| 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: |
| Converting a Vector into a Matrix..?; Converting Long/Latitude into rotx/y/z? | |
|---|---|
| Tweet Topic Started: Oct 4 2008, 03:56 AM (800 Views) | |
| GadgetTR | Oct 4 2008, 03:56 AM Post #1 |
|
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. | |
![]() |
|
| skarik | Oct 4 2008, 04:21 AM Post #2 |
|
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 | |
![]() |
|
| GadgetTR | Oct 4 2008, 04:53 AM Post #3 |
|
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. | |
![]() |
|
| skarik | Oct 4 2008, 04:57 AM Post #4 |
|
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:
Edited by skarik, Oct 4 2008, 04:59 AM.
|
| Blog|EHS | |
![]() |
|
| GadgetTR | Oct 4 2008, 06:16 AM Post #5 |
|
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...? ![]() 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. | |
![]() |
|
| Eansis | Oct 4 2008, 12:52 PM Post #6 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
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=Create 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 )
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
| |
![]() |
|
| MysteriXYZ | Oct 4 2008, 02:08 PM Post #7 |
|
Master Matrix Masher
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Hi GadgetTR, and welcome to the Ultimate 3D community .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. 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 :
|
| U3D is like candy; after extensive consumption, it's Best to brush. | |
![]() |
|
| Eansis | Oct 4 2008, 02:21 PM Post #8 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I would never try to create a rotation matrix from normal vectors until now
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
| |
![]() |
|
| MysteriXYZ | Oct 4 2008, 02:51 PM Post #9 |
|
Master Matrix Masher
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Yes, it all looks more consistent now XD . |
| U3D is like candy; after extensive consumption, it's Best to brush. | |
![]() |
|
| Eansis | Oct 4 2008, 03:07 PM Post #10 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Thanks for the save
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
| |
![]() |
|
| GadgetTR | Oct 4 2008, 08:52 PM Post #11 |
|
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. ![]() 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. | |
![]() |
|
| « Previous Topic · Questions about Ultimate 3D · Next Topic » |





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




)
.
. For instance, I would never try to retrieve rotation angles from a translation matrix, which by definition doesn't contain any rotation info 
2:48 AM Jul 11