Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Bobboau on November 11, 2006, 06:55:34 am

Title: off axis rotation (turrets in particular)
Post by: Bobboau on November 11, 2006, 06:55:34 am
[edit]now that I'm not asleep I changed the title to make it a bit more noticeable.[/edit]

been up all night working on this damned little thing, would have been easy if the stupid matrix functions would have been precise enough to have it not require implementation on a low level,but here I am, got it working, at least to the proof of concept stage.

anyway, did some work on the turret code you all will like, here (http://freespace.volitionwatch.com/blackwater/fs2_open_Bobboau_11-11-06.zip) is the executable, and here (http://freespace.volitionwatch.com/blackwater/turret_test.zip) is the test data you can use to test it or figure out how to set the stuff up.

going to sleep now.
Title: Re: delerius tired
Post by: Woolie Wool on November 11, 2006, 09:54:46 am
Great...

What is it?
Title: Re: delerius tired
Post by: Flipside on November 11, 2006, 09:57:28 am
If this is what I think it is, Bobb is my favourite person ever!

< Goes to re-install FS2 after his Hard Drive crash > ......
Title: Re: delerius tired
Post by: karajorma on November 11, 2006, 10:10:03 am
Opens data in modelview.
 :jaw:
Title: Re: delerius tired
Post by: Woolie Wool on November 11, 2006, 10:26:47 am
Ugh, use a less irritating debug build. I don't want to change stupid bull**** things normal builds never notice just to make the damn thing run.
Title: Re: delerius tired
Post by: karajorma on November 11, 2006, 10:39:13 am
The build works without giving me a single debug error. I suggest you clean up your FS2 folder rather than trying to blame Bob's build. Those errors you consider unimportant are probably causing mysterious crashes.

Title: Re: delerius tired
Post by: Shade on November 11, 2006, 10:52:54 am
Not to mention one of the reasons for debug builds is that they ***** about things that might cause problems, even if they are minor. As Kara said, the solution is to fix the problems and not to complain about the build pointing them out for you.
Title: Re: delerius tired
Post by: Bobboau on November 11, 2006, 12:27:42 pm
the main reason I uploaded a debug build is because I didn't want to spend the time compiling a release build, when I could be sleeping, wich I would still be doing if someone in the other room hadn't decided was a good time to clank a bunch of plates together... :doubt:.
so it is working for every one? turrets moving the way you'd want them too and all that.
I didn't actually test the tbm, just assumed I did everything right making the mod package.
I should note that the way I coded this 'should' allow the same thing with rotateing submodels.
Title: Re: delerius tired
Post by: karajorma on November 11, 2006, 12:31:21 pm
You're asking people to bug test. They should run a debug build anyway :)
Title: Re: delerius tired
Post by: Bobboau on November 11, 2006, 12:40:19 pm
true, but I was mostly doing this just to let people know I was working on this.

and it does work for you?
Title: Re: delerius tired
Post by: karajorma on November 11, 2006, 01:39:49 pm
I'd have said something if it didn't :)

So far I've had no issues with it. Did you bump the number of multiparts too BTW? Cause you know people are going to start demanding that next :p
Title: Re: delerius tired
Post by: Bobboau on November 11, 2006, 01:57:12 pm
if it becomes an issue I might, or I might make that dynamic.
Title: Re: off axis rotation (turrets in particular)
Post by: Nuke on November 11, 2006, 06:24:27 pm
very nice, now explain:

$uvec: 0,1,1
$fvec: 0,0,1
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 11, 2006, 07:26:35 pm
up vector and forward vector, the more important of the two is the up vector, in general it should be coliniar to the turret normal, it is the axis of rotation for the base of the turret (I have code that normalises it so you just have to give a vector of the right direction). the fvec points in the direction of the front  of the turret, you don't have to be as precise with this one, all you need is to get it generaly pointing in the right direction and the underlieing code will figure out what the proper fvec should be (it will basicly project what you give onto the plane formed by the uvec)

now those two values you were asking about say that the up vector points up and forward equaly (the true in game value would be something like [0,0.707...,0.707...]) and the fvec is more or less directly forward (this will be translated internaly to be something like [0,-0.707...,0.707...]).

there is also a third vector involved that you do not have direct controle over called the rvec (right vector) generaly you will not need to cocern yourself with it, unless you have a turret that has an off center fireing arch (like the turrets that are partaly tilted forward or backward) in wich case you need to make sure that the two models have the same rvec, the rvec is formed from the crossproduct of the u and f vecs (so in other words that the uvec and fvec of both the base and arms are coplanar).
based on what you provide in the two vectors the code will construct three vectors that are completely orthoginal to each other (so you don't have to, you only need to get the uvec completely right and even then you only need to worry about direction)

in most cases you will have turrets that are just angled around one of the principal axes so once you have your uvec, you just give a fvec in the general direction (along one of the principal axes). knowing a bit about vector math helps, but you'll get the hang of it quick. don't be fearfull of words like 'crossproduct' or 'orthoginal'
Title: Re: off axis rotation (turrets in particular)
Post by: Nuke on November 11, 2006, 09:45:58 pm
up vector and forward vector, the more important of the two is the up vector, in general it should be coliniar to the turret normal, it is the axis of rotation for the base of the turret (I have code that normalises it so you just have to give a vector of the right direction). the fvec points in the direction of the front  of the turret, you don't have to be as precise with this one, all you need is to get it generaly pointing in the right direction and the underlieing code will figure out what the proper fvec should be (it will basicly project what you give onto the plane formed by the uvec)

now those two values you were asking about say that the up vector points up and forward equaly (the true in game value would be something like [0,0.707...,0.707...]) and the fvec is more or less directly forward (this will be translated internaly to be something like [0,-0.707...,0.707...]).

there is also a third vector involved that you do not have direct controle over called the rvec (right vector) generaly you will not need to cocern yourself with it, unless you have a turret that has an off center fireing arch (like the turrets that are partaly tilted forward or backward) in wich case you need to make sure that the two models have the same rvec, the rvec is formed from the crossproduct of the u and f vecs (so in other words that the uvec and fvec of both the base and arms are coplanar).
based on what you provide in the two vectors the code will construct three vectors that are completely orthoginal to each other (so you don't have to, you only need to get the uvec completely right and even then you only need to worry about direction)

in most cases you will have turrets that are just angled around one of the principal axes so once you have your uvec, you just give a fvec in the general direction (along one of the principal axes). knowing a bit about vector math helps, but you'll get the hang of it quick. don't be fearfull of words like 'crossproduct' or 'orthoginal'

ive been learning a small bit about vector operations from doing scripting reading articles on normal mapping, ect. so pretty much everything you said makes sence to me. seems pretty straignt forward. now the question is whats left do do with it it? seems pretty complete if you ask me.
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 11, 2006, 09:55:58 pm
it might be done, but I doubt I'm that lucky. I had to add in a matrix, which I have to manually add in before normal orientation operations, because the subobjects don't use a matrix, they use a combination of angles, so every bit of code that has to do with subobjects rotating is potentially broken in a not-so-obvious way.

I guess trying it with a rotating subobject (like radar dishes) hasn't been tested yet, and should theoretically work, same with animations.
Title: Re: off axis rotation (turrets in particular)
Post by: DaBrain on November 12, 2006, 07:28:15 am
I want the HLP highlights back!

Great work Bob, I'll have something to test your feature soon. ;)
Title: Re: off axis rotation (turrets in particular)
Post by: Trivial Psychic on November 12, 2006, 08:26:44 am
One ship to to test such non-turret rotations could be Inferno's  R1 Gigas.  It has these... things that sit on its "wings" that don't rotate, but they sit at non-upright angles and are submodels, so altering them to rotate via this system would be a good test.
Title: Re: off axis rotation (turrets in particular)
Post by: WMCoolmon on November 12, 2006, 06:49:54 pm
Sweet!

Bet Omni will be happy to hear about this... :p
Title: Re: off axis rotation (turrets in particular)
Post by: Nuke on November 12, 2006, 09:27:35 pm
the new vulture im working on has some animations which could binifit from arbitrary axes, so i can really test the **** out of that whenever i finish the model.
Title: Re: off axis rotation (turrets in particular)
Post by: MetalDestroyer on November 13, 2006, 06:58:43 am
Bookmark this topic.
Title: Re: off axis rotation (turrets in particular)
Post by: Colonol Dekker on November 13, 2006, 07:02:20 am
Forgive the obvious lamen here, But i assume that we will now have side mounted turrets? 
Resulting in mega broadside style death? :) :confused:
Title: Re: off axis rotation (turrets in particular)
Post by: Col. Fishguts on November 13, 2006, 07:31:36 am
As soon as this hits CVS (which might take a while), yes.

Thanks Bob for working on one of the oldest requests ever.
Title: Re: off axis rotation (turrets in particular)
Post by: Colonol Dekker on November 13, 2006, 07:32:20 am
Whoopee, i'll cgheck up on the progress of this when i get back :D  :yes:
Title: Re: off axis rotation (turrets in particular)
Post by: Flipside on November 13, 2006, 11:17:42 am
Heh, I'm going to have to go and relearn vectors again now :D
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 19, 2006, 12:52:04 am
Sweet!!!

Having a problem though.... The actually bolt is coming from the wrong place, no wheres near the actually turret itself.  The firepoint in modelview shows up correctly and the y axis in truespace is showing up pointing forward/outward.
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 19, 2006, 10:06:49 am
what are you sub object properties?
describe the turret in more detail (or post a screen shot)
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 19, 2006, 04:14:00 pm
Ugh not having much success...

Ok if I had a turret with a normal of (-1,0,0) [facing straight out port side]

would the uvec be: -1,0,0 (pointing in the normal's direction) or would it be 0,-1, 0 (pointing straight up)?
and the fvec be: (0,0,-1) (pointing straight forward)
?
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 19, 2006, 04:51:41 pm
well you are defining what is up and forward for the turret so your uvec should be -1,0,0 and the fvec should be 0,0,1 (what you had is backwards).
keep in mind that the turret has to be modeled to look like this before you add this stuff in.
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 19, 2006, 05:06:36 pm
Ok that helps a bit... the turret barrel is tracking the target correctly (or at least it seems) but the firepoint is way off
(http://img.photobucket.com/albums/v356/Shodan_AI/misaim.jpg)



Also would it be possible to lock an axis for the up arrow (like the X) and forward (the Y axis) automatically so you wouldn't need the uvec and fvec?
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 19, 2006, 07:20:57 pm
can you give me that test pof?
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 19, 2006, 07:34:44 pm
Sorry had to leave for a while...

It's probably something stupid I'm doing that works ok in the normal version.
http://www.wcsaga.com/~team/Scooby/Custom_Mod/test_turret.rar (http://www.wcsaga.com/~team/Scooby/Custom_Mod/test_turret.rar)
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 19, 2006, 07:39:47 pm
ok, I think I see what's going on, all my test models used arms that were centered on the bas, this has a rotation point well above it, I guess I've got something to fix then.
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 19, 2006, 07:48:53 pm
huh? it should be centered on the base.... the arm's pivot point is right next to the turret base, and the turret's base should be centered on the base box.

edit: how do i visually check where the pivot points are in modelview?
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 19, 2006, 08:26:34 pm
if you hit the 'rotate parts' button it'll show it. (sometimes)

it's not centered on the base it's centered (from the turret's perspective) above it, in all my test data the base and arms were in the exact same position, so I didn't catch this till just now.

funny thing is I could have sworn I took care of the function were the problem was in, oh, yeah, fixed it.

http://freespace.volitionwatch.com/blackwater/fs2_open_Bobboau_11-19-06.zip
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 19, 2006, 08:44:56 pm
I think you fixed it!   :)

Now I can go back and start thinking about how to side mount my cap ships.  If they're complaining about features being added and not used... this definetely won't be one of them!!!! *bounces up and down happy with joy*
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 19, 2006, 08:47:44 pm
keep in mind this isn't going to be in any official builds until after the next release. so don't do anything that's going to be mission critical with it untill after that.

though with the new branching thing I'll probly get it committed soonish.

and don't forget that you can do more than just side mounting, you can put a turret at prety much any angle you can figure the uvec for
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 19, 2006, 08:51:15 pm
Any idea how soon will that be?

If nothing else I think I can get by by using a "fake"  version (i.e. not multi-turret) until then and then just change the turret's arm to the real arm
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 19, 2006, 08:57:30 pm
that could work.
Title: Re: delerius tired
Post by: Raptor on November 23, 2006, 06:27:13 am
Not to mention one of the reasons for debug builds is that they ***** about things that might cause problems, even if they are minor. As Kara said, the solution is to fix the problems and not to complain about the build pointing them out for you.

Except when you are given no clue as to what the problem is.

Only just got round to trying this... but the build just quits on me.  I just get Windows' 'this program has performed an illegal operation and will be shu down.  Sorry for the inconvinence.' message. :hopping:

the 29th August 3_6_9 build runs fine for me, but any debuild just gives me that ^.

I'll try ripping out all my mod tables and try again...  :sigh:

EDIT: Nope, still didn't work.

EDIT2: BTW, I was trying the build in the first post, if that makes any differance.
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 23, 2006, 12:13:34 pm
all debug builds cause this problem (not just mine)?
Title: Re: off axis rotation (turrets in particular)
Post by: Raptor on November 23, 2006, 12:47:05 pm
All the one's I've tried.
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 26, 2006, 10:44:50 pm
Well this feature is already being put to use....  :D

(http://img.photobucket.com/albums/v356/Shodan_AI/rak-1.jpg)
(http://img.photobucket.com/albums/v356/Shodan_AI/rak-9.jpg)

I just need to get out of the top/bottom turret mindset...
Title: Re: off axis rotation (turrets in particular)
Post by: Taristin on November 26, 2006, 10:49:18 pm
How about some in action pics? :p
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on November 26, 2006, 11:27:33 pm
Well I tried... just that the turrets use fast blob weapons, so they don't show off very well, that plus the fact i can't hit the print screen fast enough  :P

Btw, bob could we get a release version of this?  Nothing like having to hit "n" a couple million times because it's complaining about depresiated flags (probably the no damage from subsytem to parent entry).

Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on November 27, 2006, 03:10:56 am
yeah, someone made a syntax change, honestly it's a lot cleaner, rather than put +non-targetable +no damage
on diferent lines you put it in $flags:("non targetable" "no damage")
like ship flags.

...anyway nice work so far but don't limet yourself to just putting them on the sides, you could put them on those slanty bits too.
Title: Re: off axis rotation (turrets in particular)
Post by: TrashMan on December 04, 2006, 06:23:50 am
Bob, if you were a woman, I would marry you! :D

THANK YOU FOR THIS!!!!!
Title: Re: off axis rotation (turrets in particular)
Post by: Omniscaper on December 04, 2006, 04:06:02 pm
Is there still a cap on maximum number of multipart turrets? I'd like to try this code with Galactica's 175 AAA turrets.
Title: Re: off axis rotation (turrets in particular)
Post by: Scooby_Doo on December 04, 2006, 05:02:07 pm
I think thats part of PCS's problem too Omniscaper.
Title: Re: off axis rotation (turrets in particular)
Post by: Nuke on December 05, 2006, 03:48:54 am
yeah, someone made a syntax change, honestly it's a lot cleaner, rather than put +non-targetable +no damage
on diferent lines you put it in $flags:("non targetable" "no damage")
like ship flags.

...anyway nice work so far but don't limet yourself to just putting them on the sides, you could put them on those slanty bits too.

or you can use something like the turret i posted on the recent builds thread. i also have a couple more ideas to try, just havent modeled up the tests yet.

is it just be or does there seem to be some collision detection issues. seems like some of the shots are passing through the base or barrel models, or their explosions and other effects arent being rendered.
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on December 05, 2006, 01:19:26 pm
I have been worried about colision detection problems this whole time, and is principly why I haven't commited this yet, problem is when I explicitly try to shoot at a turret it seems to hit.
Title: Re: off axis rotation (turrets in particular)
Post by: Nuke on December 06, 2006, 02:45:36 am
i figure its just a matter to make the collision trees rotate with the models. i think its just a matter of their range of motion being limited to a fixed range. of course i havent looked at the code and im really talking out of my ass.
Title: Re: off axis rotation (turrets in particular)
Post by: Bobboau on December 06, 2006, 05:31:27 am
you've got it sort of backwards, the point's being collided with get rotated into the object's normal rest position, I inserted the optional axis into the code in the same way it got inserted every were else so it should be working, but things might be diferent.
Title: Re: off axis rotation (turrets in particular)
Post by: Nuke on December 07, 2006, 08:51:55 pm
well im glad i got it bass akwards, rather than completely wrong :D

but that makes sence, why rotate something as vast as a collision tree when you simply just need to rotate a couple of shots.