NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
LightPointRenderable.cpp
Go to the documentation of this file.
00001 
00009 #include <d3dx9.h>
00010 #include <windows.h>
00011 
00012 #include "../../../sharedbase/Entity.h"
00013 
00014 #include "LightPointRenderable.h"
00015 
00016 namespace GraphicsCore {
00017   LightPointRenderable::LightPointRenderable(EntitySPTR owner, ModuleInterface* renderModule) :
00018       LightDirectionalRenderable(owner, renderModule) {
00019     this->SetEnableStatus(true);
00020     this->SetAmbientColor(D3DCOLOR_XRGB(10, 10, 10));
00021     this->SetDiffuseColor(D3DCOLOR_XRGB(255, 255, 255));
00022     this->SetSpecularColor(D3DCOLOR_XRGB(255, 255, 255));
00023     this->SetRange(1000.0f);
00024   }
00025 
00026   LightPointRenderable::~LightPointRenderable() {
00027   }
00028   
00029   void LightPointRenderable::Render(LPDIRECT3DDEVICE9 pd3dDevice) {
00030     if (this->GetEnableStatus()) {
00031       this->light.Type = D3DLIGHT_POINT;
00032       this->light.Diffuse = this->GetDiffuseColor();
00033       this->light.Specular = this->GetSpecularColor();
00034       this->light.Ambient = this->GetAmbientColor();
00035       this->light.Position = this->owner->GetWorldPosition();
00036       this->light.Range = this->GetRange();
00037       this->light.Attenuation0 = 0.0f;
00038       this->light.Attenuation1 = 1.0f;
00039       this->light.Attenuation2 = 0.0f;
00040       
00041       int lightIndex = this->GetLightIndex();
00042       
00043       if (lightIndex <= 7) {
00044         pd3dDevice->SetLight(lightIndex, &this->light);
00045         pd3dDevice->LightEnable(lightIndex, TRUE);
00046       }
00047     }
00048 
00049   }
00050 }