我已按如下方式定义了一个多维数据集:
void cube(void){
struct CUSTOMVERTEX vertices[] =
{
{ D3DXVECTOR3(-0.5000f, -0.5000f, 0.5000f), //pos of first vertex
D3DXVECTOR3( 0.0000f, 0.0000f, 1.0000f), //normal of first vertex
D3DXCOLOR ( 1.0f, 0.0f, 0.0f, 0.5f), //color of first vertex
D3DXVECTOR2( 1.0000f, 1.0000f) }, //texture of first vertex
// ... data for other 35 vertices
static short indices[]=
// here are the indices
//next I did:
CreateVertexBuffer();
CreateIndexBuffer();
在我的BeginScene();
我致电:
d3ddevice->SetStreamSource(0, vb, 0, sizeof(CUSTOMVERTEX));
d3ddevice->SetIndices(ib);
d3ddevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 36, 0 , 12);
这给了我一个由12个三角形和36个顶点组成的立方体。有没有一种简单的方法可以将这些值相乘,这样我就可以获得更多相同的多维数据集here。 (质量保证)。我认为我应该在x y z方向上创建3个DrawIndexedPrimitive
循环,但我不知道我是否正确,并且不知道如何编码它。 “不可见”,重叠和接触边缘在这个项目中很好,所以不要担心它们。
编辑: 我做到了:
void cubes () {
float x = 0.0;
float y = 0.0;
float z = 0.0;
int multiply = 9;
for (int i=0;i<multiply*multiply*multiply;i++)
{
D3DXMatrixTranslation(&matM,x,y,z);
d3ddevice->SetTransform(D3DTS_WORLD, &(matM*matRotY*matRotX));
d3ddevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 36, 0 , 12);
x += 1.0f;
if (x==multiply)
{
y += 1.0f;
x = 0.0;
}
if (y==multiply)
{
z +=1.0f;
y = 0;
}
}
}
但旋转点位于由较小立方体组成的“大立方体”的下角。我知道如何将它移动到中间,如here(蓝点)。