Direct3D中读取txt文件中的坐标数据,如何根据坐标数据进行顶点缓存并绘制三维建筑?

Direct3D中读取txt文件中的坐标数据,如何根据坐标数据进行顶点缓存并绘制三维建筑?

问题描述:

我已经从txt文件中读取出来了数据(x,y,z1,z2),在使用顶点缓存时出现了问题,不知道该怎么做
//-----------------------------------------------------------------------------
// Desc: 创建并填充顶点缓冲区
//-----------------------------------------------------------------------------
HRESULT InitVB()
{
//顶点数据读取
read();

for(int s=0;s<500;s++)
{
    MPoint Mpoint[]={
        {Mpoint[s].x,Mpoint[s].y,Mpoint[s].z1,},
        {Mpoint[s].x,Mpoint[s].y,Mpoint[s].z2,},
    };
}
//创建顶点缓冲区
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 3100*sizeof(MPoint),
                                              0, D3DFVF_MPoint,
                                              D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
{
    return E_FAIL;
}

//填充顶点缓冲区
VOID* pMPoint;
if( FAILED( g_pVB->Lock( 0, sizeof(Mpoint), (void**)&pMPoint, 0 ) ) )
    return E_FAIL;

memcpy( pMPoint, Mpoint, sizeof(Mpoint) );
g_pVB->Unlock();

return S_OK;

}