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

TranslationPointLight.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/Light/TranslationPointLight.h"
00027 #include "Graphics/Scene/Scene.h"
00028 #include "Graphics/Light/LightManager.h"
00029 
00030 namespace LampForMaya{
00031 
00032 //------------------------------------------------------------------------------
00033 // コンストラクタ
00034 TranslationPointLight::TranslationPointLight(
00035     const MDagPath& initializeDagPath, const String& initializeName) :
00036     TranslationLight(initializeDagPath, initializeName){
00037 }
00038 //------------------------------------------------------------------------------
00039 // デストラクタ
00040 TranslationPointLight::~TranslationPointLight(){
00041 }
00042 //------------------------------------------------------------------------------
00043 // 分析
00044 bool TranslationPointLight::analyze(){
00045     // ライトのアナライズ
00046     if(!analyzeLight()){ return false; }
00047     MStatus result;
00048     String errorString;
00049     MFnPointLight lightShape(dagPath_.node(), &result);
00050     MayaStatusCheck(result);
00051     MFnTransform lightTransform(dagPath_.transform(), &result);
00052     MayaStatusCheck(result);
00053     // 位置
00054     MMatrix worldMatrix = lightTransform.transformationMatrix(&result);
00055     MayaStatusCheck(result);
00056     position_.set(
00057         (float)worldMatrix.matrix[3][0],
00058         (float)worldMatrix.matrix[3][1],
00059         (float)worldMatrix.matrix[3][2]);
00060     position_.set(0.f, 0.f, 0.f);
00061     // 減衰係数
00062     decayRate_ = lightShape.decayRate(&result);
00063     MayaStatusCheck(result);
00064     return true;
00065 }
00066 //------------------------------------------------------------------------------
00067 // Lampへの変換
00068 bool TranslationPointLight::convertToLamp(Scene* scene){
00069     LightManager* lightManager = scene->getLightManager();
00070     PointLight* light = lightManager->createPointLight(name_);
00071     light->setColor(exportColor_);
00072     light->setLightMask(lightMask_);
00073     light->setEnabled(visibility_);
00074     light->setPosition(position_);
00075     light->setRange(calcRange(decayRate_));
00076     if(decayRate_ == 0){
00077         light->setAttenuation(1.f, 0.f, 0.f);
00078     }else if(decayRate_ == 1){
00079         light->setAttenuation(0.f, 1.f, 0.f);
00080     }else if(decayRate_ == 2){
00081         light->setAttenuation(0.f, 0.f, 1.f);
00082     }else{
00083         MayaErrorOut(String("TranslationPointLight::convertToLamp() ") +
00084             name_ + "にサポートされていない減衰係数が設定されています");
00085         return false;
00086     }
00087     return true;
00088 }
00089 //------------------------------------------------------------------------------
00090 } // End of namespace LampForMaya
00091 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:56 2005 for LampForMaya by doxygen 1.3.2