Jump to content
  • Advertisement
Sign in to follow this  
calidev234

Offset and Scale Mesh File

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!