问题描述
- DX绘制一个椎体,麻烦大家给看看,顶点和索引序列有问题么?
- const int circlePoints = 4;//锥低边的定点数
const int radiu = 1;//锥底半径VB->Lock(0 0 (void**)&vertices 0);
// vertices of a unit centrumfor (int i = 0;i<=circlePoints+1;i++){ if (i==0) { vertices[i] = ColorVertex(0.0f 1.0f 0.0fD3DCOLOR_XRGB(02550)); }else if (i==1) { vertices[i] = ColorVertex(0.0f -1.0f 0.0fD3DCOLOR_XRGB(00255)); } else{ vertices[i] = ColorVertex(radiu*cos((i - 2)*2*D3DX_PI/circlePoints) -1.0f radiu*sin((i - 2)*2*D3DX_PI/circlePoints)D3DCOLOR_XRGB(25500)); }}VB->Unlock();// define the triangles of the cube:WORD* indices = 0;IB->Lock(0 0 (void**)&indices 0);for (int j=0;j < circlePoints;j++){ if(j==circlePoints - 1) { indices[j*6] = j%2 == 0?0:j+2; indices[j*6+1] = j%2 == 0?j+2:0; indices[j*6+2] = j%2 == 0?2:2; indices[j*6+3] = j%2 == 0?1:j+2; indices[j*6+4] = j%2 == 0?j+2:1; indices[j*6+5] = j%2 == 0?2:2; } else { indices[j*6] = j%2 == 0?0:j+2; indices[j*6+1] = j%2 == 0?j+2:0; indices[j*6+2] = j%2 == 0?j+3:j+3; indices[j*6+3] = j%2 == 0?1:j+2; indices[j*6+4] = j%2 == 0?j+2:1; indices[j*6+5] = j%2 == 0?j+3:j+3; }}可是就是画不出来,当circlePoints是3的时候能画出来一个面,其它值什么都没有
时间: 2024-08-03 20:39:48