x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
Light.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\DarkPuzzle\GameEngine\Light.cpp
旋转
特效
属性
历史版本
#pragma once //#include "DXUT.h" #include "DarkPuzzle.h" #include "Light.h" #include "GameEngine.h" namespace DarkBattle{ list
lightPool; list
::iterator currentIterator = lightPool.begin(); const char* Light::lightNames[] = {"LampPost","LightEye"}; int Light::identifyLightType(const char* name){ for (int i=0;i
GetTransformMatrix(); D3DXMATRIX trans; D3DXMatrixTranslation(&trans,0,0,15.0f); return ret*trans; } D3DXMATRIX Light::getLampPostTransform(){ D3DXMATRIX ret = pInstance->GetTransformMatrix(); D3DXMATRIX trans; D3DXMatrixTranslation(&trans,0,0,11.0f); return ret*trans; } Light* Light::CreateLight(const Game3DInstance* pInstance, int type){ assert(type
=0); return new Light(pInstance,lightNames[type]); } Light::Light(const Game3DInstance* pInstance, const char* name){ //this->currentIterator = NULL; this->pInstance = pInstance; assert(this->pInstance!=NULL); this->getTransform = NULL; this->lightFallOff = 0.5f; this->pLightRange = &GameEngine::PointLightRange; this->lightColor[0] = this->lightColor[1] = this->lightColor[2] = 1; this->isSpotLight = false; //parse the name, init the corresponding light parameters int lightType = identifyLightType(name); assert(lightType!=LIGHT_NOTLIGHT);//only valid light is added here if (lightType==LightTypesConst::LightEye){ this->isSpotLight = true; this->pLightRange = &GameEngine::SpotLightRange; this->lightColor[1] = this->lightColor[2] = 0; //red light this->lightFallOff = 0.2f; this->getTransform = &Light::getLightEyeTransform; }else if (lightType==LightTypesConst::LamPost){ this->lightColor[0] = this->lightColor[1] = 0; //blue light this->getTransform = &Light::getLampPostTransform; } assert(this->getTransform!=NULL); //add the light to the lightPool lightPool.push_back(this); } D3DXVECTOR3 Light::GetLightDirection(){ D3DXMATRIX matRot; D3DXMatrixRotationZ(&matRot, pInstance->GetAngle()); D3DXVECTOR3 ret = D3DXVECTOR3(0,-1,-1); D3DXVec3TransformCoord(&ret,&ret,&matRot); return ret; } Light* Light::IterationBegin(){ //assert(currentIterator==NULL); currentIterator = lightPool.begin(); assert(currentIterator!=lightPool.end());//there must be at least one light return *currentIterator; } bool Light::IterationEnd(){ if (currentIterator == lightPool.end()){ currentIterator = lightPool.begin(); return true; }else return false; } Light* Light::IterationNextElement(){ currentIterator++; if (currentIterator==lightPool.end()){ return NULL; } Light* ret = *currentIterator; assert(ret!=NULL); return ret; } float Light::GetLightRadius(){ return GameEngine::SpotLightRadius; } };
Light.cpp
网页地址
文件地址
上一页
48/65
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.