TransitionToSequence not working correctly.
by Clara Easson · in Torque Game Engine · 07/11/2006 (10:35 am) · 15 replies
I added the following code to ShapeBase.cc:
bool ShapeBase::setThreadTransitionSequence(U32 slot,S32 seq,bool reset)
{
Thread& st = mScriptThread[slot];
if (st.thread && st.sequence == seq && st.state == Thread::Play)
return true;
if (seq < MaxSequenceIndex)
{
setMaskBits(ThreadMaskN << slot);
st.sequence = seq;
if (reset)
{
st.state = Thread::Play;
st.atEnd = false;
st.forward = true;
}
if (mShapeInstance)
{
if (!st.thread)
st.thread = mShapeInstance->addThread();
mShapeInstance->clearTransition(st.thread);
mShapeInstance->transitionToSequence( st.thread, seq, 1, 3.25, true );
stopThreadSound(st);
updateThread(st);
}
return true;
}
return false;
}
But the sequence just starts right away, no transitions. What am I doing wrong?
Please help.
Thank you.
bool ShapeBase::setThreadTransitionSequence(U32 slot,S32 seq,bool reset)
{
Thread& st = mScriptThread[slot];
if (st.thread && st.sequence == seq && st.state == Thread::Play)
return true;
if (seq < MaxSequenceIndex)
{
setMaskBits(ThreadMaskN << slot);
st.sequence = seq;
if (reset)
{
st.state = Thread::Play;
st.atEnd = false;
st.forward = true;
}
if (mShapeInstance)
{
if (!st.thread)
st.thread = mShapeInstance->addThread();
mShapeInstance->clearTransition(st.thread);
mShapeInstance->transitionToSequence( st.thread, seq, 1, 3.25, true );
stopThreadSound(st);
updateThread(st);
}
return true;
}
return false;
}
But the sequence just starts right away, no transitions. What am I doing wrong?
Please help.
Thank you.
About the author
#2
I should have explained in more detail.
The model I am using is based on the Player class. Initially in script I call the function..
%avitar1.playThread( 0, "root" );
To play the root animation...after some time I then call the PlayTransitionthread (new) to transition from
the root to the walk (example). But the second animation starts right away. I have tried all combinations of animations 1 to 2, but none transition.
Now I work with the ShowToolPro and play with thread 0 and set "Transition to Sequence" it transitions properly from one animation to another, without having to change priorities or anything. I have include all the code below so you can get a better look.
************************************************************************
Now I want to transition smoothly from the root position to the run. So I added a console function below:
Which is basically a copy of the 'playThread' console function. I renamed it "playTransitionThread" and have it
call the "ShapeBase::setThreadTransitionSequence(slot,seq))" method shown in the begining of this post.
ShapeBase.cc
ConsoleMethod( ShapeBase, playTransitionThread, bool, 3, 4, "(int slot, string sequenceName)")
{
U32 slot = dAtoi(argv[2]);
if (slot >= 0 && slot < ShapeBase::MaxScriptThreads) {
if (argc == 4) {
if (object->getShape()) {
S32 seq = object->getShape()->findSequence(argv[3]);
if (seq != -1 && object->setThreadTransitionSequence(slot,seq))
return true;
}
}
}
return false;
}
************************************************************************
Test function in script used to test the transitions, $state is initially set to 1.
function test( %this )
{
switch( $state )
{
case 1:// intial startup state, so play the root animation
$avitar1.playThread( 0, "root" );
$state = 2;
case 2: // now transition smoothly to a second animation after 5 seconds
$avitar1.playTransitionThread( 0, "run" );
$state = 3;
case 3: // now transition smoothly to a third after 5 seconds
$avitar1.playTransitionThread( 0, "fall" );
$state = 4;
// etc....
}
schedule( 5000, 0, test, 0 );
}
***************************************************************************
What is the ShowProTool using to transition, because it works correctly.
Any help would be greatly appreciated.
07/11/2006 (11:57 am)
Hi Manoel -I should have explained in more detail.
The model I am using is based on the Player class. Initially in script I call the function..
%avitar1.playThread( 0, "root" );
To play the root animation...after some time I then call the PlayTransitionthread (new) to transition from
the root to the walk (example). But the second animation starts right away. I have tried all combinations of animations 1 to 2, but none transition.
Now I work with the ShowToolPro and play with thread 0 and set "Transition to Sequence" it transitions properly from one animation to another, without having to change priorities or anything. I have include all the code below so you can get a better look.
************************************************************************
Now I want to transition smoothly from the root position to the run. So I added a console function below:
Which is basically a copy of the 'playThread' console function. I renamed it "playTransitionThread" and have it
call the "ShapeBase::setThreadTransitionSequence(slot,seq))" method shown in the begining of this post.
ShapeBase.cc
ConsoleMethod( ShapeBase, playTransitionThread, bool, 3, 4, "(int slot, string sequenceName)")
{
U32 slot = dAtoi(argv[2]);
if (slot >= 0 && slot < ShapeBase::MaxScriptThreads) {
if (argc == 4) {
if (object->getShape()) {
S32 seq = object->getShape()->findSequence(argv[3]);
if (seq != -1 && object->setThreadTransitionSequence(slot,seq))
return true;
}
}
}
return false;
}
************************************************************************
Test function in script used to test the transitions, $state is initially set to 1.
function test( %this )
{
switch( $state )
{
case 1:// intial startup state, so play the root animation
$avitar1.playThread( 0, "root" );
$state = 2;
case 2: // now transition smoothly to a second animation after 5 seconds
$avitar1.playTransitionThread( 0, "run" );
$state = 3;
case 3: // now transition smoothly to a third after 5 seconds
$avitar1.playTransitionThread( 0, "fall" );
$state = 4;
// etc....
}
schedule( 5000, 0, test, 0 );
}
***************************************************************************
What is the ShowProTool using to transition, because it works correctly.
Any help would be greatly appreciated.
#3
(have a look at player.cc and showTSShape.cc, the only places I've found that use transitionToSequence).
07/11/2006 (12:56 pm)
I looked through the current code that use transitionToSequence, only thing different I can see is that they instead of setting pos to 1 use getPos(). Maybe worth a try?(have a look at player.cc and showTSShape.cc, the only places I've found that use transitionToSequence).
#4
I have tried using getpos() same thing does not transition.
Very strange, can you telll how ShowProTool is calling the API's to make it work?
07/11/2006 (1:15 pm)
Hi Magnus -I have tried using getpos() same thing does not transition.
Very strange, can you telll how ShowProTool is calling the API's to make it work?
#5
I'm _guessing_ it's something pretty similar to what's going on in ShowTSShape (engine\game\showTSShape.cc)...
07/11/2006 (2:47 pm)
No idea how it's done in showtool pro, you'd have to ask David Wyand.I'm _guessing_ it's something pretty similar to what's going on in ShowTSShape (engine\game\showTSShape.cc)...
#6
07/12/2006 (4:07 pm)
Why are you calling clearTransition?
#7
07/12/2006 (4:16 pm)
That's a pretty good point Ben. (I was wondering about that too yesterday, but then I must have forgot to mention it).
#8
07/13/2006 (10:08 am)
I had added it during debugging only. Initially did not have "clearTransition". Just looking at other modules and I happended to see it player::OnAdd. Anyway I have taken it back out and still no changes, transitions do not work.
#9
Any help will be appreciated.
Thank you.
07/14/2006 (10:05 am)
Has the transitionToSequence been tested. Does it work? Is there an example on the proper way to call it?Any help will be appreciated.
Thank you.
#10
07/14/2006 (4:59 pm)
Have you tried contacting Dave Wyand about this issue? If they work in ShowTool, then he can probably share with you how to call them. Don't forget to say please (he's very busy on Constructor)!
#11
I have sent a few emails with "sorry...please help". But no response. I know he must be very busy. But I am at a loss on this. Can't go any further.
07/24/2006 (12:45 pm)
Hi Ben -I have sent a few emails with "sorry...please help". But no response. I know he must be very busy. But I am at a loss on this. Can't go any further.
#12
Maybe pooling resources with Ron would be useful here!
07/24/2006 (12:47 pm)
Did you notice this thread? www.garagegames.com/mg/forums/result.thread.php?qt=23957Maybe pooling resources with Ron would be useful here!
#13
Yes I did, I actually made a post there also. But no resolution there either.
07/24/2006 (1:42 pm)
Hi Ben -Yes I did, I actually made a post there also. But no resolution there either.
#14
07/24/2006 (2:25 pm)
Well, Ron seems to have the call working, transitioning succesfully between two threads, with the only remaning question being what the time unit is for the transition period - which some experimenting ought to resolve very quickly. (If I knew, I'd tell you guys... but you're going through the exact same discovery process I'd have to do to figure it out.)
#15
06/25/2008 (10:14 am)
Finally, the question is....Is it working?
Associate Manoel Neto
Default Studio Name
You can solve the problem by having an "empty" animation. To do one, first re-export all your animations with an increased priority (i.e.: animations with priority 0 become 1, 1 become 2 and so on), so all your animations become at least priority 1.
Now open your model, without any keyframes, then create a sequence with priority 0 and export it. That way you can use that animation whenever you want to clear a thread, and it works with transitions.