2.4 Light It Up with cLitht(照耀他吧灯光!)

 

2.4 Light It Up with cLitht(照耀他吧灯光!)

I Don’t Why 老外总要在这整些没用的。。。。。

class cLight

{

protected:

D3DLIGHT8 m_Light; // Light 结构体

 

public:

cLight(); // 构造函数

D3DLIGHT8 *GetLight(); // 返回 light 结构体

BOOL SetType(D3DLIGHTTYPE Type); // 设置灯光类型:

// D3DLIGHT_POINT

// D3DLIGHT_SPOT

// D3DLIGHT_DIRECTIONAL

// 移动灯光到指定坐标,分为绝对坐标移动和相对(于当前位置)坐标移动

BOOL Move(float XPos, float YPos, float ZPos);

BOOL MoveRel(float XPos, float YPos, float ZPos);

// 获取当前位置并保存到变量中

BOOL GetPos(float *XPos, float *YPos, float *ZPos);

// 设置灯光方向,分为绝对坐标和相对坐标

BOOL Point(float XPos, float YPos, float ZPos);

BOOL PointRel(float XPos, float YPos, float ZPos);

// 获取当前方向并保存到变量中

BOOL GetDirection(float *XPos, float *YPos, float *ZPos);

// 设置和获取各不同颜色值

BOOL SetDiffuseColor(char Red, char Green, char Blue);

BOOL GetDiffuseColor(char *Red, char *Green, char *Blue);

BOOL SetSpecularColor(char Red, char Green, char Blue);

BOOL GetSpecularColor(char *Red, char *Green, char *Blue);

BOOL SetAmbientColor(char Red, char Green, char Blue);

BOOL GetAmbientColor(char *Red, char *Green, char *Blue);

// 设置和获取灯光照明范围

BOOL SetRange(float Range);

float GetRange();

// 设置和获取分散(?)值

BOOL SetFalloff(float Falloff);

float GetFalloff();

// 设置和获取衰减值

BOOL SetAttenuation0(float Attenuation);

float GetAttenuation0();

BOOL SetAttenuation1(float Attenuation);

float GetAttenuation1();

BOOL SetAttenuation2(float Attenuation);

float GetAttenuation2();

// 设置和获取 Theta

BOOL SetTheta(float Theta);

float GetTheta();

// 设置和获取 Phi

BOOL SetPhi(float Phi);

float GetPhi();

};

 

 

NOTE:当被实例化,cLight类将配置一个白灯光,并安置在(0,0,0).当你调用Point PointRel时方向是Normalized(正常的)

 

要在你的工程中使用灯光,你仅需实例化一个cLight对象,选择一个灯光类型,设置灯光颜色,位置(如果必要的话还有照明的方向)。

要设置一个灯光, ,要使用cGraphics::SetLitht

下面是一个创建一个白色灯光的例子:

// 如果 g_Graphics 是一个已经被初始化过的cGraphics 对象

cLight DirLight;

DirLight.SetType(D3DLIGHT_DIRECTIONAL);

DirLight.Move(0.0, 10.0f, 0.0f); // 离原点向上移动十个单位

DirLight.Point(0.0, -1.0, 0.0f); // 向下照明

g_Graphics.SetLight(0, &DirLight); // 设置为 0号灯光

g_Graphics.EnableLight(0, TRUE); // 拉登

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值