GuiPlayerView::setPlayerSeq issue
by Jake Callery · in Torque Game Engine · 10/20/2007 (3:53 pm) · 7 replies
Hey guys,
I'm trying to make a character selection screen, with animated character previews.
I've got the character loading with the setModel("","") member function,
however I can't seem to get setSeq() to work.
It just simply doesn't do anything. No errors.
In the engine it is basically setting a number to the mAnimationSeq variable.
However I don't see anything ever being done with that.
Is this simply not implemented?
Any thoughts on making it work?
Thanks much for the help!
I'm trying to make a character selection screen, with animated character previews.
I've got the character loading with the setModel("","") member function,
however I can't seem to get setSeq() to work.
It just simply doesn't do anything. No errors.
In the engine it is basically setting a number to the mAnimationSeq variable.
However I don't see anything ever being done with that.
Is this simply not implemented?
Any thoughts on making it work?
Thanks much for the help!
#2
10/23/2007 (9:17 am)
Can you give me the path to GuiPlayerView.cpp please. I cannot find this file.
#3
I believe other people have used the "ObjectView" resource which might be newer than GuiPlayerView. I believe I used GuiPlayerView because it seemed simpler to modify since I needed extensive customization of the controls (we had what was essentially multiple root animations. My suggestion is: Don't Ever Do This.)
My script does it this way:
playerView.setSeq(0, 1); // index, 1= playForward or 0= backward
I don't recall right now if we extended the interface here - sorry.
index above has to match that used in previous the loadDsq call:
playerView.loadDSQ(0, "root", "xxxxxxxxx.dsq"); // anim seq index (for later setSeq), anim name (search for), DSQ file path
Note: take a look at player.cc and also the TSShapeInstance class to see how the animations are used. For example, there are certain early (low sequence number, e.g. 0..8 or so) animations that are expected all around the codebase. My suggestion is to make any you don't intend to use small "do nothing" DSQs and keep them in the list if you definitely don't need them. Trying to change all the hard coded index numbers could be a lot of useless work. Likely be easier just to put all your specialized animations after them.
My last project included a PlayerView selection screen that also let you "try out" the game controls and see the player respond. (Sounds similar to what you are doing.) We ended up with a very customized version of PlayerView to match our complex object.
Glancing at my code, try looking at the PlayerView setPlayerModel() method. Per the code comments, I apparently copied a lot of functionality from setPlayerModel into setPlayerSeq to actually activate the sequence. For example:
(sequence object gets loaded from the mAnimationSeq)
Again, we might have added some items to the interface, like the forward/backward. I don't recall at this point.
10/23/2007 (3:20 pm)
WildCat: I believe GuiPlayerView is a resource, not a standard part of TGE. I believe other people have used the "ObjectView" resource which might be newer than GuiPlayerView. I believe I used GuiPlayerView because it seemed simpler to modify since I needed extensive customization of the controls (we had what was essentially multiple root animations. My suggestion is: Don't Ever Do This.)
My script does it this way:
playerView.setSeq(0, 1); // index, 1= playForward or 0= backward
I don't recall right now if we extended the interface here - sorry.
index above has to match that used in previous the loadDsq call:
playerView.loadDSQ(0, "root", "xxxxxxxxx.dsq"); // anim seq index (for later setSeq), anim name (search for), DSQ file path
Note: take a look at player.cc and also the TSShapeInstance class to see how the animations are used. For example, there are certain early (low sequence number, e.g. 0..8 or so) animations that are expected all around the codebase. My suggestion is to make any you don't intend to use small "do nothing" DSQs and keep them in the list if you definitely don't need them. Trying to change all the hard coded index numbers could be a lot of useless work. Likely be easier just to put all your specialized animations after them.
My last project included a PlayerView selection screen that also let you "try out" the game controls and see the player respond. (Sounds similar to what you are doing.) We ended up with a very customized version of PlayerView to match our complex object.
Glancing at my code, try looking at the PlayerView setPlayerModel() method. Per the code comments, I apparently copied a lot of functionality from setPlayerModel into setPlayerSeq to actually activate the sequence. For example:
(sequence object gets loaded from the mAnimationSeq)
if( sequence != -1 && mModel)
{
if (runThread) {
mModel->destroyThread(runThread);
runThread = 0;
}
runThread = mModel->addThread();
if (runThread) {
if (playForward) {
mModel->setPos( runThread, 0.0f );
mModel->setTimeScale( runThread, 1.0f );
mModel->setSequence( runThread, sequence, 0.0f ); // threadPtr, sequence, position in animation (0.0..1.0)
} else {
mModel->setPos( runThread, 1.0f );
mModel->setTimeScale( runThread, -1.0f ); // (runs anim backward)
mModel->setSequence( runThread, sequence, 1.0f ); // start at end for backward // threadPtr, sequence, position in animation (0.0..1.0)
}
}
}Again, we might have added some items to the interface, like the forward/backward. I don't recall at this point.
#4
As for GuiPlayerView, it is part of the TGE stock code. the objectView code is the only resource that I found that does anything similar. However I don't think it handled animations either.
I'm just looking to play an idle animation in the character select screen. The code above should give me a good start.
Thanks again!
Oh, and the path is SourceFiles/Game/GuiPlayerView.cc/.h in the 1.5.2 version of TGE.
Jake
10/23/2007 (3:42 pm)
Matthew, thanks very much for the code sample. I will see what I can do with it. I really appreciate the point in the right direction.As for GuiPlayerView, it is part of the TGE stock code. the objectView code is the only resource that I found that does anything similar. However I don't think it handled animations either.
I'm just looking to play an idle animation in the character select screen. The code above should give me a good start.
Thanks again!
Oh, and the path is SourceFiles/Game/GuiPlayerView.cc/.h in the 1.5.2 version of TGE.
Jake
#6
It looks like it should work for me.
However, just for clarity, GuiPlayerView, doesn't seem to provide animation, but the GuiObjectView resource looks like it will do the trick. Hopefully its not too hard to merge with 1.5.2.
Thanks again for the tip Christian!
Jake
10/23/2007 (3:57 pm)
Wow, not sure how I missed the GuiObjectView resource. Thanks for pointing that out!It looks like it should work for me.
However, just for clarity, GuiPlayerView, doesn't seem to provide animation, but the GuiObjectView resource looks like it will do the trick. Hopefully its not too hard to merge with 1.5.2.
Thanks again for the tip Christian!
Jake
#7
10/24/2007 (11:54 am)
I'm trying to do something similar in TGEA 1.0.3. Since My model doesnt need to be animated I guess I could attempt GuiPlayerView instead. Hopefully I can swap the clothes and hair on my model in real time to make for a pretty cool preview within the character selection screen. I'm a Torque newbie and will take any and all advice/guidance. Thanks in advance!
Torque 3D Owner Jake Callery
CharViewUI.setModel("base/data/shapes/player1.dts",""); CharViewUI.setSeq(1);So the model shows up, but the animation never plays.
void GuiPlayerView::setPlayerSeq( S32 index ) { if( index > MaxAnimations || index < 0 ) return; mAnimationSeq = index; }That is the code in the guiPlayerView.cc file.
Any idea on what mAnimationSeq is? or what this part of the class def is used for:
enum { run = 0, hi, anim1, anim2, anim3, anim4, anim5 };Thanks!