| 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: |
| d3d_transform_add_rotation_axis(rx,ry,rz,angle); Is there a way to emulate this? | |
|---|---|
| Tweet Topic Started: Dec 2 2007, 05:22 PM (874 Views) | |
| Eansis | Dec 2 2007, 05:22 PM Post #1 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Because U3d's "rotx, roty, and rotz" just aint happenin for ball rotation. I need a function lke "transform_add_rotation_axis" because rotx and roty, rotz aren't even consistent with each other. I can't even apply trigonometry to them because it seems roty always rotates relative to the world, rotx relative to itself and rotz relative to the object. |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| gamemakerguy1560 | Dec 2 2007, 05:52 PM Post #2 |
|
Creator of Expedition: Prehistory
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
rotx-z should work as well as the axis in gamemaker, though u believe the y rotation in U3D is 90 degrees lower than that of gamemaker's, so you have to add 90. but it should work right. if they aren't maybe you're doing something wrong. remember that in U3D, you're looking up, not down in the room editor. also the origin of the model depends on the origin in the editor you used to make it. |
![]() My Forums | |
![]() |
|
| Eansis | Dec 3 2007, 05:42 AM Post #3 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Well the problem is roty's axis maintains the same angle (relative to the world) regardless of rotx and rotz, rotx does if sin is trigonometric math is applied to rotx and rotz, and rotz is the only one with proper rotations. That rules out me using an equation/s to calculate the correct rotation angle, if there is a function similar to rotation_axis is U3d I don't have to port my game to d3d, else I will have to port my game to d3d.
|
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| zelda4evr | Dec 4 2007, 07:11 AM Post #4 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
what are you talking about Eanbro ive never experienced this, can you please SHOW us what you mean? |
![]() | |
![]() |
|
| Eansis | Dec 4 2007, 05:39 PM Post #5 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I'm not sure my diagram of axis "rotz" is entirely accurate but here ya go: |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| MysteriXYZ | Dec 5 2007, 12:50 AM Post #6 |
|
Master Matrix Masher
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
So you want to rotate around an arbitrary axis, right? Then you should use matrices. Basically, these are the steps to get it done:
P.S. nice hat on the ball in the lower left corner :lol:! (j/k) |
| U3D is like candy; after extensive consumption, it's Best to brush. | |
![]() |
|
| Eansis | Dec 5 2007, 06:57 PM Post #7 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
So, should this code work?:
PS: Im glad you like the hat
|
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| MysteriXYZ | Dec 5 2007, 08:30 PM Post #8 |
|
Master Matrix Masher
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Okay, I'll explain a bit better ^_^. What it comes down to, is that you still rotate around X-, Y- and Z-axes, no longer in world space, but in local space. So you have to imagine your arbitrary axis to be one of the world X-, Y- or Z-axes, transformed with a rotation matrix. So you end up doing a regular rotation, which itself gets "rotated", so it happens locally, relative to the space in which your arbitrary axis represents one of the X-, Y- or Z-axes. Let's assume you want to do a local rotz, i.e. rotate around an arbitrary axis that represents the Y-axis of some local space. What you need first, is the rotation matrix that describes the orientation of that space, relative to the world (world-to-local-space matrix). Suppose you know the corresponding rotx/y/z of that local space. These could be the rotx/y/z of a certain object that you want to use as reference coordinate system, for example axis_obj. Then your first line of code is:
Then you invert that matrix:
Now you set up a rotation matrix that describes the rotz rotation you want to apply to the object of your choice - for example ball_obj - as you would do it in that local space:
Currently this rotation is destined to be performed in world space, so how do you get it into the local space of axis_obj? By first rotating the inverse of that local space (AxisMatrixInv) with that AngleMatrix, and then putting it back into its rightful place by transforming it with the AxisMatrix itself:
Finally, you can get the new Euler angles of the ball_obj from FinalMatrix:
And Bob may or may not be your uncle . |
| U3D is like candy; after extensive consumption, it's Best to brush. | |
![]() |
|
| Eansis | Dec 5 2007, 11:27 PM Post #9 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Well, it kinda works, except it doesnt return the correct roty. Here is my code: AxisMatrix=CreateRotationMatrix(-1,0,0,0); AxisMatrixInv=InvertMatrix(-1,AxisMatrix); AngleMatrix=CreateRotationMatrix(-1,Addy mod 360,0,-Addx mod 360); ResultMatrix=TransformMatrix(-1,AxisMatrixInv,AngleMatrix); FinalMatrix=TransformMatrix(-1,ResultMatrix,AxisMatrix); BallOrientation=ComputeMatrixRotationAngles(-1,FinalMatrix); rotx=GetVector(BallOrientation,1); roty=GetVector(BallOrientation,2); rotz=GetVector(BallOrientation,3); Addx+=(x-xprevious)*pi Addy+=(y-yprevious)*pi ReleaseMatrix(AxisMatrix); ReleaseMatrix(AxisMatrixInv); ReleaseMatrix(AngleMatrix); ReleaseMatrix(ResultMatrix); ReleaseVector(BallOrientation); |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| MysteriXYZ | Dec 6 2007, 12:55 AM Post #10 |
|
Master Matrix Masher
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
That's probably because the following doesn't really do anything :
Maybe we're on the wrong track here anyway, and I just remembered an old topic about something similar, so you might find this example useful. |
| U3D is like candy; after extensive consumption, it's Best to brush. | |
![]() |
|
| Eansis | Dec 6 2007, 04:24 AM Post #11 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I got it to work using your example! Thankyou very much for helping me!
|
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| « Previous Topic · Questions about Ultimate 3D · Next Topic » |





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





:
9:37 PM Jul 11