Gvactor.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. //---------------------------------------------------------------------------
  2. //
  3. // gvactor.h - This file contains the header for the Ground Vehicle Actor class
  4. //
  5. // MechCommander 2
  6. //
  7. //---------------------------------------------------------------------------//
  8. // Copyright (C) Microsoft Corporation. All rights reserved. //
  9. //===========================================================================//
  10. #ifndef GVACTOR_H
  11. #define GVACTOR_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. #include <gosFX\gosfxheaders.hpp>
  27. //**************************************************************************************
  28. #ifndef NO_ERR
  29. #define NO_ERR 0
  30. #endif
  31. #define GV_PART_BODY 0
  32. #define GV_PART_TURRET 1
  33. #define NUM_GV_PARTS 2
  34. #define MAX_GV_ANIMATIONS 10
  35. //***********************************************************************
  36. //
  37. // GVAppearanceType
  38. //
  39. //***********************************************************************
  40. class GVAppearanceType : public AppearanceType
  41. {
  42. public:
  43. TG_TypeMultiShapePtr gvShape[MAX_LODS];
  44. float lodDistance[MAX_LODS];
  45. TG_TypeMultiShapePtr gvShadowShape;
  46. TG_TypeMultiShapePtr gvDmgShape;
  47. char destructEffect[60];
  48. TG_AnimateShapePtr gvAnimData[MAX_GV_ANIMATIONS];
  49. bool gvAnimLoop[MAX_GV_ANIMATIONS];
  50. bool gvReverse[MAX_GV_ANIMATIONS];
  51. bool gvRandom[MAX_GV_ANIMATIONS];
  52. long gvStartF[MAX_GV_ANIMATIONS];
  53. char rotationalNodeId[TG_NODE_ID];
  54. long numSmokeNodes; //Where damage smoke comes from.
  55. long numWeaponNodes; //Where weapons fire from.
  56. long numFootNodes; //Where dust trail, contrail comes out of.
  57. NodeData *nodeData;
  58. static TG_TypeMultiShapePtr SensorTriangleShape;
  59. static TG_TypeMultiShapePtr SensorCircleShape;
  60. public:
  61. void init (void)
  62. {
  63. long i=0;
  64. for (i=0;i<MAX_LODS;i++)
  65. {
  66. gvShape[i] = NULL;
  67. lodDistance[i] = 0.0f;
  68. }
  69. gvShadowShape = NULL;
  70. gvDmgShape = NULL;
  71. for (i=0;i<MAX_GV_ANIMATIONS;i++)
  72. {
  73. gvAnimData[i] = NULL;
  74. gvAnimLoop[i] = false;
  75. gvReverse[i] = false;
  76. gvRandom[i] = false;
  77. gvStartF[i] = 0;
  78. }
  79. destructEffect[0] = 0;
  80. }
  81. GVAppearanceType (void)
  82. {
  83. init();
  84. }
  85. ~GVAppearanceType (void)
  86. {
  87. destroy();
  88. }
  89. virtual void init (char *fileName);
  90. virtual void destroy (void);
  91. void setAnimation (TG_MultiShapePtr shape, DWORD animationNum);
  92. long getNumFrames (long animationNum)
  93. {
  94. if ((animationNum >= 0) && (animationNum < MAX_GV_ANIMATIONS) && (gvAnimData[animationNum]))
  95. return gvAnimData[animationNum]->GetNumFrames();
  96. return 0.0f;
  97. }
  98. float getFrameRate (long animationNum)
  99. {
  100. if ((animationNum >= 0) && (animationNum < MAX_GV_ANIMATIONS) && (gvAnimData[animationNum]))
  101. return gvAnimData[animationNum]->GetFrameRate();
  102. return 0.0f;
  103. }
  104. bool isReversed (long animationNum)
  105. {
  106. if ((animationNum >= 0) && (animationNum < MAX_GV_ANIMATIONS) && (gvAnimData[animationNum]))
  107. return gvReverse[animationNum];
  108. return false;
  109. }
  110. bool isLooped (long animationNum)
  111. {
  112. if ((animationNum >= 0) && (animationNum < MAX_GV_ANIMATIONS) && (gvAnimData[animationNum]))
  113. return gvAnimLoop[animationNum];
  114. return false;
  115. }
  116. bool isRandom (long animationNum)
  117. {
  118. if ((animationNum >= 0) && (animationNum < MAX_GV_ANIMATIONS) && (gvAnimData[animationNum]))
  119. return gvRandom[animationNum];
  120. return false;
  121. }
  122. long getTotalNodes (void)
  123. {
  124. return numSmokeNodes + numWeaponNodes + numFootNodes;
  125. }
  126. };
  127. //***********************************************************************
  128. //
  129. // GVAppearance
  130. //
  131. //***********************************************************************
  132. class GVAppearance : public ObjectAppearance
  133. {
  134. public:
  135. GVAppearanceType* appearType;
  136. TG_MultiShapePtr gvShape;
  137. TG_MultiShapePtr gvShadowShape;
  138. TG_MultiShapePtr sensorCircleShape;
  139. TG_MultiShapePtr sensorTriangleShape;
  140. float sensorSpin;
  141. long objectNameId;
  142. float turretRotation;
  143. float pitch;
  144. float roll;
  145. float actualTurretRotation;
  146. float velocityMagnitude;
  147. bool inDebugMoveMode;
  148. long sensorLevel;
  149. float hazeFactor;
  150. long status;
  151. gosFX::Effect *destructFX;
  152. gosFX::Effect *waterWake;
  153. gosFX::Effect *dustCloud;
  154. gosFX::Effect *activity;
  155. bool isWaking;
  156. bool isActivitying;
  157. bool movedThisFrame;
  158. bool dustCloudStart;
  159. float OBBRadius;
  160. long gvAnimationState;
  161. float currentFrame;
  162. float gvFrameRate;
  163. bool isReversed;
  164. bool isLooping;
  165. bool setFirstFrame;
  166. bool canTransition;
  167. bool isInfantry;
  168. long currentLOD;
  169. long *nodeUsed; //Used to stagger the weapon nodes for firing.
  170. float *nodeRecycle; //Used for ripple fire to find out if the node has fired recently.
  171. DWORD localTextureHandle;
  172. DWORD psRed;
  173. DWORD psBlue;
  174. DWORD psGreen;
  175. float flashDuration;
  176. float duration;
  177. float currentFlash;
  178. bool drawFlash;
  179. DWORD flashColor;
  180. long rotationalNodeIndex;
  181. long dustNodeIndex;
  182. long activityNodeIndex;
  183. long hitNodeId;
  184. long weaponNodeId[4];
  185. public:
  186. virtual void init (AppearanceTypePtr tree = NULL, GameObjectPtr obj = NULL);
  187. virtual AppearanceTypePtr getAppearanceType (void)
  188. {
  189. return appearType;
  190. }
  191. GVAppearance (void)
  192. {
  193. init();
  194. }
  195. virtual long update (bool animate = true);
  196. void updateGeometry (void);
  197. virtual long render (long depthFixup = 0);
  198. virtual long renderShadows (void);
  199. virtual void destroy (void);
  200. virtual unsigned long getAppearanceClass (void)
  201. {
  202. return VEHICLE_APPR_TYPE;
  203. }
  204. ~GVAppearance (void)
  205. {
  206. destroy();
  207. }
  208. virtual void setPaintScheme (void);
  209. virtual void setPaintScheme (DWORD red, DWORD green, DWORD blue);
  210. virtual void getPaintScheme (DWORD &red, DWORD &green, DWORD &blue);
  211. virtual void resetPaintScheme (DWORD red, DWORD green, DWORD blue);
  212. virtual bool recalcBounds (void);
  213. virtual void flashBuilding (float duration, float flashDuration, DWORD color);
  214. void setFadeTable (MemoryPtr fTable)
  215. {
  216. fadeTable = fTable;
  217. }
  218. virtual void setObjectNameId (long objId)
  219. {
  220. objectNameId = objId;
  221. }
  222. virtual bool isMouseOver (float px, float py);
  223. virtual void setObjectParameters (Stuff::Vector3D &pos, float rot, long selected, long team, long homeRelations);
  224. virtual void setMoverParameters (float turretRot, float lArmRot = 0.0f, float rArmRot = 0.0f, bool isAirborne = false);
  225. void debugUpdate (void);
  226. virtual void setSensorLevel (long lvl)
  227. {
  228. sensorLevel = lvl;
  229. }
  230. virtual void setObjStatus (long oStatus);
  231. virtual bool playDestruction (void);
  232. virtual bool getInTransition (void)
  233. {
  234. return (canTransition == false);
  235. }
  236. virtual void setGesture (unsigned long gestureId);
  237. virtual long getCurrentGestureId (void)
  238. {
  239. return gvAnimationState;
  240. }
  241. //--------------------------------------------
  242. // Once site Objects are in place, go get 'em
  243. virtual void setWeaponNodeUsed (long nodeId);
  244. virtual Stuff::Vector3D getWeaponNodePosition (long nodeId);
  245. virtual Stuff::Vector3D getSmokeNodePosition (long nodeId);
  246. virtual Stuff::Vector3D getDustNodePosition (long nodeId);
  247. virtual long getWeaponNode (long weapontype);
  248. virtual float getWeaponNodeRecycle (long node);
  249. virtual long getLowestWeaponNode (void);
  250. virtual Stuff::Vector3D getNodeNamePosition (char *nodeName);
  251. virtual bool PerPolySelect (long mouseX, long mouseY);
  252. virtual Stuff::Point3D getRootNodeCenter (void)
  253. {
  254. Stuff::Point3D result = gvShape->GetRootNodeCenter();
  255. return result;
  256. }
  257. virtual void setAlphaValue (BYTE aVal)
  258. {
  259. gvShape->SetAlphaValue(aVal);
  260. //Sensor shape fades in opposite direction from mover
  261. sensorCircleShape->SetAlphaValue(0xff - aVal);
  262. sensorTriangleShape->SetAlphaValue(0xff - aVal);
  263. }
  264. virtual void scale (float scaleFactor)
  265. {
  266. gvShape->ScaleShape(scaleFactor);
  267. }
  268. virtual void startWaterWake (void);
  269. virtual void stopWaterWake (void);
  270. virtual void startActivity (long effectId, bool loop);
  271. virtual void stopActivity (void);
  272. virtual Stuff::Vector3D getNodeIdPosition (long nodeId);
  273. virtual Stuff::Vector3D getHitNode (void);
  274. };
  275. //***************************************************************************
  276. #endif