Welcome Guest [Log In] [Register]
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:

Username:   Password:
Add Reply
Converting a Vector into a Matrix..?; Converting Long/Latitude into rotx/y/z?
Topic Started: Oct 4 2008, 03:56 AM (800 Views)
GadgetTR
Member Avatar
The One and Only
[ * ]
As much as I hate to just join a forum and ask questions...


Well, I'll cut to the chase. Basically I need a way to convert a Vector and/or a Longitude-Latitude direction into rotx and rotz (roty being the offset). Pointing up would mean no rotation etc.

I'm trying to use the Ray Tracing Normal of the ground below the character to adjust the character's rotation accordingly (when I said "roty being the offset" I meant the direction that the character was facing).

Maybe there was a something in the manual that I overlooked, but I've been pulling my hair out over it for a while now.
~GadgetTR - Formerly known as Shadow Blade in other places, such as the GMC.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
rotx = CalculateVectorLongitude(vector_id);
roty = CalculateVectorLatitude(vector_id);

Rotz is not exactly doable with vectors (since it's just a line).
Blog|EHS
Offline Profile Quote Post Goto Top
 
GadgetTR
Member Avatar
The One and Only
[ * ]
Um, sorry. That didn't help me much. I already know how to get Longitude & Latitude between two points. What I need to know is how to change a Long-Latitude direction into a rotation. Basically I need to be able to align an object's "Y-Pole" (an imaginary pole going from feet to head) to a a given Longitude-Latitude direction.
Edited by GadgetTR, Oct 4 2008, 04:54 AM.
~GadgetTR - Formerly known as Shadow Blade in other places, such as the GMC.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Ahh, well...there's a few topics about this. Let me see if I can dig one up.

Edit:
Okay, there's a lot and I'm not the person to tell which does which axis. However, I'm guessing you could manually put the rotation into a rotation matrix in your order. Example:
Code:
 

matrix_position = CreateTranslationMatrix(-1,x,y,z);
matrix_scaling = CreateScalingMatrix(-1,scalx,scaly,scalz);

matrix_rotx = CreateRotationMatrix(-1,rotx,0,0);
matrix_roty = CreateRotationMatrix(-1,0,roty,0);
matrix_rotz = CreateRotationMatrix(-1,0,0,rotz);

TransformMatrix(matrix_rotx,matrix_rotx,matrix_rotz);
TransformMatrix(matrix_rotx,matrix_rotx,matrix_roty);
TransformMatrix(matrix_scaling,matrix_rotx,matrix_scaling);
TransformMatrix(matrix_position,matrix_rotx,matrix_position);

CopyMatrix(GetObjectTransformation(id),matrix_position);

ReleaseMatrix(matrix_position);
ReleaseMatrix(matrix_scaling);
ReleaseMatrix(matrix_rotx);
ReleaseMatrix(matrix_roty);
ReleaseMatrix(matrix_rotz);
Edited by skarik, Oct 4 2008, 04:59 AM.
Blog|EHS
Offline Profile Quote Post Goto Top
 
GadgetTR
Member Avatar
The One and Only
[ * ]
I understand matrices pretty good, but I'll be honest with you... That script doesn't make much sense to me at all. >< Wh.. where do you input the Long/Latitude...? :huh:

In case, for whatever reason, my previous two posts weren't clear enough, I'm going for a Sonic Adventure-style wall/slope-standing/running/what-have-you. Where, when you're on a slope/wall, you're tilted in the direction returned by the RayTracingNormal() script, but still facing in whatever direction you'd be facing normally (which means that roty probably shouldn't chage).


So, um. Yeah.
~GadgetTR - Formerly known as Shadow Blade in other places, such as the GMC.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
GadgetTR
Oct 4 2008, 06:16 AM
I understand matrices pretty good, but I'll be honest with you... That script doesn't make much sense to me at all. >< Wh.. where do you input the Long/Latitude...? :huh:

In case, for whatever reason, my previous two posts weren't clear enough, I'm going for a Sonic Adventure-style wall/slope-standing/running/what-have-you. Where, when you're on a slope/wall, you're tilted in the direction returned by the RayTracingNormal() script, but still facing in whatever direction you'd be facing normally (which means that roty probably shouldn't change).
Well, you would have to create a Transformation Matrix and use ray-tracing to retrieve the normal of the plane you are on. It would look something like this:

dist=GetDistanceToModel(level,x,y,z+height/2,rotx+PlusOrMinus+90,roty) (The origin of the player model should be at it's head, with a dynamic offset of height/2)

if dist<height/1.99
{

nor=GetRayTracingNormal()
//nor is a vector describing the normal of the plane you are (hopefully) standing on
Tilt=CreateTranslationRotationMatrix(-1,GetVector(nor,1),GetVector(nor,2),GetVector(nor,3))
TiltRot=ComputeMatrixRotationAngles(-1,Tilt)
//now nor is converted into euler angles//
Rot=CreateRotationMatrix(-1,rotx0,roty0,rotz0)
//our current meta-variables rotx0 and roty0 is transformed into the real rotx and roty
NewRot=TransformMatrix(-1,Rot,Tilt)
FinalRot=ComputeMatrixRotationAngles(-1,NewRot)
rotx=GetVector(FinalRot,1)
roty=GetVector(FinalRot,2)
rotz=GetVector(FinalRot,3)

}
else
rotx=rotx0
roty=roty0
rotz=rotz0

/movement//
if "event"
Move(rotx,roty,1)

Note to self: (if it doesn't work blame MysteriXYZ :D )
Edited by Eansis, Oct 4 2008, 02:26 PM.
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Hi GadgetTR, and welcome to the Ultimate 3D community :) .

GadgetTR
Oct 4 2008, 06:16 AM
I'm going for a Sonic Adventure-style wall/slope-standing/running/what-have-you. Where, when you're on a slope/wall, you're tilted in the direction returned by the RayTracingNormal() script, but still facing in whatever direction you'd be facing normally (which means that roty probably shouldn't chage).
Please check out my Follow Surface Examples and see if they provide the solution you are looking for. There are 2 of them, a third-person ("FollowSurface_Example_GM6.gm6") and a first person example ("FollowSurface_FPS_Example_GM6.gm6").

The way I managed to keep the character aligned to the surface is quite complicated (I added many comments to make it as clear as I could) and please realize that your character may get stuck at places where the "ground" makes a sharp angle downwards, like at the edge of a pit etc.
Anyway, I hope these examples will be of use to you.

Eanbro
 
if it doesn't work blame MysteriXYZ :D
I am in no way responsible for the way your mind works ;) . For instance, I would never try to retrieve rotation angles from a translation matrix, which by definition doesn't contain any rotation info :D :
Code:
 
Tilt=CreateTranslationMatrix(-1,GetVector(nor,1),GetVector(nor,2),GetVector(nor,3))
TiltRot=ComputeMatrixRotationAngles(-1,Tilt)
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
I would never try to create a rotation matrix from normal vectors until now :D
Edited by Eansis, Oct 4 2008, 02:27 PM.
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Eanbro
Oct 4 2008, 02:21 PM
I would never try to create a rotation matrix from normal vectors until now :D
Yes, it all looks more consistent now XD .
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
Thanks for the save :D
Edited by Eansis, Oct 4 2008, 03:07 PM.
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
GadgetTR
Member Avatar
The One and Only
[ * ]
Thanks for helping, everyone. But, until I'm able to comprehend the help (><), I found kind of a "cheat" way of doing it. Basically I turn the model on its "belly" (or just do SetBoneRotation(root_bone,-90,0,0), which is what I did), then I made rotx equal the longitude and roty equal the latitude. This way, I'm able to point it's "head" in any direction, and just use rotz to change the facing direction. :yahoo:

Well, anyway, thanks for the help. I'll try not to just disappear like I do on some forums after I register. :X
~GadgetTR - Formerly known as Shadow Blade in other places, such as the GMC.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply