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
|
tbResult RenderProc(float SecsPassed)
{
float fAspect;
D3DLIGHT9 Light;
tbMatrix mProjection;
tbMatrix mCamera;
tbMatrix mWorld;
tbVector3 vCameraDir;
// Z-Buffer leeren und die Szene beginnen
tbDirect3D::GetDevice()->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
tbDirect3D::GetDevice()->BeginScene();
// Projektionsmatrix erstellen und einsetzen
fAspect = (float)(g_Config.Direct3D.VideoMode.Width) / (float)(g_Config.Direct3D.VideoMode.Height);
mProjection = tbMatrixProjection(TB_DEG_TO_RAD(60.0f), fAspect, 1.0f, 300.0f);
tbDirect3D::GetDevice()->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)(&mProjection));
// Kameramatrix erstellen und einsetzen
vCameraDir = tbVector3(sinf(g_fCameraRot) * cosf(g_fCameraUpDown),
sinf(g_fCameraUpDown),
cosf(g_fCameraRot) * cosf(g_fCameraUpDown));
mCamera = tbMatrixCamera(g_vCameraPos, g_vCameraPos + vCameraDir);
tbDirect3D::GetDevice()->SetTransform(D3DTS_VIEW, (D3DMATRIX*)(&mCamera));
ZeroMemory(&Light, sizeof(D3DLIGHT9));
Light.Type = D3DLIGHT_DIRECTIONAL;
Light.Diffuse = tbColor(0.5f, 0.5f, 0.5f);
Light.Ambient = tbColor(0.5f, 0.5f, 0.5f);
Light.Specular = tbColor(0.5f, 0.5f, 0.5f);
Light.Direction = vCameraDir;
tbDirect3D::GetDevice()->SetLight(0, &Light);
tbDirect3D::GetDevice()->LightEnable(0, TRUE);
mWorld = tbMatrixRotationZ(0.5f * g_fTime) * tbMatrixRotationX(0.5 * g_fTime);
tbDirect3D::GetDevice()->SetTransform(D3DTS_WORLD, (D3DMATRIX*)(&mWorld));
// Das Modell rendern (zuerst alle opaken Effekte, dann alle transparenten)
g_pModell->Render();
tbDirect3D::GetDevice()->EndScene();
tbDirect3D::GetDevice()->Present(NULL, NULL, NULL, NULL);
return TB_OK;
}
|