Original Post
I don''t get why this doesn''t work. Wall is a simple 12 triangle mesh. I use similar code to scale my terain and it works flawlessly. What am I missing?
What i get is a bunch of trangles shooting off in all sorts of oddball directions.
What I''m trying to do is transform the mesh in the VB so I don''t have to transform it each time I go to render it. This is a static object so it doesn''t make sense to me to have to transform it each time I have to render it.
pVertices.x += 300; Doesn''t work either.
Shad
CD3DMesh *m_pWall; // Wall Object
// Code from InitDeviceObjects
D3DXMATRIXA16 matx;
D3DXVECTOR3 vecx;
if( FAILED( m_pWall->Create( m_pd3dDevice, _T("wall2.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
D3DXMatrixTranslation( &matx, 300, 0, 0 );
LPDIRECT3DVERTEXBUFFER8 pVB;
if( SUCCEEDED( m_pWall->GetSysMemMesh()
->GetVertexBuffer( &pVB ) ) )
{
struct VERTEX { FLOAT x,y,z,tu,tv; };
VERTEX* pVertices;
DWORD dwNumVertices = m_pWall->GetSysMemMesh()
->GetNumVertices();
pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
for( DWORD i=0; i<dwNumVertices; i++ )
{
vecx.x = pVertices[i].x;
vecx.y = pVertices[i].y;
vecx.z = pVertices[i].z;
D3DXVec3TransformCoord(&vecx,&vecx,&matx);
pVertices[i].x = vecx.x;
pVertices[i].y = vecx.y;
pVertices[i].z = vecx.z;
}
pVB->Unlock();
pVB->Release();
}