OSDN Git Service

fix cmake/Macros.cmake
[moflib/moflib.git] / moflib-1.0 / moflib / moflib / mof / DirectionalLight.cpp
1 #include "mof/DirectionalLight.hpp"
2 #include <d3dx9.h>
3 #include "mof/GraphicsDevice.hpp"
4 #include "mof/private/GraphicsDeviceImpl.hpp"
5
6
7 mof::DirectionalLight::DirectionalLight(mof::Color diffuse , mof::Color ambient , mof::Vector3D& direction)
8 : mof::Light()
9 {
10         setDiffuseColor(diffuse);
11         setAmbientColor(ambient);
12         setDirection(direction);
13
14 }
15
16
17 void mof::DirectionalLight::update(){
18         //mof::Animation* pAnimation = getAnimation();
19         //if(pAnimation == NULL)return;
20         //pAnimation->update();
21         //mof::Color color = pAnimation->get();
22         //set(pAnimation->getColor());
23 }
24
25 void mof::DirectionalLight::reflect(){
26         LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();
27         D3DLIGHT9 light;
28         ZeroMemory(&light , sizeof(light));
29         light.Type = D3DLIGHT_DIRECTIONAL;
30         light.Diffuse.a = (float)mof::getAlpha(m_diffuse) / 255.0f;
31         light.Diffuse.r = (float)mof::getRed(m_diffuse) / 255.0f;
32         light.Diffuse.g = (float)mof::getGreen(m_diffuse) / 255.0f;
33         light.Diffuse.b = (float)mof::getBlue(m_diffuse) / 255.0f;
34
35         light.Ambient.a = (float)mof::getAlpha(m_ambient) / 255.0f;
36         light.Ambient.r = (float)mof::getRed(m_ambient) / 255.0f;
37         light.Ambient.g = (float)mof::getGreen(m_ambient) / 255.0f;
38         light.Ambient.b = (float)mof::getBlue(m_ambient) / 255.0f;
39
40         light.Direction = D3DXVECTOR3(m_direction.x , m_direction.y , m_direction.z);
41         
42         
43         pDevice->SetLight(0 , &light);
44         pDevice->LightEnable(0 , TRUE);
45 }