Sign in to follow this  
calidev234

Offset and Scale Mesh File

Recommended Posts

So I’ve successfully loaded two mesh files. Now I would like to offset one and scale it differently. So far I’ve tried this: -------------------------------- D3DXMATRIXA16 mW; LPVOID pVerts = NULL; D3DXMatrixIdentity( &mW ); if( SUCCEEDED( car2->mesh->LockVertexBuffer( 0, &pVerts ) ) ) { float fRadius; D3DXVECTOR3 vCtr; if( SUCCEEDED(D3DXComputeBoundingSphere( (const D3DXVECTOR3*)pVerts, car2->mesh->GetNumVertices(), car2->mesh->GetNumBytesPerVertex(), &vCtr, &fRadius ) ) ) { D3DXMatrixTranslation( &mW, 1230.f, 100.0f, 100.0f ); D3DXMATRIXA16 m; D3DXMatrixScaling( &m, 0.03f, 0.03f, 0.03f); D3DXMatrixMultiply( &mW, &mW, &m ); } car2->mesh->UnlockVertexBuffer(); } -------------------------------- I’ve only placed this in the OnCreateDevice; right after I loaded the mesh file. So far the code does not crash, but it does not offset the mesh nor does it scale it. Any ideas? Do I have to put this on the OnFrameRender as well?

Share this post


Link to post
Share on other sites
What do you mean "offset the mesh"? Are you talking about matrix translations?
As for scaling, you don't need to calculate the bound sphere, nor lock the mesh.

I believe all your problem resides in not calling device->SetTransform( D3DTS_WORLD, &mW );

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this