Translating/Transforming meshes

stevenmu

Member
Joined
Jun 8, 2005
Messages
5
Hi All,

Apologies in advance for this incredibly stupid question, but I cant seem to find the answer in any of the tutorials, samples or forums. Im trying to create a 3d graph component (more as a learning excersise than anything else) that shows a bar graph in 3d and spins it around. Im able to create each bar as a mesh at runtime, render it and use a world transform to rotate the world around the y-axis but this is leading to occlusion problems. So what I want to do, and I think this would be the proper way of doing it, is to create each bar as a mesh at the origin, then translate them along the x-axis to their proper places in the graph and then perform a translation on each of them to rotate them about the y-axis.

Now for the really silly part, I think I can figure out the proper matrices but Ive no idea how to apply them to the meshes, I can see how to do it in the unmanaged APIs but not the managed for some reason. Anybody got any tips or clues ?

Thanks,
Steve.
 
Its still just a matter of setting your World matrix. To change the size of your meshes be sure to multiply a scaling matrix before your translation matrix.
 
Thanks for the reply, Id been starting to wonder if that might be the case. Does that mean though that to apply different transforms to different meshes I would need to set the world matrix, render a mesh, set the world matrix again, render the next mesh etc ?
 
stevenmu said:
Thanks for the reply, Id been starting to wonder if that might be the case. Does that mean though that to apply different transforms to different meshes I would need to set the world matrix, render a mesh, set the world matrix again, render the next mesh etc ?
Exactly.

Err... "The message you have entered is too short. Please lengthen your message to at least 10 characters."

Im all set now
 
Seems a little counter-intuitive to me but I suppose the reasoning behind it will become clearer as I advance. Thanks for your help



(I sorted the occlusion problem I was having, Id commented out the line enabling the z-buffer and forgotten all about it :o )
 
The World matrix is a transform thru which all vertices must pass; it maps vertex coordinates to world coordinates.
Really you should use the View matrix to handle the rotation of the graph.
 
IngisKahn said:
The World matrix is a transform thru which all vertices must pass; it maps vertex coordinates to world coordinates.
Really you should use the View matrix to handle the rotation of the graph.
Im hoping to be able to render other objects independantly of the graph, such as a key which would stay in one corner of the screen or perhaps if there was a list of graphs to show the next and previous ones static to each side. If I use the view matrix it would be very complicated to get everything to its proper position, using the world matrix I can (I think I can at least) draw any meshes which should be transformed, i.e. the active graph, then apply a matrix to rotate the correct amount around the y-axis, then draw the other meshes such as the ones for the key.
 
Yeah, I think sprites will work well for the key, and its a good chance to try out something new.

Ive changed the it now to create all the meshes at the origin and move each one out using the world matrix and its working prefectly. I came across ThePentiumGuys tutorial in tutors corner which explains why its done that way and it makes sense, even though its slightly more complicated to code for.

Thanks for all your help.
 
Back
Top