Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Inside the file \Engine\source\ts\tsShapeInstance.h
- At the end of "class TSShapeInstance" (just before the closing "}") add:
- //-------------------------------------------------------------------------------------
- //irei1as_ STsequences data of the simobject
- //-------------------------------------------------------------------------------------
- U32 mId_ObjectMaker; ///irei1as_ STsequences Object creator of this ShapeInstance
- bool mNotIsGhost_ObjectMaker; ///irei1as_ STsequences State of the Object Creator -!isGhost()-
- 2. Inside the file \Engine\source\ts\tsShapeInstance.cpp
- locate the line inside "void TSShapeInstance::buildInstanceData(TSShape * _shape, bool loadMaterials)"
- that says:
- mData = 0;
- And add before it:
- mId_ObjectMaker = 0; ///irei1as_ STsequences
- mNotIsGhost_ObjectMaker = false; ///irei1as_ STsequences
- 3. Inside the file \Engine\source\T3D\shapeBase.cpp
- locate the line
- mShapeInstance = new TSShapeInstance(mDataBlock->mShape, isClientObject());
- And add after it:
- mShapeInstance->mId_ObjectMaker = this->getId(); ///irei1as_ STsequences
- mShapeInstance->mNotIsGhost_ObjectMaker = !isGhost(); ///irei1as_ STsequences
- 4. Inside the file \Engine\source\T3D\tsStatic.cpp
- locate the line
- mShapeInstance = new TSShapeInstance( mShape, isClientObject() );
- And add after it:
- mShapeInstance->mId_ObjectMaker = this->getId(); ///irei1as_ STsequences
- mShapeInstance->mNotIsGhost_ObjectMaker = !isGhost(); ///irei1as_ STsequences
- 5. Inside the file \Engine\source\ts\tsThread.cpp
- locate this method:
- void TSThread::selectKeyframes(F32 pos, const TSSequence * seq, S32 * k1, S32 * k2, F32 * kpos)
- just at the end before the closing "}" of that add:
- ///irei1as_ STsequences start Sprite code implementation
- if (seq->isSprite())
- {
- if (kpos) *kpos = 0.0f; //irei1as_ STsequences sprite just doesn't have interpolation
- }
- ///irei1as_ STsequences end Sprite code implementation
- 6. IMPORTANT NOTE ABOUT SPRITES:
- At the shape .cs file add:
- %this.setSequenceSprite("name_of_sequence", "1"); //enables Sprites of "name_of_sequence"
- %this.setSequenceSprite("name_of_sequence", "0"); //disables Sprites of "name_of_sequence"
- Note that if there is no %this.setSequenceSprite() then it's just disabled as default.
- 7. Inside the file \Engine\source\ts\tsThread.cpp
- locate this method:
- void TSThread::activateTriggers(F32 a, F32 b)
- After this line:
- mShapeInstance->setTriggerStateBit(state & TSShape::Trigger::StateMask, on);
- Add these lines:
- ///irei1as_ STsequences start Triggery code implementation
- if (getSequence()->isTriggery())
- {
- if (mShapeInstance->mNotIsGhost_ObjectMaker) ///The script only calls from server
- {
- U32 v=(state & TSShape::Trigger::StateMask);
- int ret=0;
- if(v)--v;
- while(v){
- ret++;
- if (ret==31) break; //31 is the maximum possible value after all, so 32 would be bad
- v>>=1;
- }
- custom_animtriggercall(mShapeInstance->mId_ObjectMaker, getSequenceName(), ret+1, on); //ret[0,31]->ret+1[1-32]
- }
- }
- ///irei1as_ STsequences end Triggery code implementation
- 8. IMPORTANT NOTE ABOUT TORQUESCRIPT ANIMATION TRIGGERS (Triggery):
- At the shape .cs file add:
- %this.setSequenceTriggery("name_of_sequence", "1"); //enables Triggery of "name_of_sequence"
- %this.setSequenceTriggery("name_of_sequence", "0"); //disables Triggery of "name_of_sequence"
- Note that if there is no %this.setSequenceTriggery() then it's just disabled as default.
- 9. Now we need to implement custom_animtriggercall(...)
- First add this line at the start with the includes of \Engine\source\ts\tsThread.cpp:
- #include "animtrigger.h" ///irei1as_ STsequences
- 10. Now we need that animtrigger.h. We put in in the source folder along with torqueConfig.h
- animtrigger.h includes this data:
- //-----------------------------------------------------------------
- //irei1as_ animtrigger Here we define the exchange c++->torquescript function that is called from tsThread.cpp
- //new includes to add the torque script entry point for customanimtrigger
- #include "console/engineAPI.h"
- void custom_animtriggercall(U32 object_id, String sequence_name, U32 trigger_number, bool trigger_state)
- {
- //enter point to torquescript
- //Note that the function "customanimtrigger" should be defined somewhere inside a torquescript .cs
- //object_id id of that server object
- //sequence_name name of the sequence of the trigger
- //trigger_number number of the trigger calling this
- //trigger_state state of the trigger calling this
- if ( Con::isFunction( "custom_animtriggercall" ) )
- Con::executef("custom_animtriggercall",object_id,sequence_name,trigger_number,trigger_state);
- }
- 11. Finally we only need to add in torquescript somewhere a function like:
- // Function that handles animation triggers
- function custom_animtriggercall(%objectidA, %sequencenameA, %triggernumberA, %triggerstateA)
- {
- //code goes here;
- //echo("object=" @ %objectnameA @ "-");
- echo("object=" @ %objectidA.getName() @ "-");
- echo("objectid=" @ %objectidA @ "-");
- echo("sequence=" @ %sequencenameA @ "-");
- echo("triggernumber=" @ %triggernumberA @ "-");
- echo("triggerstate=" @ %triggerstateA @ "-");
- echo("\n");
- }
- Note: Triggers in the last frame may not be called (use lastframe-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement