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
|
g_pVertexBuffer->Lock(0,0,(void**)(&pVertices),D3DLOCK_NOSYSLOCK);
g_pIndexBuffer->Lock(0,0,(void**)(&pwIndices),D3DLOCK_NOSYSLOCK);
for(int iCube = 0; iCube < g_iNumCubes; iCube++)
{
g_aCubes[iCube].vPosition = tbVector3Random() * tbFloatRandom(20.0f,250.0f);
g_aCubes[iCube].vDirection = tbVector3Random() * tbFloatRandom(1.0f,20.0f);
}
pVertices[0].vPosition = tbVector3(-1.0f,1.0f,-1.0f); //vorne links oben
pVertices[1].vPosition = tbVector3(-1.0f,1.0f,1.0f); //hinten links oben
pVertices[2].vPosition = tbVector3(1.0f,1.0f,1.0f); //hinten rechts oben
pVertices[3].vPosition = tbVector3(1.0f,1.0f,-1.0f); //vorne rechts oben
pVertices[4].vPosition = tbVector3(-1.0f,-1.0f,-1.0f);//vorne links unten
pVertices[5].vPosition =tbVector3(-1.0f,-1.0f,1.0f);//hinten links unten
pVertices[6].vPosition = tbVector3(1.0f,-1.0f,1.0f); //hinten rechts unten
pVertices[7].vPosition = tbVector3(1.0f,-1.0f,-1.0f);//vorne rechts unten
for(int iVertex = 0; iVertex < 8; iVertex++)
{
pVertices[iVertex].dwColor = tbColorRandom(1.0f) * 2.0f;
pVertices[iVertex].vTexture = tbVector2Random();
}
int aiIndex[36] = {0,3,7, 0,7,4, // Vorderseite
2,1,5, 2,5,6, // Hinterseite
1,0,4, 1,4,5, // Linke Seite
3,2,6, 3,6,7, // Rechte Seite
0,1,2, 0,2,3, // Oberseite
6,5,4, 6,4,7}; // Unterseite
for(int iIndex = 0; iIndex < 36; iIndex++)
{
pwIndices[iIndex] = (WORD)(aiIndex[iIndex]);
}
g_pVertexBuffer->Unlock();
g_pIndexBuffer->Unlock();
|