00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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 }
00091