Jump to content
  • Advertisement
Sign in to follow this  
Dean1988

Vb.net - Dx9 - Translation + Rotation with Meshes problem.

This topic is 4675 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

hi guys I've recently, the last day or two go into Dx9 with VB.NET (due to job) And i have a problem...possibly. basically, i'm rendering 2 meshes, and i want one to turn on an axis while the other turns on another axis. If i do this

            dxClass.dxDevice.Transform.World = Matrix.Translation(-40, 0, 0)
            dxMesh1.RenderMesh()

            dxClass.dxDevice.Transform.World = Matrix.Translation(40, 0, 0)
            dxMesh2.RenderMesh()


Then they both render at different points as i expected. However, if i try this...
'New Line Here!
            dxClass.dxDevice.Transform.World = Matrix.Multiply(dxClass.dxDevice.Transform.World, Matrix.RotationYawPitchRoll(Math.PI / 10000, Math.PI / 10000, Math.PI / 10000))
            dxClass.dxDevice.Transform.World = Matrix.Translation(-40, 0, 0)
            dxMesh1.RenderMesh()

            dxClass.dxDevice.Transform.World = Matrix.Translation(40, 0, 0)
            dxMesh2.RenderMesh()
The first Mesh doesn't Rotate at all, it just sits there. Now, im sure it does that due to the Translation of me playing it a x:-40, however, how am i supposed to place an object off-center and get it rotating, there obviously has to be a way. I'm not asking for direct code, as that way i wouldn't learn as well, but if possible pointers to the right pages etc. Cheers, Dean

Share this post


Link to post
Share on other sites
Advertisement
Uhh... PI/10000 is going to give you a really small number. I'm guessing it is rotating, just not by a discernable amount.

Share this post


Link to post
Share on other sites
I'd assume then that your RawPitchRoll transform is being undone (overwritten) by the translation. Try multiplying in the translation matrix instead of just setting it.

Share this post


Link to post
Share on other sites
Okay,
so i tried this



dxClass.dxDevice.Transform.World = Matrix.Multiply(dxClass.dxDevice.Transform.World, Matrix.RotationYawPitchRoll(Math.PI / 10000, Math.PI / 10000, Math.PI / 10000))
dxClass.dxDevice.Transform.World = Matrix.Multiply(dxClass.dxDevice.Transform.World, Matrix.Translation(-10, 0, 0))
dxMesh1.RenderMesh()




And, i suppose as you would expect, it flies off the screen, as the X value is being multiplied every time it renders...

Cheers though mate...

Dean

Share this post


Link to post
Share on other sites
You are overwriting the world matrix every time you set the translation. Try to instead multiply the rotaion matrix by the translation (rotate on the left). That will rotate and translate the mesh every frame.

Share this post


Link to post
Share on other sites
Hi

so i tried this.



dxClass.dxDevice.Transform.World = Matrix.Multiply(Matrix.RotationX(100), Matrix.Translation(-10, 0, 0))
dxMesh1.RenderMesh()



And it's very nearly there, it just set's the rotation the same every time, i chose 100, and it just sits there, which i guess is fair enough.

I assume i neeed to use a variable that i increment every loop?

Cheers,

Dean

Share this post


Link to post
Share on other sites
Its flying off the screen because each pass is cumulative - you'll need to undo the changes you've made to the matrix otherwise they'll keep adding up.

I'm no MDX guru (go unmanaged!) but I'm guessing the call is

Matrix.Identity();

or something similar.

Share this post


Link to post
Share on other sites
Calling

Matrix.Identity to the World just stops ALL rotation, so either im not using it right ( which is probably the case ) or it's not doing what we expect it to do.

And btw, i do intend to move it over to C++ in the end, i only use VB at work, i'm a C++ Programmer outside of work :)

Cheers,

Dean

Share this post


Link to post
Share on other sites
arrr!


dxClass.dxDevice.Transform.World = Matrix.Identity()
dxClass.dxDevice.Transform.World = Matrix.Multiply(Matrix.RotationX(100), Matrix.Translation(-10, 0, 0))
dxMesh1.RenderMesh()


^ does that work?

MDX in C++ is, essentially the same as in VB, minus all the language differences [wink] its the same library afaik

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!