multiple meshes (more noob ?s)

Started by
2 comments, last by nosajghoul 21 years, 9 months ago
I finally get how to load a mesh, so I tried loading 2. I got that to work, but theyre intersecting each other. How do I place individual objects in a scene and move them about independently? (for example, have a stationary ground, and a ship (or 20) that flies over it) thanks again, jason
normal_toes@hotmail.com
Advertisement
Use a different world matrix for each one. Set it with SetTransform before displaying appropriate meshes.
---visit #directxdev on afternet <- not just for directx, despite the name
A well commmented code snippet would be swell...
normal_toes@hotmail.com
Jason,

I would suggest you read up on using world transformation matrices before going any further if you''re having trouble. Basically, you set the projection transformation once during initialization, set the view transformation once per frame (if it moves), and than for each mesh, set the world transformation, draw a mesh, set next world transformation, draw a mesh, set world... and so on.

To give you your answer in pseudo-code:

For each mesh to draw:
Set mesh''s world transformation matrix
For each material subset in mesh
Set material
Set texture
Draw subset
Next subset
Next mesh

So, basically, a mesh is transformed and rendered using the world transformation currently set. To set any transformation, use the IDirect3DDevice8::SetTransform using D3DTS_WORLD, D3DTS_VIEW, and D3DTS_PROJECTION.



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX

This topic is closed to new replies.

Advertisement