Deploying,Geting right rotation?
by kc_0045 · in Torque Game Engine · 02/14/2004 (12:12 pm) · 4 replies
Hello, im adding deployables to my game but im having some problems :(. heres the code im useing to get the pos your looking at.
now that works fine but i need it so you can deploy on to StaticShape with the right rotation....any one have any idea on how i choud do this? any ideas? plz post.
%pos = %obj.getMuzzlePoint(%slot); %vec = %obj.getMuzzleVector(%slot); %res = containerRayCast(%pos,vectorAdd(%pos,vectorScale(%vec,2000)), $TypeMasks::PlayerObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::StaticObjectType,%obj); if (%res) %hitLoc = getWords(%res,1,3);
now that works fine but i need it so you can deploy on to StaticShape with the right rotation....any one have any idea on how i choud do this? any ideas? plz post.
About the author
#2
02/14/2004 (8:52 pm)
No no no i mean like if your looking at say a flat wall thats its angle is 90Degres and you want the object to deploy so the bottom is facing that wall how whoud you do that?
#3
02/15/2004 (4:02 am)
Well, thats a little tougher obviously. First off, you'll need to make sure your object deploys it's negative Z axis in the direction you are facing. And you'll have to do a force on the angle. Meaning, you may be looking up at a 45 degree angle, but where your raycast strikes the wall, the deploy will occur at a direct 90 degree's. Keep in mind this could confuse the issue if you are trying to deploy on angled surfaces. For flat and straight up and down, it shouldn't be a problem.
#4
Now my problem is this, my normal to rotation function seems to be 2d only, one axis just stays flat and is causing problems.
a freind suggested I use "Euler type matricies with matrix/vector multiplication" iv tryed searching that, but I cant seem to find anything usfull :S
http://img171.imageshack.us/my.php?image=screenshot00100002vb6.jpg
The bottom 2 poles by the gun is what I'm talking about.
09/09/2006 (10:39 pm)
Well, iv started this project up again now that iv got a better knowledge as to how TGE works, didnt take me long to solve the problem i had before.Now my problem is this, my normal to rotation function seems to be 2d only, one axis just stays flat and is causing problems.
%ray = ContainerRayCast (%startPoint, %endPoint, $DeployableMask, %obj);
%hitobj = getword(%ray,0);
%Surfnorm = getWord(%ray, 4) SPC getWord(%ray, 5) SPC getWord(%ray, 6);
%Surfpos = getWord(%ray, 1) SPC getWord(%ray, 2) SPC getWord(%ray, 3);
%Surfrotation = Normal2Rotation(%Surfnorm);
function Normal2Rotation(%normal)
{
if(getWord(%normal, 2) == 1 || getWord(%normal, 2) == -1)
%rotAxis = vectorNormalize(vectorCross(%normal, "0 1 0"));
else
%rotAxis = vectorNormalize(vectorCross(%normal, "0 0 1"));
%initialAngle = mACos(vectorDot(%normal, "0 0 1"));
%rotation = %rotAxis SPC (%initialAngle);
return %rotation;
}a freind suggested I use "Euler type matricies with matrix/vector multiplication" iv tryed searching that, but I cant seem to find anything usfull :S
http://img171.imageshack.us/my.php?image=screenshot00100002vb6.jpg
The bottom 2 poles by the gun is what I'm talking about.
Torque Owner Gonzo T. Clown