Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Nuke on September 20, 2007, 01:19:39 am

Title: any chance at gatting the lookat feature back?
Post by: Nuke on September 20, 2007, 01:19:39 am
anyone remember that look at feature for subobjects that was lumped onto bob's turret upgrades? it was for simulating haydraulic pistons and such for animation. im finally able to do some modeling for nukemod again and ive come up with a couple ideas for how to do certain animations which would require that feature. sence it really didnt have anything to do with turrets i was wondering if we could get that feature back into head without screwing anything up?

if this is not possible, id like tosee the code for this feature would be so i can do the same thing in scripting.
Title: Re: any chance at gatting the lookat feature back?
Post by: Bobboau on September 20, 2007, 04:21:24 am
the trick to it was finding object B's position int object A's reference frame, th easiest way to do that would be to get B's position in object space and transform with A's matrix, but I'm not sure if you can get all that in the right way with the scripting system.

my code for this is in CVS history if anyone does want to take a stab, but I'd recommend coming up with an off axis subobject solution first, cause that makes everything more useful.
Title: Re: any chance at gatting the lookat feature back?
Post by: Nuke on September 20, 2007, 05:21:59 am
i should be suffietiently familiar with matrix math by now to figure out how to do that.

i could probibly get b's position and subtract a's pos from it to draw a vactor between the parts, use vector:getOrientation() to give me a matrix and set the orientation for object a to that matrix. this should work with objects on a plane or objects with z axis radial symetry in multiple planes. though im not sure if .position takes into account any displacement caused by the moving of its parent. anyway im probibly gonna have to test the crap out of any scripting concoction i come up with :D
Title: Re: any chance at gatting the lookat feature back?
Post by: WMCoolmon on September 21, 2007, 03:50:59 am
Quote
    lvector Position
        Subsystem position with regards to main ship

So no. It is just the displacement of the subsystem from the center of the ship.

That reminds me that .Position needs to be reworked to work properly. Right now if you change it you actually change the position in the model data, which means that the subsystem position will change for all ships of that type, not just the ship it is applied to. That was supposed to cause problems with the collision code so I never fixed it myself.
Title: Re: any chance at gatting the lookat feature back?
Post by: Nuke on September 21, 2007, 10:22:30 am
in that case is have to (un?)rotate the position data from a (and possibly b as well if its parent moves) by its respective orientation, then i can draw the line from a to b. then id have to set a to its parents rotation matrix * the rotation matrix generated by getting the a-to-b vector's orientation via v:getOrientation() (or vice versa, multiplication order matters). i think :D

anyway all i really need to do is come up with a matrix for a and b so that the parts meet up. im probibly gonna end up reading the matrix tutorial over at gamedev (for like the 5th time) on this one.

anyway i always wondered what would happen if you changed a subobjects .Position. does the same apply if i change a subobject's .Orientation? i dont think ive seen any other ships inherit turret angles from alpha 1 whilst testing my turret scripts, but then again i wasnt looking for it.
Title: Re: any chance at gatting the lookat feature back?
Post by: Bobboau on September 21, 2007, 09:03:25 pm
the way to get this feature to work is once you have B's position in A's frame of reference, you project B's position into A's and figure out the angle you'd need to rotate A by so that it would be pointing at B.

but like I said finding B relative to A taking into account all the rotations and stuff of both of the objects is the tricky part.