bdactor.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. //---------------------------------------------------------------------------
  2. //
  3. // dbactor.h - This file contains the header for the Static ground object appearance class
  4. //
  5. // MechCommander 2
  6. //
  7. //---------------------------------------------------------------------------//
  8. // Copyright (C) Microsoft Corporation. All rights reserved. //
  9. //===========================================================================//
  10. #ifndef BDACTOR_H
  11. #define BDACTOR_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 MOVE_H
  21. #include "move.h"
  22. #endif
  23. #ifndef MSL_H
  24. #include "msl.h"
  25. #endif
  26. #ifndef OBJECTAPPEARANCE_H
  27. #include "ObjectAppearance.h"
  28. #endif
  29. #include <gosFX\gosfxheaders.hpp>
  30. //**************************************************************************************
  31. #ifndef NO_ERR
  32. #define NO_ERR 0
  33. #endif
  34. #define MAX_BD_ANIMATIONS 10
  35. //***********************************************************************
  36. //
  37. // BldgAppearanceType
  38. //
  39. //***********************************************************************
  40. class BldgAppearanceType : public AppearanceType
  41. {
  42. public:
  43. TG_TypeMultiShapePtr bldgShape[MAX_LODS];
  44. float lodDistance[MAX_LODS];
  45. TG_TypeMultiShapePtr bldgShadowShape;
  46. TG_TypeMultiShapePtr bldgDmgShape;
  47. TG_TypeMultiShapePtr bldgDmgShadowShape;
  48. TG_AnimateShapePtr bdAnimData[MAX_BD_ANIMATIONS];
  49. bool bdAnimLoop[MAX_BD_ANIMATIONS];
  50. bool bdReverse[MAX_BD_ANIMATIONS];
  51. bool bdRandom[MAX_BD_ANIMATIONS];
  52. long bdStartF[MAX_BD_ANIMATIONS];
  53. char rotationalNodeId[TG_NODE_ID];
  54. char destructEffect[60];
  55. bool spinMe;
  56. bool isForestClump;
  57. DWORD terrainLightRGB;
  58. float terrainLightIntensity;
  59. float terrainLightInnerRadius;
  60. float terrainLightOuterRadius;
  61. long numWeaponNodes;
  62. NodeData *nodeData;
  63. public:
  64. void init (void)
  65. {
  66. long i=0;
  67. for (i=0;i<MAX_LODS;i++)
  68. {
  69. bldgShape[i] = NULL;
  70. lodDistance[i] = 0.0f;
  71. }
  72. bldgShadowShape = NULL;
  73. bldgDmgShape = NULL;
  74. bldgDmgShadowShape = NULL;
  75. for (i=0;i<MAX_BD_ANIMATIONS;i++)
  76. bdAnimData[i] = NULL;
  77. destructEffect[0] = 0;
  78. spinMe = false;
  79. }
  80. BldgAppearanceType (void)
  81. {
  82. init();
  83. }
  84. ~BldgAppearanceType (void)
  85. {
  86. destroy();
  87. }
  88. void setAnimation (TG_MultiShapePtr shape, DWORD animationNum);
  89. long getNumFrames (long animationNum)
  90. {
  91. if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
  92. return bdAnimData[animationNum]->GetNumFrames();
  93. return 0.0f;
  94. }
  95. float getFrameRate (long animationNum)
  96. {
  97. if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
  98. return bdAnimData[animationNum]->GetFrameRate();
  99. return 0.0f;
  100. }
  101. void setFrameRate (long animationNum, float nFrameRate)
  102. {
  103. if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
  104. bdAnimData[animationNum]->SetFrameRate(nFrameRate);
  105. }
  106. bool isReversed (long animationNum)
  107. {
  108. if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
  109. return bdReverse[animationNum];
  110. return false;
  111. }
  112. bool isLooped (long animationNum)
  113. {
  114. if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
  115. return bdAnimLoop[animationNum];
  116. return false;
  117. }
  118. bool isRandom (long animationNum)
  119. {
  120. if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
  121. return bdRandom[animationNum];
  122. return false;
  123. }
  124. virtual void init (char *fileName);
  125. virtual void destroy (void);
  126. };
  127. //***********************************************************************
  128. //
  129. // BldgAppearance
  130. //
  131. //***********************************************************************
  132. class BldgAppearance : public ObjectAppearance
  133. {
  134. public:
  135. BldgAppearanceType* appearType;
  136. TG_MultiShapePtr bldgShape;
  137. TG_MultiShapePtr bldgShadowShape;
  138. long bdAnimationState;
  139. float currentFrame;
  140. float bdFrameRate;
  141. bool isReversed;
  142. bool isLooping;
  143. bool setFirstFrame;
  144. bool canTransition;
  145. float turretYaw;
  146. float turretPitch;
  147. float hazeFactor;
  148. long status;
  149. gosFX::Effect *destructFX;
  150. gosFX::Effect *activity;
  151. gosFX::Effect *activity1;
  152. bool isActivitying;
  153. float OBBRadius;
  154. float highZ;
  155. float SpinAngle;
  156. float flashDuration;
  157. float duration;
  158. float currentFlash;
  159. bool drawFlash;
  160. DWORD flashColor;
  161. long currentLOD;
  162. long *nodeUsed; //Used to stagger the weapon nodes for firing.
  163. float *nodeRecycle; //Used for ripple fire to find out if the node has fired recently.
  164. TG_LightPtr pointLight;
  165. DWORD lightId;
  166. bool forceLightsOut;
  167. bool beenInView;
  168. bool fogLightSet;
  169. DWORD lightRGB;
  170. DWORD fogRGB;
  171. long rotationalNodeId;
  172. long hitNodeId;
  173. long activityNodeId;
  174. long activityNode1Id;
  175. public:
  176. virtual void init (AppearanceTypePtr tree = NULL, GameObjectPtr obj = NULL);
  177. virtual AppearanceTypePtr getAppearanceType (void)
  178. {
  179. return appearType;
  180. }
  181. BldgAppearance (void)
  182. {
  183. init();
  184. }
  185. virtual long update (bool animate = true);
  186. virtual long render (long depthFixup = 0);
  187. virtual long renderShadows (void);
  188. virtual void destroy (void);
  189. ~BldgAppearance (void)
  190. {
  191. destroy();
  192. }
  193. virtual bool recalcBounds (void);
  194. virtual bool getInTransition (void)
  195. {
  196. return (canTransition == false);
  197. }
  198. void setFadeTable (MemoryPtr fTable)
  199. {
  200. fadeTable = fTable;
  201. }
  202. virtual void setGesture (unsigned long gestureId);
  203. virtual long getCurrentGestureId (void)
  204. {
  205. return bdAnimationState;
  206. }
  207. virtual unsigned long getAppearanceClass (void)
  208. {
  209. return BUILDING_APPR_TYPE;
  210. }
  211. virtual void setObjectNameId (long objId)
  212. {
  213. objectNameId = objId;
  214. }
  215. virtual bool isMouseOver (float px, float py);
  216. virtual void setObjectParameters (Stuff::Vector3D &pos, float rot, long selected, long alignment, long homeRelations);
  217. virtual void setMoverParameters (float turretRot, float lArmRot = 0.0f, float rArmRot = 0.0f, bool isAirborne = false);
  218. virtual void setObjStatus (long oStatus);
  219. virtual long calcCellsCovered (Stuff::Vector3D& pos, short* cellList);
  220. virtual void markTerrain(_ScenarioMapCellInfo* pInfo, int type, int counter);
  221. virtual long markMoveMap (bool passable, long* lineOfSightRect, bool useheight = false, short* cellList = NULL);
  222. virtual void markLOS (bool clearIt = false);
  223. void calcAdjCell (long& row, long& col);
  224. virtual void scale (float scaleFactor)
  225. {
  226. bldgShape->ScaleShape(scaleFactor);
  227. }
  228. virtual bool playDestruction (void);
  229. virtual float getRadius (void)
  230. {
  231. return OBBRadius;
  232. }
  233. virtual void flashBuilding (float duration, float flashDuration, DWORD color);
  234. virtual float getTopZ (void)
  235. {
  236. return highZ;
  237. }
  238. virtual void setWeaponNodeUsed (long nodeId);
  239. virtual long getWeaponNode (long weapontype);
  240. virtual float getWeaponNodeRecycle (long node);
  241. virtual Stuff::Vector3D getWeaponNodePosition (long node);
  242. virtual bool isSelectable()
  243. {
  244. return !appearType->spinMe;
  245. }
  246. virtual void setFilterState (bool state)
  247. {
  248. bldgShape->GetMultiType()->SetFilter(state);
  249. }
  250. virtual void setIsHudElement (void)
  251. {
  252. bldgShape->SetIsHudElement();
  253. }
  254. virtual bool getIsLit (void)
  255. {
  256. return (appearType->terrainLightRGB != 0xffffffff);
  257. }
  258. virtual void setLightsOut (bool lightFlag)
  259. {
  260. forceLightsOut = lightFlag;
  261. }
  262. virtual bool PerPolySelect (long mouseX, long mouseY);
  263. virtual bool isForestClump (void)
  264. {
  265. return appearType->isForestClump;
  266. }
  267. virtual Stuff::Point3D getRootNodeCenter (void)
  268. {
  269. Stuff::Point3D result = bldgShape->GetRootNodeCenter();
  270. return result;
  271. }
  272. virtual Stuff::Vector3D getNodeNamePosition (char *nodeName);
  273. virtual void startActivity (long effectId, bool loop);
  274. virtual void stopActivity (void);
  275. virtual Stuff::Vector3D getHitNode (void);
  276. virtual bool hasAnimationData (long gestureId)
  277. {
  278. return (appearType->bdAnimData[gestureId] != NULL);
  279. }
  280. virtual Stuff::Vector3D getNodeIdPosition (long nodeId);
  281. };
  282. //***************************************************************************
  283. //***********************************************************************
  284. //
  285. // TreeAppearanceType
  286. //
  287. //***********************************************************************
  288. class TreeAppearanceType : public AppearanceType
  289. {
  290. public:
  291. TG_TypeMultiShapePtr treeShape[MAX_LODS];
  292. float lodDistance[MAX_LODS];
  293. TG_TypeMultiShapePtr treeShadowShape;
  294. TG_TypeMultiShapePtr treeDmgShape;
  295. TG_TypeMultiShapePtr treeDmgShadowShape;
  296. TG_AnimateShapePtr treeAnimData[MAX_BD_ANIMATIONS];
  297. bool isForestClump;
  298. public:
  299. void init (void)
  300. {
  301. long i=0;
  302. for (i=0;i<MAX_LODS;i++)
  303. {
  304. treeShape[i] = NULL;
  305. lodDistance[i] = 0.0f;
  306. }
  307. for (i=0;i<MAX_BD_ANIMATIONS;i++)
  308. treeAnimData[i] = NULL;
  309. treeShadowShape = NULL;
  310. treeDmgShape = NULL;
  311. treeDmgShadowShape = NULL;
  312. }
  313. TreeAppearanceType (void)
  314. {
  315. init();
  316. }
  317. ~TreeAppearanceType (void)
  318. {
  319. destroy();
  320. }
  321. virtual void init (char *fileName);
  322. virtual void destroy (void);
  323. };
  324. //***********************************************************************
  325. //
  326. // TreeAppearance
  327. //
  328. //***********************************************************************
  329. class TreeAppearance : public ObjectAppearance
  330. {
  331. public:
  332. TreeAppearanceType* appearType;
  333. TG_MultiShapePtr treeShape;
  334. TG_MultiShapePtr treeShadowShape;
  335. float hazeFactor;
  336. float pitch;
  337. float yaw;
  338. long status;
  339. float OBBRadius;
  340. long currentLOD;
  341. bool forceLightsOut;
  342. bool beenInView;
  343. bool fogLightSet;
  344. DWORD lightRGB;
  345. DWORD fogRGB;
  346. public:
  347. virtual void init (AppearanceTypePtr tree = NULL, GameObjectPtr obj = NULL);
  348. virtual AppearanceTypePtr getAppearanceType (void)
  349. {
  350. return appearType;
  351. }
  352. TreeAppearance (void)
  353. {
  354. init();
  355. }
  356. virtual long update (bool animate = true);
  357. virtual long render (long depthFixup = 0);
  358. virtual long renderShadows (void);
  359. virtual void destroy (void);
  360. ~TreeAppearance (void)
  361. {
  362. destroy();
  363. }
  364. virtual unsigned long getAppearanceClass (void)
  365. {
  366. return TREE_APPR_TYPE;
  367. }
  368. virtual bool recalcBounds (void);
  369. void setFadeTable (MemoryPtr fTable)
  370. {
  371. fadeTable = fTable;
  372. }
  373. virtual void setObjectNameId (long objId)
  374. {
  375. objectNameId = objId;
  376. }
  377. virtual bool isMouseOver (float px, float py);
  378. virtual void setObjectParameters (Stuff::Vector3D &pos, float rot, long selected, long alignment, long homeRelations);
  379. virtual void setMoverParameters (float pitchAngle, float lArmRot = 0.0f, float rArmRot = 0.0f, bool isAirborne = false);
  380. virtual void setObjStatus (long oStatus);
  381. virtual void scale (float scaleFactor)
  382. {
  383. treeShape->ScaleShape(scaleFactor);
  384. }
  385. virtual float getRadius (void)
  386. {
  387. return OBBRadius;
  388. }
  389. virtual void setLightsOut (bool lightFlag)
  390. {
  391. forceLightsOut = lightFlag;
  392. }
  393. virtual bool isForestClump (void)
  394. {
  395. return appearType->isForestClump;
  396. }
  397. virtual void markTerrain(_ScenarioMapCellInfo* pInfo, int type, int counter);
  398. virtual Stuff::Point3D getRootNodeCenter (void)
  399. {
  400. Stuff::Point3D result = treeShape->GetRootNodeCenter();
  401. return result;
  402. }
  403. virtual void markLOS (bool clearIt = false);
  404. };
  405. //***************************************************************************
  406. #endif