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

# TranslationFog.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/Fog/TranslationFog.h"
    00027 #include "Graphics/Scene/Scene.h"
    00028 #include "Graphics/Fog/Fog.h"
    00029
    00030 namespace LampForMaya{
    00031
    00032 //------------------------------------------------------------------------------
    00033 // コンストラクタ
    00034 TranslationFog::TranslationFog(){
    00035 }
    00036 //------------------------------------------------------------------------------
    00037 // デストラクタ
    00038 TranslationFog::~TranslationFog(){
    00039 }
    00040 //------------------------------------------------------------------------------
    00041 // 分析
    00042 bool TranslationFog::analyze(){
    00043     MStatus result;
    00044     int intResult;
    00045     double doubleResult;
    00046     MDoubleArray doubleArray;
    00047     // フォグが有効かどうか
    00048     result = MGlobal::executeCommand(MString(
    00049         "modelEditor -q -fogging modelPanel4;"), intResult, false, false);
    00050     MayaStatusCheck(result);
    00051     fogEnabled_ = (intResult != 0);
    00052     // フォグカラー
    00053     result = MGlobal::executeCommand(MString(
    00054         "modelEditor -q -fogColor modelPanel4;"), doubleArray, false, false);
    00055     MayaStatusCheck(result);
    00056     fogColor_.set((float)doubleArray[0], (float)doubleArray[1],
    00057         (float)doubleArray[2], (float)doubleArray[3]);
    00058     fogColor_.a = 0.f;// フォグのアルファは使用されないので0に設定
    00059     // フォグモード
    00060     result = MGlobal::executeCommand(MString(
    00061         "modelEditor -q -fogMode modelPanel4;"), fogMode_, false, false);
    00062     MayaStatusCheck(result);
    00063     // フォグ濃度
    00064     result = MGlobal::executeCommand(MString(
    00065         "modelEditor -q -fogDensity modelPanel4;"), doubleResult, false, false);
    00066     MayaStatusCheck(result);
    00067     fogDensity_ = (float)doubleResult;
    00068     // フォグニア
    00069     result = MGlobal::executeCommand(MString(
    00070         "modelEditor -q -fogStart modelPanel4;"), doubleResult, false, false);
    00071     MayaStatusCheck(result);
    00072     fogNear_ = (float)doubleResult;
    00073     // フォグファー
    00074     result = MGlobal::executeCommand(MString(
    00075         "modelEditor -q -fogEnd modelPanel4;"), doubleResult, false, false);
    00076     MayaStatusCheck(result);
    00077     fogFar_ = (float)doubleResult;
    00078 /*
    00079     DebugOut("\nfog\n");
    00080     DebugOut("fogEnabled %d\n", fogEnabled_);
    00081     DebugOut("fogColor %s\n", fogColor_.toString().getBytes());
    00082     DebugOut("fogMode %s\n", fogMode_.asChar());
    00083     DebugOut("fogDensity %f\n", fogDensity_);
    00084     DebugOut("fogNear %f\n", fogNear_);
    00085     DebugOut("fogFar %f\n", fogFar_);
    00086 //*/
    00087     return true;
    00088 }
    00089 //------------------------------------------------------------------------------
    00090 // Lampへの変換
    00091 bool TranslationFog::convertToLamp(Scene* scene){
    00092     Fog* fog = scene->getFog();
    00093     fog->setEnabled(fogEnabled_);
    00094     Color4c color;
    00095     color.set(fogColor_);
    00096     fog->setColor(color);
    00097     if(fogMode_ == "linear"){
    00098         fog->setMode(Fog::modeLinear);
    00099     }else if(fogMode_ == "exponent"){
    00100         fog->setMode(Fog::modeExponent);
    00101     }else if(fogMode_ == "exponent2"){
    00102         fog->setMode(Fog::modeExponent2);
    00103     }else{
    00104         MayaErrorOut(String("TranslationFog::convertToLamp() "
    00105             "未知のフォグモードが設定されています ") + fogMode_.asChar());
    00106         return false;
    00107     }
    00108     fog->setDensity(fogDensity_);
    00109     fog->setNear(fogNear_);
    00110     fog->setFar(fogFar_);
    00111     return true;
    00112 }
    00113 //------------------------------------------------------------------------------
    00114 } // End of namespace LampForMaya
    00115 //------------------------------------------------------------------------------