Translating/Transforming meshes

stevenmu

Newcomer
Joined
Jun 8, 2005
Messages
5
Hi All,

Apologies in advance for this incredibly stupid question, but I can't seem to find the answer in any of the tutorials, samples or forums. I'm 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. I'm 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 I've 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.
 
It's 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, I'd 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, I'd 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."

I'm 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, I'd 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.
I'm 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 it's 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 it's a good chance to try out something new.

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

Thanks for all your help.
 
Back
Top