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
|
if(m_pVB == NULL || m_pIB == NULL)
{
CUSTOMVERTEX * gVertPool = new CUSTOMVERTEX[8];
// Back top right
gVertPool[0].x = m_TopCorner.x + m_TopWidth;
gVertPool[0].y = m_TopCorner.y;
gVertPool[0].z = m_TopCorner.z;
// Back top left
gVertPool[1].x = m_TopCorner.x;
gVertPool[1].y = m_TopCorner.y;
gVertPool[1].z = m_TopCorner.z;
// Back bottom right
gVertPool[2].x = position->Point1->x + m_BottomWidth;
gVertPool[2].y = position->Point1->y;
gVertPool[2].z = position->Point1->z;
// Back bottom left
gVertPool[3].x = position->Point1->x;
gVertPool[3].y = position->Point1->y;
gVertPool[3].z = position->Point1->z;
// Front top right
gVertPool[4].x = m_TopCorner.x + m_TopWidth;
gVertPool[4].y = m_TopCorner.y;
gVertPool[4].z = m_TopCorner.z + m_TopDepth;
// Front top left
gVertPool[5].x = m_TopCorner.x;
gVertPool[5].y = m_TopCorner.y;
gVertPool[5].z = m_TopCorner.z + m_TopDepth;
// Front bottom right
gVertPool[6].x = position->Point1->x + m_BottomWidth;
gVertPool[6].y = position->Point1->y;
gVertPool[6].z = position->Point1->z + m_BottomDepth;
// Front bottom left
gVertPool[7].x = position->Point1->x;
gVertPool[7].y = position->Point1->y;
gVertPool[7].z = position->Point1->z + m_BottomDepth;
for(int i = 0; i < vertexCount; ++i)
{
gVertPool[i].color = m_color;
::D3DXVec3Normalize(&gVertPool[i].normal, &gVertPool[i].normal);
}
// Indexes for our cube
WORD indexList[indexCount] = { 0, 2, 3,
3, 1, 0,
7, 6, 4,
4, 5, 7,
4, 6, 2,
2, 0, 4,
1, 3, 7,
7, 5, 1,
4, 0, 1,
1, 5, 4,
2, 6, 7,
7, 3, 2 };
m_pVB = m_d3dobj->getVertexBuffer(gVertPool, vertexCount);
m_pIB = m_d3dobj->getIndexBuffer(indexList, indexCount);
}
return m_d3dobj->RenderBuffered(m_pVB, vertexCount, m_pIB, indexCount);
|