how do I load and control different meshes?

Started by
3 comments, last by Tevong 22 years, 2 months ago
I''m using DirectX8 in VB and i can load one textured mesh fine and set controls with the cursor key. I set the world transformation to move it about but I was wondering how do I load several meshes and set a different world transformation to each? The D3DXMatrixTransform takes only a D3D Device as a parameter so I can''t specify which object I want to transform. Or do I have to reload the mesh everytime I Want to move a different mesh?
Signed: ___T____
Advertisement
You need to make several transformation matrices and apply them before rendering respective meshes. There might be a more efficient way to do this.
---visit #directxdev on afternet <- not just for directx, despite the name
here''s the order my program does things:

-create device
-load mesh
-set matrices
-draw mesh

Here''s how I draw the mesh:

Dim counter As Long
''meshes are divided in subsets, one for each material
''loop through each subset
For counter = 0 To numMaterials - 1

''set the material and texture for this subset
objD3DDevice.SetMaterial Materials(counter)
objD3DDevice.SetTexture 0, Textures(counter)

''draw the mesh subset
objMesh.DrawSubset counter

Next counter

so I''d have to save different materials and textures array for every mesh and draw the mesh I want to transform after specifying the transform?
Signed: ___T____
OK just tried doing it this way let me know if there''s a better way:

Public Type MESHTYPE
meshName As String
mesh As D3DXMesh
moveX As Single
moveY As Single
moveZ As Single
numMaterials As Long
materials() As D3DMATERIAL8
textures() As Direct3DTexture8
End Type

and the DrawMesh function takes a MESHTYPE as a parameter after applying the world transformation matrix to draw the mesh which I want to transform.

Signed: ___T____
to move seperate meshes, just set the world matrix as needed. you can set it an unlimited amount of times.

for example:

move first mesh
SetTransform(worldmatrix)

move next mesh
SetTransform(worldmatrix)

there''s only one world matrix...you just move it, draw what you want moved, then set it back.

This topic is closed to new replies.

Advertisement