I m 试图在屏幕上放置一只ube子......i 有一个照相机,以摩擦和键板的指挥进行轮换和翻译......然而,在运行期间,ube的平方表面在屏幕上平平平平,而照相机正在轮换......屏幕上的其他物品在平方表面上出现......任何人都解释出放火的过程? 事先感谢任何帮助......
#define SQUAREFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
struct SQUARE {
float x, y, z;
DWORD color;
};
SQUARE vert[] =
{
// 1
{ -64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
{ -64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
{ 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
{ 64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
};
bool CGraphics::TerrainTwo(D3DXVECTOR3 minB, D3DXVECTOR3 maxB, int numCellsW, int numCellsL)
{
HRESULT hr;
void* pVoid;
hr = m_d3ddev->CreateVertexBuffer(sizeof(SQUARE)*sizeof(vert),0,
CUSTOMFVF,D3DPOOL_DEFAULT,&m_terrainVertexBuffer,NULL);
if(FAILED(hr)){
MessageBox(NULL, L"Could not Create Vertex Buffer", L"ERROR", MB_OK);
return false;
}
hr = m_terrainVertexBuffer->Lock(0, 0, (void**)&pVoid, NULL);
if(FAILED(hr)){
MessageBox(NULL, L"Could not Lock Vertex Buffer", L"ERROR", MB_OK);
return false;
}
memcpy(pVoid, &vert, sizeof(vert));
m_terrainVertexBuffer->Unlock();
/*hr = m_d3ddev->CreateIndexBuffer(sizeof(DWORD)*sizeof(indices),0,
D3DFMT_INDEX16, D3DPOOL_DEFAULT, &m_terrainIndexBuffer, NULL);
if(FAILED(hr)){
MessageBox(NULL, L"Could not Create Index Buffer", L"ERROR", MB_OK);
return false;
}
hr = m_terrainIndexBuffer->Lock(0, 0, (void**)&pVoid, 0);
if(FAILED(hr)){
MessageBox(NULL, L"Could not Create Vertex Buffer", L"ERROR", MB_OK);
return false;
}
memcpy(pVoid, indices, sizeof(indices));
if(FAILED(hr)){
MessageBox(NULL, L"Could not Create Vertex Buffer", L"ERROR", MB_OK);
return false;
}
m_terrainIndexBuffer->Unlock();*/
return true;
}
void CGAME::Update()
{
if(m_graphics){
//m_graphics->UpdateSkyBox();
D3DXMATRIX matRotX, matRotY, matRotZ, matTrans;
D3DXMatrixRotationX (&matRotX, 0);
D3DXMatrixRotationY( &matRotY, 0 );
D3DXMatrixRotationZ( &matRotZ, 0 );
// Calculate a translation matrix
D3DXMatrixTranslation(&matTrans,5.0,1.0,5.0);
D3DXMATRIX matWorld = (matRotX*matRotY*matRotZ)*matTrans;
m_graphics->RenderTerrain(matWorld);
}
}
void CGraphics::RenderTerrain(D3DXMATRIX matW)
{
m_d3ddev->SetTransform(D3DTS_WORLD, &matW);
m_d3ddev->SetTexture(0, NULL);
m_d3ddev->SetStreamSource(0, m_terrainVertexBuffer, 0, sizeof(SQUARE));
m_d3ddev->SetFVF(CUSTOMFVF);
m_d3ddev->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
}