-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlight.cpp
More file actions
101 lines (79 loc) · 2.83 KB
/
light.cpp
File metadata and controls
101 lines (79 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//--------------------------------------------------------------------------------------------------------
//
//ライト処理[light.cpp]
//Author:菊地陽人
//
//--------------------------------------------------------------------------------------------------------
#include "main.h"
#include "light.h"
#include "input.h"
#include "color.h"
//マクロ定義
#define NUM_LIGHT (4) //ライトの数
//グローバル変数
D3DLIGHT9 g_aLight[NUM_LIGHT];
////ライトの向き格納
//const D3DXVECTOR3 c_apLightVec[NUM_LIGHT] = {
// D3DXVECTOR3(0.2f, -0.8f, 0.4f),
// D3DXVECTOR3(-0.2f, 0.8f, -0.4f),
// D3DXVECTOR3(0.8f, -0.1f, 0.4f),
//};
//--------------------------------------------------------------------------------------------------------
//ライトの初期化処理
//--------------------------------------------------------------------------------------------------------
void InitLight(void)
{
#if 0
//デバイスの取得
LPDIRECT3DDEVICE9 pDevice = GetDevice();
D3DXVECTOR3 aVecDir[NUM_LIGHT]; //設定用方向ベクトル
for (int nCntLight = 0; nCntLight < NUM_LIGHT; nCntLight++)
{
//ライトの方向を設定
aVecDir[nCntLight] = c_apLightVec[nCntLight];
//ライトの情報をクリアする
ZeroMemory(&g_aLight[nCntLight], sizeof(D3DLIGHT9));
//ライトの種類を設定
g_aLight[nCntLight].Type = D3DLIGHT_DIRECTIONAL;
//ライトの拡散光を設定
g_aLight[nCntLight].Diffuse = XCOL_WHITE;
D3DXVec3Normalize(&aVecDir[nCntLight], &aVecDir[nCntLight]); //ベクトルを正規化する
g_aLight[nCntLight].Direction = aVecDir[nCntLight];
//ライトを設定する
pDevice->SetLight(nCntLight, &g_aLight[nCntLight]);
//ライトを有効にする
pDevice->LightEnable(nCntLight, TRUE);
}
#endif
}
//--------------------------------------------------------------------------------------------------------
//ライトの終了処理
//--------------------------------------------------------------------------------------------------------
void UninitLight(void)
{
}
//--------------------------------------------------------------------------------------------------------
//ライトの更新処理
//--------------------------------------------------------------------------------------------------------
void UpdateLight(void)
{
}
//--------------------------------------------------------------------------------------------------------
//ライトの設定処理
//Author:石原颯馬
//--------------------------------------------------------------------------------------------------------
void SetLight(int nLightNum, D3DLIGHT9 light)
{
//デバイスの取得
LPDIRECT3DDEVICE9 pDevice = GetDevice();
//ライトの情報をクリアする
ZeroMemory(&g_aLight[nLightNum], sizeof(D3DLIGHT9));
//引数のライト情報を代入
g_aLight[nLightNum] = light;
//ライトの種類を設定
g_aLight[nLightNum].Type = D3DLIGHT_DIRECTIONAL;
//ライトを設定する
pDevice->SetLight(nLightNum, &g_aLight[nLightNum]);
//ライトを有効にする
pDevice->LightEnable(nLightNum, TRUE);
}