DirectX如何克隆多维数据集?

DirectX如何克隆多维数据集?,directx,cube,vertex,Directx,Cube,Vertex,我对立方体的定义如下: 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

我对立方体的定义如下:

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个顶点组成的立方体。有没有一种简单的方法可以将这些值相乘,这样我就可以得到更多相同的立方体,如图所示。(对质量很抱歉)。我想我应该创建3个循环,它们将
DrawIndexedPrimitive
放在x-y-z方向上,但我不知道我是否正确,也不知道如何编码。“看不见”,重叠和接触的边缘在这个项目中很好,所以不要担心他们

编辑: 我做到了:

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;
            }
        }
}
void多维数据集(){
浮动x=0.0;
浮动y=0.0;
浮动z=0.0;
整数乘=9;
对于(int i=0;IsettTransform(D3DTS_WORLD,&(matM*matRotY*matRotX));
D3D设备->DrawIndexedPrimitive(D3DPT_三角形列表,0,0,36,0,12);
x+=1.0f;
如果(x==乘法)
{
y+=1.0f;
x=0.0;
}
如果(y==乘法)
{
z+=1.0f;
y=0;
}
}
}

但是旋转点在由更小的立方体组成的“大立方体”的下角。你知道我怎样才能把它移到中间像(蓝点)一样吗.

你不想克隆缓冲区。定义一个平移世界矩阵,然后再次渲染相同的缓冲区。使用三个
for
循环的方法很好。你有什么具体的问题吗?@NicoSchertler,如果有少量的立方体,这很好,但我认为OP正在寻找体素几何体渲染根据他的问题,我可能错了,但在这种情况下,最好将9x9x9x24个顶点和相应的索引打包到一个顶点和索引缓冲区中,并从单个顶点缓冲区中绘制。