genactor.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. //---------------------------------------------------------------------------
  2. //
  3. // Genactor.h - This file contains the header for the generic 3D appearance class
  4. //
  5. // MechCommander 2
  6. //
  7. //---------------------------------------------------------------------------//
  8. // Copyright (C) Microsoft Corporation. All rights reserved. //
  9. //===========================================================================//
  10. #ifndef GENACTOR_H
  11. #define GENACTOR_H
  12. //---------------------------------------------------------------------------
  13. // Include files
  14. #ifndef APPEAR_H
  15. #include "appear.h"
  16. #endif
  17. #ifndef APPRTYPE_H
  18. #include "apprtype.h"
  19. #endif
  20. #ifndef MSL_H
  21. #include "msl.h"
  22. #endif
  23. #ifndef OBJECTAPPEARANCE_H
  24. #include "ObjectAppearance.h"
  25. #endif
  26. //**************************************************************************************
  27. #ifndef NO_ERR
  28. #define NO_ERR 0
  29. #endif
  30. #define MAX_GEN_ANIMATIONS 5
  31. //***********************************************************************
  32. //
  33. // GenericAppearanceType
  34. //
  35. //***********************************************************************
  36. class GenericAppearanceType : public AppearanceType
  37. {
  38. public:
  39. TG_TypeMultiShapePtr genShape;
  40. TG_TypeMultiShapePtr genDmgShape;
  41. TG_AnimateShapePtr genAnimData[MAX_GEN_ANIMATIONS];
  42. bool genAnimLoop[MAX_GEN_ANIMATIONS];
  43. bool genReverse[MAX_GEN_ANIMATIONS];
  44. bool genRandom[MAX_GEN_ANIMATIONS];
  45. long genStartF[MAX_GEN_ANIMATIONS];
  46. char rotationalNodeId[TG_NODE_ID];
  47. char textureName[50];
  48. DWORD dotRGB;
  49. public:
  50. void init (void)
  51. {
  52. genShape = NULL;
  53. for (long i=0;i<MAX_GEN_ANIMATIONS;i++)
  54. genAnimData[i] = NULL;
  55. textureName[0] = 0;
  56. dotRGB = 0x00ffffff;
  57. }
  58. GenericAppearanceType (void)
  59. {
  60. init();
  61. }
  62. ~GenericAppearanceType (void)
  63. {
  64. destroy();
  65. }
  66. void setAnimation (TG_MultiShapePtr shape, DWORD animationNum);
  67. long getNumFrames (long animationNum)
  68. {
  69. if ((animationNum >= 0) && (animationNum < MAX_GEN_ANIMATIONS) && (genAnimData[animationNum]))
  70. return genAnimData[animationNum]->GetNumFrames();
  71. return 0.0f;
  72. }
  73. float getFrameRate (long animationNum)
  74. {
  75. if ((animationNum >= 0) && (animationNum < MAX_GEN_ANIMATIONS) && (genAnimData[animationNum]))
  76. return genAnimData[animationNum]->GetFrameRate();
  77. return 0.0f;
  78. }
  79. bool isReversed (long animationNum)
  80. {
  81. if ((animationNum >= 0) && (animationNum < MAX_GEN_ANIMATIONS) && (genAnimData[animationNum]))
  82. return genReverse[animationNum];
  83. return false;
  84. }
  85. bool isLooped (long animationNum)
  86. {
  87. if ((animationNum >= 0) && (animationNum < MAX_GEN_ANIMATIONS) && (genAnimData[animationNum]))
  88. return genAnimLoop[animationNum];
  89. return false;
  90. }
  91. bool isRandom (long animationNum)
  92. {
  93. if ((animationNum >= 0) && (animationNum < MAX_GEN_ANIMATIONS) && (genAnimData[animationNum]))
  94. return genRandom[animationNum];
  95. return false;
  96. }
  97. virtual void init (char *fileName);
  98. virtual void destroy (void);
  99. };
  100. //***********************************************************************
  101. //
  102. // GenericAppearance
  103. //
  104. //***********************************************************************
  105. class GenericAppearance : public ObjectAppearance
  106. {
  107. public:
  108. GenericAppearanceType* appearType;
  109. TG_MultiShapePtr genShape;
  110. long genAnimationState;
  111. float currentFrame;
  112. float genFrameRate;
  113. bool isReversed;
  114. bool isLooping;
  115. bool setFirstFrame;
  116. bool canTransition;
  117. float hazeFactor;
  118. float pitch;
  119. long status;
  120. float OBBRadius;
  121. long skyNumber;
  122. public:
  123. virtual void init (AppearanceTypePtr tree = NULL, GameObjectPtr obj = NULL);
  124. virtual AppearanceTypePtr getAppearanceType (void)
  125. {
  126. return appearType;
  127. }
  128. void changeSkyToSkyNum (char *txmName, char *newName);
  129. GenericAppearance (void)
  130. {
  131. init();
  132. }
  133. virtual long update (bool animate = true);
  134. virtual long render (long depthFixup = 0);
  135. virtual long renderShadows (void);
  136. virtual void destroy (void);
  137. ~GenericAppearance (void)
  138. {
  139. destroy();
  140. }
  141. virtual bool recalcBounds (void);
  142. virtual bool getInTransition (void)
  143. {
  144. return (canTransition == false);
  145. }
  146. virtual void setGesture (unsigned long gestureId);
  147. virtual long getCurrentGestureId (void)
  148. {
  149. return genAnimationState;
  150. }
  151. virtual unsigned long getAppearanceClass (void)
  152. {
  153. return GENERIC_APPR_TYPE;
  154. }
  155. virtual void setObjectNameId (long objId)
  156. {
  157. objectNameId = objId;
  158. }
  159. virtual bool isMouseOver (float px, float py);
  160. virtual void setObjectParameters (Stuff::Vector3D &pos, float rot, long selected, long alignment, long homeRelations);
  161. virtual void setMoverParameters (float turretRot, float lArmRot = 0.0f, float rArmRot = 0.0f, bool isAirborne = false);
  162. virtual void setObjStatus (long oStatus);
  163. virtual void markTerrain (_ScenarioMapCellInfo* pInfo, int type, int counter);
  164. virtual void markMoveMap (bool passable);
  165. virtual void setIsHudElement (void)
  166. {
  167. genShape->SetIsHudElement();
  168. }
  169. virtual void scale (float scaleFactor)
  170. {
  171. genShape->ScaleShape(scaleFactor);
  172. }
  173. virtual Stuff::Point3D getRootNodeCenter (void)
  174. {
  175. Stuff::Point3D result = genShape->GetRootNodeCenter();
  176. return result;
  177. }
  178. virtual void setSkyNumber (long skyNum);
  179. };
  180. //***************************************************************************
  181. #endif