| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
| Rotational calculations; Math related (and I suck at Math) | |
|---|---|
| Tweet Topic Started: Sep 18 2007, 09:49 PM (246 Views) | |
| Matrix_Square | Sep 18 2007, 09:49 PM Post #1 |
![]()
Matrix Square Entertainment Developer
![]() ![]() ![]() ![]() ![]() ![]()
|
Basically, there's an airplane sequence in my game that the player gets to control the plane. Pressing up and down will change the rotx so that the plane tilts up and down. Pressing left and right will "roll" the plane, and theoretically, pressing up and down will rotate the plane on its NEW x axis, whichever way the plane is now facing after the roll. However, in U3D, the axes are static, and rotx will always be horizontal regardless of the model's orientation... Basically, how can I figure out the NEW rotx the model needs to rotate in order to rotate properly on the new x-axis after a roll of "z" amount of degrees? (This should be pretty easy to accomplish for those of you that are math geniuses XD... Or at least have a good understanding of trig). If you don't know what I'm talking about, download this ZIP file (and you can download it if you want a Jet model to work with): This Zip File. |
| SPRING time PROGRAMMING - GM & Ultimate3D Tutorials | |
![]() |
|
| MysteriXYZ | Sep 20 2007, 09:19 AM Post #2 |
|
Master Matrix Masher
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
In short, the problem is changing the order of rotations for the jet. The way to solve this is by using matrices (so you can avoid any annoying trig
).What, Matrix_Square not know matrix? That big mystery to MysteriXYZ :D! So what you need to do is set up a matrix JetOrientation that stores the current rotx/y/z of the jet. When you want to rotate the jet, turn that rotation into a temporary matrix LocalRotation. What you want to do, is rotate the jet around its local axes (in object space, not world space). To get the correct result, you need to transform everything you do in local space, to world space. This includes the local rotations. Therefore, you must transform LocalRotation with JetOrientation and put the result back into JetOrientation, so that it is updated with the new local rotation. Finally, you can retrieve the new rotx/y/z from JetOrientation. In code: In Create Event of jet:
In Key Press Event of jet:
The variables RotIncrX/Y/Z represent the angle incrementation of the local rotations. In Destroy Event of jet:
If this code doesn't correctly execute, you can execute me :P. I just typed this off the top of my head, so there may be some mistakes ^_^. |
| U3D is like candy; after extensive consumption, it's Best to brush. | |
![]() |
|
| « Previous Topic · Questions about Ultimate 3D · Next Topic » |






![]](http://z1.ifrm.com/static/1/pip_r.png)



).
2:35 AM Jul 11