Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

# TranslationPicture.cpp

Go to the documentation of this file.

    00001 //------------------------------------------------------------------------------
    00002 // Lamp : Open source game middleware
    00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
    00004 //
    00005 // This library is free software; you can redistribute it and/or
    00006 // modify it under the terms of the GNU Lesser General Public
    00007 // License as published by the Free Software Foundation; either
    00008 // version 2.1 of the License, or (at your option) any later version.
    00009 //
    00010 // This library is distributed in the hope that it will be useful,
    00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013 // Lesser General Public License for more details.
    00014 //
    00015 // You should have received a copy of the GNU Lesser General Public
    00016 // License along with this library; if not, write to the Free Software
    00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018 //------------------------------------------------------------------------------
    00019
    00020 /** @file
    00021  * 変換ピクチャ実装
    00022  * @author Junpee
    00023  */
    00024
    00025 #include "System/stdafx.h"
    00026 #include "Translator/Picture/TranslationPicture.h"
    00027 #include "Graphics/Scene/Scene.h"
    00028 #include "Graphics/Picture/PictureManager.h"
    00029 #include "Core/Codec/Tga/TargaLoader.h"
    00030
    00031 namespace LampForMaya{
    00032
    00033 //------------------------------------------------------------------------------
    00034 // コンストラクタ
    00035 TranslationPicture::TranslationPicture(const String& initializeName,
    00036     const String& initializePath) :
    00037     name_(initializeName), path_(initializePath){
    00038 }
    00039 //------------------------------------------------------------------------------
    00040 // デストラクタ
    00041 TranslationPicture::~TranslationPicture(){
    00042 }
    00043 //------------------------------------------------------------------------------
    00044 // Lampへの変換
    00045 bool TranslationPicture::convertToLamp(Scene* scene){
    00046     PictureManager* pictureManager = scene->getPictureManager();
    00047     TargaLoader loader(path_);
    00048     if(!loader.loadHeader()){
    00049         MayaErrorOut(String("TranslationPicture::convertToLamp() "
    00050             "ピクチャの読み込みに失敗しました ") + path_);
    00051         return false;
    00052     }
    00053     Picture* picture;
    00054     if(loader.hasAlpha()){
    00055         PictureRGBA8* pictureRGBA8 = pictureManager->createPictureRGBA8(name_);
    00056         picture = pictureRGBA8;
    00057         pictureRGBA8->setSize(loader.getSize());
    00058         loader.loadImage(pictureRGBA8->getImageBuffer());
    00059     }else{
    00060         PictureRGB8* pictureRGB8 = pictureManager->createPictureRGB8(name_);
    00061         picture = pictureRGB8;
    00062         pictureRGB8->setSize(loader.getSize());
    00063         loader.loadImage(pictureRGB8->getImageBuffer());
    00064     }
    00065     picture->setPath(path_);
    00066     return true;
    00067 }
    00068 //------------------------------------------------------------------------------
    00069 } // End of namespace LampForMaya
    00070 //------------------------------------------------------------------------------