playThread and Speed
by Nicolai Dutka · in Torque Game Engine Advanced · 08/18/2009 (1:37 pm) · 3 replies
Is there a way to alter the speed at which an animation is played without effecting the rest of the game?
I need to be able to speed up the animations of character under specific circumstances. The only option I can think of is to re-export the character with a second set of sequence helpers that have the framerate doubled (if I am thinking correctly here, playing an animation with 60 frames at 30 frames per second will take 2 seconds to play, but playing it at 60 frames per second would make the animation look sped up and only take 1 second to play...)
What I'd really like is another parameter in 'playThread':
%obj.playThread(%slot,%sequence,%speed)
I need to be able to speed up the animations of character under specific circumstances. The only option I can think of is to re-export the character with a second set of sequence helpers that have the framerate doubled (if I am thinking correctly here, playing an animation with 60 frames at 30 frames per second will take 2 seconds to play, but playing it at 60 frames per second would make the animation look sped up and only take 1 second to play...)
What I'd really like is another parameter in 'playThread':
%obj.playThread(%slot,%sequence,%speed)
#2
Also, if this is in C++, how would I set a default value of 1 in case no value is given?
I haven't had to do much in C++, so my skill in that area is very... 'noobish'. :P
08/18/2009 (4:57 pm)
Is that in C++ code? If so, do you happen to know which file?Also, if this is in C++, how would I set a default value of 1 in case no value is given?
I haven't had to do much in C++, so my skill in that area is very... 'noobish'. :P
#3
In the concole method playthread,you should add the speed factor:
F32 speed = dAtof(argv[3]);
Then instead of
object->playThread(slot);
use:
object->playThread(slot,speed);
You should do the same for updateThread()
don't forget to correct the declarations into the header file.
You call updateThread(Thread& st,F32 speed);
Find that:
mShapeInstance->setTimeScale(st.thread,st.forward ? 1.0f : -1.0f);
replace with:
if(speed) mShapeInstance->setTimeScale(st.thread,st.forward ? speed : -speed);
else mShapeInstance->setTimeScale(st.thread,st.forward ? 1.0f : -1.0f);
if you do not need speed,you use '0' in playthread.
I have not tested this,i believe it works.
08/18/2009 (5:05 pm)
It is in shapebase.In the concole method playthread,you should add the speed factor:
F32 speed = dAtof(argv[3]);
Then instead of
object->playThread(slot);
use:
object->playThread(slot,speed);
You should do the same for updateThread()
don't forget to correct the declarations into the header file.
You call updateThread(Thread& st,F32 speed);
Find that:
mShapeInstance->setTimeScale(st.thread,st.forward ? 1.0f : -1.0f);
replace with:
if(speed) mShapeInstance->setTimeScale(st.thread,st.forward ? speed : -speed);
else mShapeInstance->setTimeScale(st.thread,st.forward ? 1.0f : -1.0f);
if you do not need speed,you use '0' in playthread.
I have not tested this,i believe it works.
Torque Owner Ivan Mandzhukov
Liman3D
that can be done in updateThread(),where you can adjust the animation's timescale.
instead of setting 1 or -1(inverse playback),you should set speed or -speed.