Author Topic: Rotating animation script (alpha build)  (Read 4087 times)

0 Members and 1 Guest are viewing this topic.

Rotating animation script (alpha build)
Before I stall any longer here's the animation script. I haven't got everything I wanted in it yet, but there's enough for thrust vectoring, thrust nozzles and landing gear systems.  Also if someone wants to write this in a more understandable instructions please do!!!

This is an alpha build so it's probably buggy and not the best of handling everything, but it's a start.
There's a few things you must do beforehand to get everything working.

1. The subobject's axises must be aligned with that of the ships (i.e. the subobjects x axis must be parallel to the ships x, same for y & z). If they're not they won't rotate correctly (in fact they'll rotate on the ships axis rather than the subsystem's) If someone can find a solution for this please let me know! 

 If the subsystem's doesn't match up, you must rotate them to be parallel.  Remember what those rotation coordinates are, you'll need them later!!!  Finally preform a x-form reset (or equivalent) to force it aligned.  Don't worry you'll be providing those angles later and will appear correctly in-game

2. The subsystem must be visible to fred (i.e. have a $special=subsystem and $name=blah) and the appropriate ship table entries.  Otherwise nothing will happen

3. copy the animation-sct.tbm into the tables folder and load it with your favorite editor (notepad++ hint hint)

4. Scroll down to ShipType:RegisterShip (about line 1278) 
Code: [Select]
function ShipType:RegisterShip ()

local ship = self:GetRealShip ()
if (ship.Class.Name == "F-104D Bearcat") then
self:RegisterBearcat ()
--*****************************************************************************************************
-- UPDATE ME
-- Add different ship classes as needed here
--*****************************************************************************************************
end
self:SetInitialOrientation ()
end
you'll need to add your new ship type here.  Let's say for example you made "GTSV Hercules Mk X"
you would add this:
Code: [Select]
elseif (ship.Class.Name == "GTSV Hercules Mk X") then
     self:RegisterGTSVHercules ()

Warning! Renaming your ship latter will require this to be altered to.! (Is there a way in lua to retrieve the $short name for a ship? that would be much safer)

5. Next we need to create the RegisterGTSVHercules.  Jump down to line 1451 (ShipType:RegisterBearcat ())
This is a template for your ship. copy this function (1456 to 1623) and paste it. Rename it to that function name (in this case "RegisterGTSVHercules"

6. There's quite a bit here you probably won't need.  If your looking to do landing gears the stuff in "testing == 1" is what you want to look at (1470-1583).  Thrust vectoring, nozzling is the second half (1586-1621)
I hope I left enough comments in there to help you.  There's two different ship models i used, one was my bearcat with landing gears and the other a box with vectoring engines.

Also remember back when I said to remember those coordinates if the axises didn't align, those go in the Offset.  The second parameter for RegisterLandingGearSubsystem, RegisterThrustVectorSubsystem, RegisterThrustVelocitySubsystem.  I.e. let's say you had a subobject "PortLandingGear"  that was off ship axis.  You rotated it till it was on.  Let's say (-10,0,0).  RegisterLandingGear... would look like this:
Code: [Select]
self:RegisterLandingGearSubsystem ("PortLandingGear" ba.createVector (math.rad (10),0,0),......
Note the angle is the negative if what we first saw.  We want the offset to be the angle from the ships (0,0,0) to where the subsystem should first show up as.  Hope that made sense

7. That should be it for lua coding! WHEW!

8. In FRED you'll want to luascript these functions:  OpenLandGear ("ShipName")  CloseLandGear ("ShipName") ToggleLandGear ("ShipName")

Ugh too big for code.  Grab it here:

Version 0.201
http://scoobydoo.freespacemods.net/AnimBeta/0.201-animation-sct.tbm

Version .2
http://scoobydoo.freespacemods.net/AnimBeta/0.2-animation-sct.tbm

Version .12
http://scoobydoo.freespacemods.net/AnimBeta/0.12-animation-sct.tbm

Version .11
http://scoobydoo.freespacemods.net/AnimBeta/0.11-animation-sct.tbm

Version .1
http://scoobydoo.freespacemods.net/AnimBeta/0.1-animation-sct.tbm
« Last Edit: October 08, 2014, 02:50:21 am by Scooby_Doo »
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 
Re: Rotating animation script (alpha build)
Awesome.  Could you release the test models you used as an example?

 
Re: Rotating animation script (alpha build)
Yup, give me a couple minutes...

Alright here's everything:
There's two different models, the landing gear bearcat  and the thrust vectoring/nozzle. 
To switch to the bearcat model:
set TCI-Bearcat-shp.tbm   "$Pof file: TCI-Bearcat1.pof"
animation-sct.tbm   line 1463   "local testing = 1"


To switch to the thrust nozzle model:
set TCI-Bearcat-shp.tbm "$POF file: TCI-Bearcat.pof"
animation-sct.tbm line 1463  "local testing = 0"

it's not the best way but it works for me.  also there is no need to modify the mission file (i think i set the keys alt+q and alt+g to open/close the doors, they have no effect on the thruster version)
http://scoobydoo.freespacemods.net/AnimBeta/AnimTest-03-06-13.7z

If you have any more questions, just ask!


« Last Edit: March 06, 2013, 10:47:27 pm by Scooby_Doo »
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

  
Re: Rotating animation script (alpha build)
I'm getting the following error with the bearcat model:  "GetShipByName (name) Mismatch type <name>, needs 'string', got string"

 
Re: Rotating animation script (alpha build)
Fixed, there was an another  one.  My type checking routine wasn't looking for the right thing whoops.

Version 0.11 is up now.
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 
Re: Rotating animation script (alpha build)
I've updated it to 0.12  There was a bug with the thruster velocity,  afterburner angles were always used when afterburning, even if you didn't want it.  It now obeys your true/false request, although it might be a bit jumpy when going from zero to afterburner and back again.  One possible solution is to give  the afterburner position  the same position as the max speed position.
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 
Re: Rotating animation script (alpha build)
There seems to be a bug in the RemoveLostShips.  The game will crash when you kill a ship. Why the game is crashing is confusing me.

When I use the open/close/toggle landing gear I can search through the ships available ingame and choose the correct one (done simply via GetShipByName script).

Now when I look for ships that are no longer in the game, the list still exists and has all the correct entries, but when I try to retrieve an entry it's nil.

Code: [Select]
function ToggleLandGear(shipName)
assert (shipName ~= nil, "Error: CloseLandGear (shipName) shipName is nil")

local ship = shipList:GetShipByName (shipName)
ship:ToggleLandingGear()
end

Code: [Select]
function ShipListType:GetShipByName (name)
assert (name ~= nil, "ShipListType:GetShipByName (name) name is nil")
assert (type (name) == "string", "ShipListType:GetShipByName (name) Mismatch type <name>, needs 'string', got " .. tostring (type (name)))

for loop = 1, #self.shipAnimationList do
local ship = self:GetShip (loop)
if (ship:GetRealShip ().Name == name) then
return ship
end
end

return nil
end

Code: [Select]
function RemoveLostShips ()

debugs = #shipList.shipAnimationList
gr.drawString (debugs, 50,50)

local debugs3 = shipList.shipAnimationList [1]
gr.drawString (debugs3, 100, 150)

local debugs1 = shipList:GetShipByName ("Alpha 1")
gr.drawString (debugs1, 100, 50)

local debugs2 = shipList:GetShipByName ("Test1")
gr.drawString (debugs2, 100, 100)

end
In RemoveLostShips all those show (nil)... but I can still ToggleLandGear ("Alpha 1") and it works  :banghead:  :confused:
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 
Re: Rotating animation script (alpha build)
Think I've finally cracked the problem with crash to desktop when a ship is destroyed.

Version 0.2 has been uploaded, hopefully no more problems with that. *crosses fingers*
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 
Re: Rotating animation script (alpha build)
Another bug fixed, Version 0.201. This time is was a stupid little error  :banghead:  When you forced the landing gears to close it would act as though they were opening.  I had CloseLandingGear call for opening LOL.

Also I learned in the ship table, the subsystem entry just needs the bare basics.  Don't put any rotation/animation info in, otherwise the subsystem can do some weird rotations that you don't have any idea why it's doing it.  Spent an hour trying to figure that one out.
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"