Creating a shape with C
by Vincent BILLET · in Torque Game Engine · 05/01/2006 (1:38 am) · 5 replies
Sorry for this stupid question, but it don't find the solution. I want to translate this script in C++.
How do I manage to create my shape and animating it in C++?
In advance thanks for the answers.
%shape = new StaticShape() { datablock = "MyShapeDataBlock"; };
MissionCleanup.add(%shape);
%shape.setTransform("0 0 0");
%shape.setscale("1 1 1");
%shape.playThread(0,"Action");How do I manage to create my shape and animating it in C++?
In advance thanks for the answers.
#2
05/02/2006 (1:59 am)
Yes, but it create TSStatic which can't be animated. If I use BaseShape, the shape simply doesn't render.
#3
05/02/2006 (3:27 am)
If I remember correctly you cannot use ShapeBase objects directly. You need to use a derivative of a shapebase.
#4
05/02/2006 (11:55 am)
The reason I mentioned the fxShapeReplicator was because it creates things. You can look at the code and learn how to spawn objects (not limited to TSStatics) from C++.
#5
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
in TSStatic.cpp, just before mShapeInstance->animate(); I add :
in TSStatic.cpp, just before addToScene(); I Add :
And here I Have a My fxShapeReplicator with animated shapes !
Once again, I'm Happy :)
05/02/2006 (12:36 pm)
The reason I wanted to create animated shapes was beacause fxShapeReplicator couldn't animate shapes. But thank you for the answer. I Found a solution to animate fxShapeReplicator, So now I'm Happy.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 bool prepRenderImage ( SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState=false);
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 !
Once again, I'm Happy :)
Associate Manoel Neto
Default Studio Name