Left/Right Vector
by Christian · in Torque Game Engine · 12/16/2007 (12:36 am) · 5 replies
Is there a vector set up in torque for left/right vector?
---#--
# X #
--#--
X = you
# = points around you
need to place them like that knowing which one is left, right, etc so using VectorAdd doesn't work in this case.
the forward and backwards vector I can get, but not sure if there is a command for left and right. Thanks.
-Christian
---#--
# X #
--#--
X = you
# = points around you
need to place them like that knowing which one is left, right, etc so using VectorAdd doesn't work in this case.
the forward and backwards vector I can get, but not sure if there is a command for left and right. Thanks.
-Christian
#2
As to objects transform, yes.
To get my players forward vector/position in front of them I use:
12/16/2007 (3:39 am)
I am doing this in script, but if there is a c++ solution that makes more sense....As to objects transform, yes.
To get my players forward vector/position in front of them I use:
%vector = %caster.getForwardVector(); %forward = VectorNormalize(%vector); %position = VectorScale(%forward, 3);
#3
Try this:
In code I would use:
12/16/2007 (4:02 am)
Good, we have a solid base to start from.Try this:
%right = MatrixMulPoint(%caster.getTransform(), "1 0 0");
In code I would use:
MatrixF mat = myObject->getTransform(); Point3F right; mat.getColumn(0, &right);
#4
another option to doing the matrix multiply is using the cross-product.
the cross-product of two vectors produces a third vector which is perpendicular to both of the originals.
so
note not sure but the above might actually generate %left,
in which case you can get %right by either changing %up to 0 0 -1, or swapping the order of the args to the cross-product.
12/16/2007 (7:16 am)
Just because vectors are awesome,another option to doing the matrix multiply is using the cross-product.
the cross-product of two vectors produces a third vector which is perpendicular to both of the originals.
so
%up = "0 0 1"; %right = vectorCross(%caster.getForwardVector(), %up);
note not sure but the above might actually generate %left,
in which case you can get %right by either changing %up to 0 0 -1, or swapping the order of the args to the cross-product.
#5
It is a 6 sided cube (just basically a die with 6 mount points instead of numbers). When I mount 1 to another, the rotation of the cube will change. So if the left side was previously mount point 2, now it's mount point 4. Just the way the model is set up to line up correctly...So my origional idea was to mount it on all 6 sides and get the distance closest to the side I want and choose that mount point like so:
12/16/2007 (2:19 pm)
Thanks for the replies. I thought that would solve the problem i'd been having, the vectors I believe work fine, but the problem i've been having still remains. Basically I have a bunch of pieces I have to mount together, sort of like legos or a puzzle.It is a 6 sided cube (just basically a die with 6 mount points instead of numbers). When I mount 1 to another, the rotation of the cube will change. So if the left side was previously mount point 2, now it's mount point 4. Just the way the model is set up to line up correctly...So my origional idea was to mount it on all 6 sides and get the distance closest to the side I want and choose that mount point like so:
for (%x = 0; %x < 6; %x++)
{
$b[%to].mountObject($b[%from], %x); //$b[%to] is where what cube it's being mounted to, [%from] = what pieces is being mounted
%dist = VectorDist($b[%from].getPosition(), %where);
if (%dist < %lastdist)
{
%lastdist = %dist;
%point = %x;
}
}Basicaly it is returning all the distances are the same, so i'm assuming that torque cannot mount this fast. Any ideas for a better solution for finding the right mount point for each situation?
Torque Owner Michael Bacon
Default Studio Name
Yes.
Oh yah, the helpful part: Are you doing this in script or in code? What do you have? An objects transform? Please give context.