Advertisement
Guest User

st_2 doc ST_ implementation.txt

a guest
May 9th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. 1. Inside the file \Engine\source\ts\tsShapeInstance.h
  2. At the end of "class TSShapeInstance" (just before the closing "}") add:
  3.  
  4. //-------------------------------------------------------------------------------------
  5. //irei1as_ STsequences data of the simobject
  6. //-------------------------------------------------------------------------------------
  7. U32 mId_ObjectMaker; ///irei1as_ STsequences Object creator of this ShapeInstance
  8. bool mNotIsGhost_ObjectMaker; ///irei1as_ STsequences State of the Object Creator -!isGhost()-
  9.  
  10.  
  11. 2. Inside the file \Engine\source\ts\tsShapeInstance.cpp
  12. locate the line inside "void TSShapeInstance::buildInstanceData(TSShape * _shape, bool loadMaterials)"
  13. that says:
  14. mData = 0;
  15. And add before it:
  16.  
  17. mId_ObjectMaker = 0; ///irei1as_ STsequences
  18. mNotIsGhost_ObjectMaker = false; ///irei1as_ STsequences
  19.  
  20. 3. Inside the file \Engine\source\T3D\shapeBase.cpp
  21. locate the line
  22. mShapeInstance = new TSShapeInstance(mDataBlock->mShape, isClientObject());
  23. And add after it:
  24.  
  25. mShapeInstance->mId_ObjectMaker = this->getId(); ///irei1as_ STsequences
  26. mShapeInstance->mNotIsGhost_ObjectMaker = !isGhost(); ///irei1as_ STsequences
  27.  
  28. 4. Inside the file \Engine\source\T3D\tsStatic.cpp
  29. locate the line
  30. mShapeInstance = new TSShapeInstance( mShape, isClientObject() );
  31. And add after it:
  32.  
  33. mShapeInstance->mId_ObjectMaker = this->getId(); ///irei1as_ STsequences
  34. mShapeInstance->mNotIsGhost_ObjectMaker = !isGhost(); ///irei1as_ STsequences
  35.  
  36. 5. Inside the file \Engine\source\ts\tsThread.cpp
  37. locate this method:
  38. void TSThread::selectKeyframes(F32 pos, const TSSequence * seq, S32 * k1, S32 * k2, F32 * kpos)
  39. just at the end before the closing "}" of that add:
  40.  
  41. ///irei1as_ STsequences start Sprite code implementation
  42. if (seq->isSprite())
  43. {
  44. if (kpos) *kpos = 0.0f; //irei1as_ STsequences sprite just doesn't have interpolation
  45. }
  46. ///irei1as_ STsequences end Sprite code implementation
  47.  
  48. 6. IMPORTANT NOTE ABOUT SPRITES:
  49. At the shape .cs file add:
  50.  
  51. %this.setSequenceSprite("name_of_sequence", "1"); //enables Sprites of "name_of_sequence"
  52. %this.setSequenceSprite("name_of_sequence", "0"); //disables Sprites of "name_of_sequence"
  53.  
  54. Note that if there is no %this.setSequenceSprite() then it's just disabled as default.
  55.  
  56. 7. Inside the file \Engine\source\ts\tsThread.cpp
  57. locate this method:
  58. void TSThread::activateTriggers(F32 a, F32 b)
  59. After this line:
  60. mShapeInstance->setTriggerStateBit(state & TSShape::Trigger::StateMask, on);
  61. Add these lines:
  62.  
  63. ///irei1as_ STsequences start Triggery code implementation
  64. if (getSequence()->isTriggery())
  65. {
  66. if (mShapeInstance->mNotIsGhost_ObjectMaker) ///The script only calls from server
  67. {
  68. U32 v=(state & TSShape::Trigger::StateMask);
  69. int ret=0;
  70. if(v)--v;
  71. while(v){
  72. ret++;
  73. if (ret==31) break; //31 is the maximum possible value after all, so 32 would be bad
  74. v>>=1;
  75. }
  76. custom_animtriggercall(mShapeInstance->mId_ObjectMaker, getSequenceName(), ret+1, on); //ret[0,31]->ret+1[1-32]
  77. }
  78. }
  79. ///irei1as_ STsequences end Triggery code implementation
  80.  
  81. 8. IMPORTANT NOTE ABOUT TORQUESCRIPT ANIMATION TRIGGERS (Triggery):
  82. At the shape .cs file add:
  83.  
  84. %this.setSequenceTriggery("name_of_sequence", "1"); //enables Triggery of "name_of_sequence"
  85. %this.setSequenceTriggery("name_of_sequence", "0"); //disables Triggery of "name_of_sequence"
  86.  
  87. Note that if there is no %this.setSequenceTriggery() then it's just disabled as default.
  88.  
  89. 9. Now we need to implement custom_animtriggercall(...)
  90. First add this line at the start with the includes of \Engine\source\ts\tsThread.cpp:
  91.  
  92. #include "animtrigger.h" ///irei1as_ STsequences
  93.  
  94. 10. Now we need that animtrigger.h. We put in in the source folder along with torqueConfig.h
  95. animtrigger.h includes this data:
  96.  
  97. //-----------------------------------------------------------------
  98.  
  99. //irei1as_ animtrigger Here we define the exchange c++->torquescript function that is called from tsThread.cpp
  100. //new includes to add the torque script entry point for customanimtrigger
  101. #include "console/engineAPI.h"
  102.  
  103. void custom_animtriggercall(U32 object_id, String sequence_name, U32 trigger_number, bool trigger_state)
  104. {
  105. //enter point to torquescript
  106. //Note that the function "customanimtrigger" should be defined somewhere inside a torquescript .cs
  107. //object_id id of that server object
  108. //sequence_name name of the sequence of the trigger
  109. //trigger_number number of the trigger calling this
  110. //trigger_state state of the trigger calling this
  111. if ( Con::isFunction( "custom_animtriggercall" ) )
  112. Con::executef("custom_animtriggercall",object_id,sequence_name,trigger_number,trigger_state);
  113. }
  114.  
  115.  
  116. 11. Finally we only need to add in torquescript somewhere a function like:
  117.  
  118. // Function that handles animation triggers
  119. function custom_animtriggercall(%objectidA, %sequencenameA, %triggernumberA, %triggerstateA)
  120. {
  121. //code goes here;
  122. //echo("object=" @ %objectnameA @ "-");
  123. echo("object=" @ %objectidA.getName() @ "-");
  124. echo("objectid=" @ %objectidA @ "-");
  125. echo("sequence=" @ %sequencenameA @ "-");
  126. echo("triggernumber=" @ %triggernumberA @ "-");
  127. echo("triggerstate=" @ %triggerstateA @ "-");
  128. echo("\n");
  129.  
  130. }
  131.  
  132.  
  133. Note: Triggers in the last frame may not be called (use lastframe-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement