Game Development Community

Precise animation thread control in script

by John Klima · in Torque Game Engine · 03/29/2006 (7:35 am) · 2 replies

Hi all,

i am finding a need for precise thread control from script, along the lines of what showTSShape exposes. i want to have many many additional threads for blending with the normal run/walk/jump/death etc... and i want to control the frame any animation is at, and it's scale, much like the sliders in show. so far i have not found a good way to do this from script. playThread() simply plays the thread.

do i need to somehow integrate what showTSShape exposes into maybe player.cc and then create console methods? or is there some way i can just get at an object's .dsqs in script and mess with them the way showTSShape does?


thanks!

j

#1
03/29/2006 (4:51 pm)
Well i made some progress. in my player.cc i added this:
S32 i = 0;  //just test one
          S32 baSeq = shape->findSequence("ShoulderLeftUp");
          if (baSeq != -1) {
             mBoneBlends[i] = mShapeInstance->addThread();
             mShapeInstance->setSequence(mBoneBlends[i],baSeq, 0.5f);
             mShapeInstance->setTimeScale(mBoneBlends[i],0);             
          }
          else
             mBoneBlends[i] = 0;
at the bottom of Player::onNewDataBlock(). i put it there cause there was something similar above that handles the look thread:
// Initialize head look thread
       TSShape const* shape = mShapeInstance->getShape();
       S32 headSeq = shape->findSequence("head");
       if (headSeq != -1) {
          mHeadVThread = mShapeInstance->addThread();
          mShapeInstance->setSequence(mHeadVThread,headSeq,0);
          mShapeInstance->setTimeScale(mHeadVThread,0);
       }
       else
          mHeadVThread = 0;

i then made a console method to set my new mBoneBlend[] value, which subsequently calls this:
void Player::setBoneBlendValue(S32 index, F32 value){ 
       Con::printf("player.cc->Set Bone Blend %d %f",index, value);
    	 mShapeInstance->setPos(mBoneBlends[index],value);
    }

all the data is getting to the right place, but for some reason, prolly client/server stuff that i still dont understand, nothing happens. back up in onNewDataBlock, when i set the mShapeInstance->setSequence(mBoneBlends[i],baSeq, 0.5f); the thread goes to the right spot, 0.5, no problem. so i'm doing something right. just don't know what i'm doing wrong, why the position doesn't change. i tried to model this on what showTsShape does, and i saw no "dirtyeverything" or playThread or anything like it. as far as i can tell, its sets the thread pos to the position of the gui slider, and that is that.

any help greatly appreciated!!

thanks!

j
#2
03/30/2006 (4:43 pm)
Uggh some day i will get the hang of this

first, i have to store my script set value in a datablock, damn i knew that one!

void Player::setBoneBlendValue(S32 index, F32 value){
        mDataBlock->boneBlendValue[index] =value;    
}

then in player.cc updateAnimation()
for(S32 i = 0 ; i < BONE_BLEND_MAX ; i++){
            mShapeInstance->setPos(mBoneBlends[i],mDataBlock->boneBlendValue[i]);         
            mShapeInstance->advanceTime(dt,mBoneBlends[i]);
    }

now when i call my console function, everything works. prolly should put some null and range checking on the input values.