Game Development Community

dev|Pro Game Development Curriculum

Animated fxShapeReplicator

by Vincent BILLET · 07/03/2006 (11:31 am) · 15 comments

The reason I wanted to create animated shapes was beacause fxShapeReplicator couldn't animate shapes.

fxShapeReplicator creates TSStatic. So we need to update TSStatic.h and TSStatic.cpp to make this work.

Here is this solution :
in TSStatic.h, just before : bool prepRenderImage ( SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState=false);
I Add :
// Rendering
  protected:
   U32	  smLastTime;    // Animated TSStatic : Last Render Time
   TSThread* pTread;	 // Animated TSStatic : Controlling Thread
   bool isanimated;		 // Animated TSStatic : Is Static Animated

Verify also if you have this in the top of TSStatic.h :
class TSShapeInstance;
class TSStatic;
class Shadow;
[B]class TSThread;[/B]

in TSStatic.cpp, just before mShapeInstance->animate();
I add :
// Animated TSStatic : if this static is animated
if (isanimated)
{
   // Animated TSStatic : Make animation advance
   mShapeInstance->advanceTime((Sim::getCurrentTime()-smLastTime)/1000.0,pTread); 
   // Animated TSStatic : Remember last Render Time
   smLastTime = Sim::getCurrentTime();
}

in TSStatic.cpp, just before addToScene();
I Add :
// Animated TSStatic : Get the Shape
   TSShape* pShape = mShapeInstance->getShape();
   // Animated TSStatic : Find the default Action
   S32 seq = pShape->findSequence("Action");				
   // Animated TSStatic : Default : No Animation
   isanimated = false;								
   // Animated TSStatic : If Default Animation is set
   if(seq >= 0){
      // Animated TSStatic : Ok, We have an animation
      isanimated = true;
      // Animated TSStatic : Adding the thread		
      pTread = mShapeInstance->addThread();
      // Animated TSStatic : Init sequence		
      mShapeInstance->setSequence(pTread, seq, 0);
      // Animated TSStatic : Get the current time for render usage
      smLastTime = Sim::getCurrentTime();
   }

And here I Have a My fxShapeReplicator with animated shapes !
Note : The default animation is called "Action". When you create a Static (even without a fxShapeReplicator), this default action is played
Be Happy !

Edit : Added Fix of Riccardo.

#1
05/03/2006 (6:28 am)
Hot stuff Vincent. Oblivion here we come :-)
#2
07/07/2006 (6:26 am)
can't get it working in TGE1.4.
getting error:
engine\game\tsStatic.h(116): error C2143: syntax error : missing ';' before '*'
The line, compiler doesnt like is
TSThread* pTread;
any hints on how to make it working not only in TSE, but in TGE also?
#3
07/21/2006 (12:21 am)
bank, you must define class TSThread at the top of tsStatic.h:

class TSShape;
class TSShapeInstance;
class TSStatic;
class TSThread; <--------------------------!!!!!add this
class Shadow;
#4
07/21/2006 (1:27 am)
Thank you Riccardo for the fix. I've updated this ressource.
#5
07/21/2006 (7:49 am)
I this out, everything compile. When place shape in mission with Animation it does not show but nonanimation shape does?
#6
01/06/2007 (1:54 am)
Does this work with Torque 1.5?
#7
01/06/2007 (7:18 am)
Just put into TGE 1.5.
Works great, thanks tons.
#8
01/08/2007 (10:40 am)
In my game the animation is not shown. I looked with the torque show tool pro for a good a animation, I use the player from tutorial base, sequence01 is a good animation, so I changed it in the source, but there's no animation played.
#9
01/08/2007 (12:01 pm)
@Christian :
The animation played by default must be called "Action", not sequence01.
#10
01/08/2007 (2:29 pm)
Vincent Billet is 100 percent correct. I just tested it in TGE 1.5.0.
#11
01/09/2007 (5:25 am)
So, how to change this?
#12
01/09/2007 (7:30 am)
in TSStatic.cpp, just before addToScene();
Change :
// Animated TSStatic : Find the default Action
S32 seq = pShape->findSequence("Action");
#13
01/09/2007 (7:31 am)
I did this, but it still does not work.
#14
01/09/2007 (7:57 am)
You can just redo your animation in 3d software.
#15
03/09/2007 (2:35 pm)
Great resource. Big thanks for sharing!