Hard Light Productions Forums
Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Scooby_Doo on April 04, 2008, 05:07:50 pm
-
Could someone please write a simple program that you can enter the 3 axises and it'll spit out the forward and up vectors? Or at least the formula for it. I still can't get my brain wrapped around it :confused:
-
I'm not sure what you're talking about, but I did write a little app a long time ago for calculating the rotation matrix to use in missions if you wanted a ship oriented with a specific heading, pitch and roll (instead of using "point to" or manual rotation in fred).
Are you trying to calculate the relative vector (target is (x, y, z) units away from a point)?
-
Normal vectors can be confusing at first. What you have to know is that a normal vector is specifying a relative point. The three axes are the X (left-right), Y (up-down), and Z (forward-back) in that order. So if you have a turret on the left side of a ship, facing forward, its forward vector should be 0,0,1 (a point one unit forward), and its up vector should be 1,0,0 (or maybe its -1,0,0), specifying a point one unit to the left.
-
Is it that hard to stick a few numbers into the box in PCS2 and see which way the stick points? :P
-
Depends on the level of control you want. :P
It's why I wrote my little app, so I can set up a bunch of RBCs or something and have them all pointing exactly where I want.
-
I can do top, bottom, left right facing with no major problems, but when you start getting into odd degrees I have no idea how to compute.
-
When you get into odd angles (other than 45% which is easy), then you need to use trigonometry to get it. This can be complicated.
-
What numbers/values do you actuall have? Exactly what values are you trying to calculate?
Is this what you're looking for?
http://en.wikipedia.org/wiki/Spherical_coordinates#Cartesian_coordinate_system
2 angle input, your r is always 1 for the turret normals anyway.
-
OK. I made a diagram that shows what you need to do. Should be doable on any scientific calculator (I would be surprised if your computer didn't have one built in). MAKE SURE IT IS IN DEGREE MODE FIRST, otherwise it will think you are using radians. You should be able to use this to generate a vector (just imagine the hypotenuse as the vector you want).
[attachment deleted by ninja]
-
I think I had something like that but something's messed up.
I've got a turret set at 150,0,90 (truespace angle)
150 is -30 from straight down left. (flipped vert it's 30)
sin (30) = .5
cos (30) = .866
$uvec:-.866, -.5, 0
$fvec:0,0,1
The turret rotates in the wrong angle, and the barrel tries to ain backwards. Ugh
-
You could try flipping -0.866 to +0.866. It might not help, but I find I always forget which direction along the X axis is positive. Could also be that the code is just messed up.
-
I think I had something like that but something's messed up.
I've got a turret set at 150,0,90 (truespace angle)
150 is -30 from straight down left. (flipped vert it's 30)
sin (30) = .5
cos (30) = .866
$uvec:-.866, -.5, 0
$fvec:0,0,1
The turret rotates in the wrong angle, and the barrel tries to ain backwards. Ugh
I've never done anything with vectoring, so I could be completely wrong, but shouldn't -.5 be a Z value?
try:
$uvec: 0.5, 0, -.866
$fvec: 0, 0, 1
-
Just a suggestion if you are not into trigonometry... Take the model you have and open it in truespace. Use the TS 'sweep' thing IIRC (havent got TS installed here ATM) on the surface where you planning to place the turret on after checking that sweep has been set to 0,0,1. Then choose one of the vertexes on the new poly and copy its stats somewhere (coordinates). Then choose the corresponding vertex on the old poly and do the same. Do subtraction. Got nice set of coordinates. Only problem is figuring out which one points where when the model is converted.
If you are into trigonometry then solving these shouldn't be that difficult without any fooling with the models.
EDIT.. should be worth noting that XYZ in TS are not the same as in FS. By very brief look now that i installed it again.. TS XYZ -> FS ZXY if i am not mistaken
-
If you want to visualise it, fvecs and uvecs are like two gunpoints pointing out the front and top of your turret respectively.
Just make a tempoary gunpoint, switch to wireframe and drag it into the centre of the base of your turret. Go to front or side or wherever orthogonal views of your model and enter numbers in the normal for that point. Use largeish numbers so you turn the firepoint into an axis line. Fiddle with the numbers until you get an axis line that is as accurate as you want it, then 'Normalise' the point so it uses nice small numbers again. This becomes your uvec.
The fvec I suspect may have a bug in it where it actually needs to point backwards. Just point it along the same direction the turret is facing and find out if the arms rotate correctly. If not, try reversing it.
It's all very easy though. You really don't need this stuff to be pinpoint precise. ;)
-
Ok this is strange,
I moved the turret back to 0,0,0 and rotated it back up normal. I added two small boxes, one add (0,0,0) and one at (0,0,1). I then rotated it back to 150, the second box does show (0,.5,-.866). So that parts correct.
Now if I go into pcs2 and use (.5, 0, .866) in any positive/negative combination it doesn't make any difference, the turret is still rotating the wrong way. :confused:
-
Just had a thought. It seems weird, because I would have though that someone would think of it already, but it might work. Try:
$uvec=-0.5,-0.866,0
I think you have the X and Y axis flipped (its complicated). Just try it.
EDIT: I had if flipped too.
-
I have said before that I am ignorant, when it comes to vectors, and I'll say that again.
This might help people who know more:
150 is not (or should not be) 30 degrees, it should be 60 and should be in the second quadrant instead of the third. Hope that helps with your calculations.
-
I have said before that I am ignorant, when it comes to vectors, and I'll say that again.
This might help people who know more:
150 is not (or should not be) 30 degrees, it should be 60 and should be in the second quadrant instead of the third. Hope that helps with your calculations.
That's what I was thinking in my last post. Flipping the X and Y are definitely worth a try (since 60 and 30 are essentially opposites in a right triangle).
-
Correct it would be 60 degrees from top in the second quad and 30 degrees from the bottom in the second quad. But using the two squares method is easier, no calcuations need to be done :)
-
I have said before that I am ignorant, when it comes to vectors, and I'll say that again.
This might help people who know more:
150 is not (or should not be) 30 degrees, it should be 60 and should be in the second quadrant instead of the third. Hope that helps with your calculations.
That's what I was thinking in my last post. Flipping the X and Y are definitely worth a try (since 60 and 30 are essentially opposites in a right triangle).
I think I'm correct assuming I have a point A one unit above the origin(0,0,1), I then rotate it delta degrees (150), point A will be .5 unit to the left and .866 units down from the origin. These two numbers would be the unit vector, since A should still be one unit away from the origin.
-
I have said before that I am ignorant, when it comes to vectors, and I'll say that again.
This might help people who know more:
150 is not (or should not be) 30 degrees, it should be 60 and should be in the second quadrant instead of the third. Hope that helps with your calculations.
That's what I was thinking in my last post. Flipping the X and Y are definitely worth a try (since 60 and 30 are essentially opposites in a right triangle).
That's been bugging me. Could someone explain to me how you could get a Y value other than 0 or 1, using sine and cosine for something with the coordinates 150, 0, 90?
-
I tried something, I made a eye point and made it's normal (.5, -.866,0) and its pointing in the correct direction..
-
So try that on the turret. If it works, the problem solved. If not, either there's something glaring obvious that we're all missing, or there's an error in the code.
-
So try that on the turret. If it works, the problem solved. If not, either there's something glaring obvious that we're all missing, or there's an error in the code.
Already tried that, didn't help. Even negated the numbers.
-
did they fix multi axis turrets?
oh yea, an excerpts from my matrix class:
mat(double x, double y, double z) //convert eulers to matrix
{
double a,b,c,d,e,f,g,h; //stick our pre-comps into an array //this comment doesn't make any sense!
a = cos(x); b = sin(x);
c = cos(y); d = sin(y);
e = cos(z); f = sin(z);
g = a * d; h = b * d;
c0 = c * e; c1 = -c * f; c2 = d;
c3 = h * e + a * f; c4 = -h * f + a * e; c5 = -b *c;
c6 = -g * e + b * f; c7 = g * f + b * e; c8 = a * c;
}
and
vec operator * (vec &v) //apply to vector
{
return vec(c0 * v.x + c1 * v.y + c2 * v.z,
c3 * v.x + c4 * v.y + c5 * v.z,
c6 * v.x + c7 * v.y + c8 * v.z);
}
give the first function your angles of rotation , i think its in pitch, yaw, roll order. do the math and this will create a 3*3 matrix that represents the full orientation of the object. come up with a vector pointed to 0'0'1 (i think), and do the math in the second function on it (along with the components of the 0'0'1 vector, so v.x and v.y = 0 and v.z = 1). your rotated vector's x'y'z will be the first line, the second and the third respectively. theres other math to gen the side and up vectors, but i dont know it.
-
Ok does mat (x,y,z) produce the up vector in matrix format?
-
yea. you need a matrix to do the vector transform.
the matrix has 9 fields c0-c8, it stores an orientation, but you have to multiply it by a vector. the resulting vector would be of the same magnitude but rotated by the angles you created the matrix from. just remember that it rotates around 0'0'0, so a translate,rotate,untranslate may be necessary if your center isn't zero. another thing is that all input angles are in radians so be sure the calculator is set to the radians mode.
-
did they fix multi axis turrets?
Yes. Problem is nobody knows how to use them yet :p
-
Make sure you try both PCS2 AND PCS1
-
I'm gonna interject here with a couple of questions. This is a 2 part turret? If so, is the beam firing from the wrong place? if not, is the turret arm lifting away from the turret body?
... in other words, could you post a screenshot of what's happening?
-
I'm gonna interject here with a couple of questions. This is a 2 part turret? If so, is the beam firing from the wrong place? if not, is the turret arm lifting away from the turret body?
From what I can tell, it is a multipart turret. Where did you get that beam thing from though? The problem seems to be that the turret is rotating around the wrong axis.
EDIT: Oh, and...
:welcomegreen:
-
Thanks :)
And the beam thing I ask because when I was learning multipart turrets I was having a barrel rotate out of the base of the turret... turned out I'd set the axes of the barrel wrong, so the barrel was rotating around the center instead of at one end. Kind of sounded like maybe the same thing was happening here.
-
Thanks :)
And the beam thing I ask because when I was learning multipart turrets I was having a barrel rotate out of the base of the turret... turned out I'd set the axes of the barrel wrong, so the barrel was rotating around the center instead of at one end. Kind of sounded like maybe the same thing was happening here.
I've had that problem too, but that's not what's going on here. What is happening here is that Scooby_Doo is trying to use a new feature which allows multipart turrets to be placed not just on the top and bottom of the ship, but also on the sided and at weird angles on the hull. When you do this, however, you have to specify the axis along which it rotates, and this can be *difficult* to calculate sometimes.
-
ohhhhh my mistake. But, where's this feature documented? I wanna play with it!