为什么我的球体纹理坏了? [Directx 9,c ++]

时间:2015-09-26 20:42:13

标签: c++ directx-9

我使用D3DXCreateSphere()函数创建我的球体,我想获得顶点位置来计算纹理坐标,但它破了!我需要帮助〜

  1. front side
  2. back side
  3. 这是我的结构顶点:

      

    struct _VERTEX {D3DXVECTOR3规范;漂浮;漂浮电视; };

    这是我的代码:

    LPD3DXMESH mesh;
    LPD3DXMESH texMesh;
    
    D3DXCreateSphere(pDev, 3, 20, 20, &mesh, NULL);
    
    mesh->CloneMeshFVF(D3DXMESH_SYSTEMMEM, FVF_VERTEX, pDev, &texMesh);
    
    mesh->Release();
    
    _VERTEX *pVerts;
    if (SUCCEEDED(texMesh->LockVertexBuffer(0, (void **)&pVerts))) {
    
        int numVerts = texMesh->GetNumVertices();
    
        for (int i = 0; i<numVerts; i++) {
    
            pVerts->tu = asinf(pVerts->norm.x) / D3DX_PI + 0.5f;
            pVerts->tv = asinf(pVerts->norm.y) / D3DX_PI + 0.5f;
    
            pVerts++;
        }
    
        texMesh->UnlockVertexBuffer();
    }
    
    pDev->SetTexture(0, texture);
    texMesh->DrawSubset(0);
    

0 个答案:

没有答案