Game Development Community

dev|Pro Game Development Curriculum

afxHelicopter

by Gibby · 11/17/2012 (2:36 pm) · 7 comments

With the deprecation of IFL animations from T3D, I, like many others, have been searching to find an easy way to animate helicopter blades, ceiling fans, etc. This can be done by mounting the object as a ShapeBase but afx provides in afxModelData a handy way of doing this as well.Here's an example of using afx to do the work:

First, I took a static helicopter model, selected the rotor blades and shaft, and separated them into their own mesh. I then added a node [in my case, mount5] where the rotor shaft meets the helicopter body. I then saved the body as a separate dts model without the rotor mesh. Next, I centered my new rotor mesh, offsetting it's origin to be below the rotors in the center of the shaft. Then I animated the entire mesh to rotate 360 degrees, and saved it as a dts file with the animation 'baked in' as 'ambient'.

In the helicopter script file, I added this:

// =============================================================================
// Gibstah's afxHelicopter
// =============================================================================

datablock afxModelData(HELI_Rotor01_CE)
{
   shapeFile = "art/shapes/vehicles/heli/rotor01_anim.dts";
   sequence = "ambient"
   sequenceRate = 1;
};

datablock afxEffectWrapperData(HELI_Rotor01_EW)
{
  effect = HELI_Rotor01_CE;

  constraint = 'helicopter.mount5";
};

datablock afxEffectronData(Equip_Chopper_Rotor)
{
	duration = $AFX::INFINITE_TIME;
	execOnNewClients = true;
	addEffect = HELI_Rotor01_EW;
};

function equipChopper(%chopper)
{
    %chopper.rotor = startEffectron(Equip_Chopper_Rotor, %chopper, "helicopter");
}
 
function jetHeli::onAdd( %this, %obj )
{
   
	//Parent::onAdd( %this, %obj );
	%obj.setEnergyLevel(%this.MaxEnergy);
	%obj.setRechargeRate(%this.rechargeRate);
	%obj.setRepairRate(0);
	%obj.mountable=true;
   
	equipChopper(%obj);

	//remainder of generic ::onAdd goes here, blah, blah, blah...

Before and After:





#1
11/17/2012 (4:30 pm)
i also did the same thing with my heli.
+i have plan to split it into more parts so that it spilited away depending on damage position.just like gta4.all scripting was done a long time ago.

only need to learn 3d max/blender for this.
looks like that will never be happened.nor my script will be in action.

"but afx provides in afxModelData a handy way of doing this "
i was wondering why u particularly need afx.
as far i remember i did that with stock functions.
may be using:
bool SceneObject::mountObject()
#2
11/17/2012 (4:43 pm)
If you notice in the video, there seems to be an issue with rendering the blades in sync with the body using ShapeBase::mountObject. The issue went away with afx. The reason, among many, to use afx is to be able to dynamically animate the rotor for start/stop/damage. I also enhance all of my weapons and damage effects with afx as well - stay tuned for footage...
#3
11/17/2012 (4:45 pm)
ugh - webserver issue generated multiple posts...

@ahsan: NEVER say never. I not a modeler at all, yet have been using the student version of max to slowly learn the prog on my own time. As a scripter/Coder, just knowing the pipeline and being able to use it myself to equip models to follow my code is a huge asset...
#4
11/17/2012 (5:00 pm)
"there seems to be an issue with rendering the blades in sync with the body using ShapeBase::mountObject. The issue went away with afx."

ahh,i cant see the video.(youtube banned in my country.)
i am not sure if i also have same issue.
i have to check my one.

+ which model you are using for your heli?

there is a sound issue with heli.did u solve it?can u hear your heliEngine sound on movement?
(although i have fixed it.need to test more before post)



#5
11/17/2012 (5:11 pm)
Quote:
there is a sound issue with heli.did u solve it?can u hear your heliEngine sound on movement?

If you're using the helicopter resources that have been bouncing around, the sound is not likely to work as the sound layer changed a few times between TGE/TGEA/2009/1.2...


FWIW I'm not using any of the pre-existing helicopter resources but rather a newer, slightly more extensible vtolVehicle class that Sean Rice and I have done. If I recall, the forward thrust issue with the old resource was an issue with the file but don't quote me on that...
#6
11/17/2012 (8:58 pm)
Huh, looks like something about mounting needs to be fixed :P. What classes were you mounting? I.e. was the rotor a StaticShape? EDIT: Oops, found your thread.
#7
11/18/2012 (12:18 am)
This is a cool use for AFX. Thanks for sharing.