item3d.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // item3d.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 03/06/97 JMI Started this 3D item class.
  23. //
  24. // 03/06/97 JMI Overrided EditModify().
  25. //
  26. // 03/06/97 JMI Added m_u16IdParent member and override for Render().
  27. //
  28. // 03/06/97 JMI Added Trumpet, Horn, and Sax and descriptions for known
  29. // types.
  30. //
  31. // 03/07/97 JMI Added handy everything-to-get-started Setup().
  32. //
  33. // 03/13/97 JMI Load now takes a version number.
  34. //
  35. // 03/17/97 JMI Now based on CThing3d instead of CCharacter.
  36. //
  37. // 03/18/97 JMI Made ItemType and instantiable members public.
  38. // Also, moved m_u16IdParent into base class.
  39. // Also, removed Render() proto.
  40. //
  41. // 06/14/97 JMI Added a constructor that will allow derivations of this
  42. // class.
  43. //
  44. // 08/07/97 JMI Added ability to optionally load a rigid body and child
  45. // anim for this item3d.
  46. //
  47. ////////////////////////////////////////////////////////////////////////////////
  48. #ifndef ITEM3D_H
  49. #define ITEM3D_H
  50. #include "RSPiX.h"
  51. #include "character.h"
  52. class CItem3d : public CThing3d
  53. {
  54. //---------------------------------------------------------------------------
  55. // Types, enums, etc.
  56. //---------------------------------------------------------------------------
  57. public:
  58. typedef enum // Items.
  59. {
  60. None, // No current type. Must be 0.
  61. Custom, // A type whose name is stored in m_szAnimBaseName[].
  62. Trumpet,
  63. Horn,
  64. Sax,
  65. // Add new item enums above this line.
  66. NumTypes
  67. } ItemType;
  68. //---------------------------------------------------------------------------
  69. // Variables
  70. //---------------------------------------------------------------------------
  71. public:
  72. CAnim3D m_anim; // One animation.
  73. char m_szAnimBaseName[RSP_MAX_PATH]; // Name of animation.
  74. ItemType m_type; // Item type if known.
  75. char m_szAnimRigidName[RSP_MAX_PATH]; // Rigid body transform anim name.
  76. CAnim3D m_animChild; // Optional child anim.
  77. char m_szChildAnimBaseName[RSP_MAX_PATH]; // Name of child anim.
  78. CSprite3 m_spriteChild; // Child sprite. Never
  79. // explicitly added to scene
  80. // (acts just as a child to
  81. // our main sprite).
  82. // Tracks file counter so we know when to load/save "common" data
  83. static short ms_sFileCount;
  84. //---------------------------------------------------------------------------
  85. // Static Variables
  86. //---------------------------------------------------------------------------
  87. public:
  88. // "Constant" values that we want to be able to tune using the editor
  89. // Array of known animation base names.
  90. static char* ms_apszKnownAnimBaseNames[NumTypes];
  91. static char* ms_apszKnownAnimDescriptions[NumTypes];
  92. //---------------------------------------------------------------------------
  93. // Constructor(s) / destructor
  94. //---------------------------------------------------------------------------
  95. protected:
  96. // Constructor
  97. CItem3d(CRealm* pRealm)
  98. : CThing3d(pRealm, CItem3dID)
  99. {
  100. Reset();
  101. }
  102. // Constructor
  103. CItem3d(CRealm* pRealm, ClassIDType id)
  104. : CThing3d(pRealm, id)
  105. {
  106. Reset();
  107. }
  108. // Reset this object.
  109. void Reset(void) // Returns nothing.
  110. {
  111. m_szAnimBaseName[0] = '\0';
  112. m_type = None;
  113. m_szAnimRigidName[0] = '\0';
  114. m_szChildAnimBaseName[0] = '\0';
  115. m_spriteChild.m_pthing = this;
  116. }
  117. public:
  118. // Destructor
  119. ~CItem3d()
  120. {
  121. // Kill item3d
  122. Kill();
  123. }
  124. //---------------------------------------------------------------------------
  125. // Required static functions
  126. //---------------------------------------------------------------------------
  127. public:
  128. // Construct object
  129. static short Construct( // Returns 0 if successfull, non-zero otherwise
  130. CRealm* pRealm, // In: Pointer to realm this object belongs to
  131. CThing** ppNew) // Out: Pointer to new object
  132. {
  133. short sResult = 0;
  134. *ppNew = new CItem3d(pRealm);
  135. if (*ppNew == 0)
  136. {
  137. sResult = -1;
  138. TRACE("CItem3d::Construct(): Couldn't construct CItem3d!\n");
  139. }
  140. return sResult;
  141. }
  142. //---------------------------------------------------------------------------
  143. // Required virtual functions (implimenting them as inlines doesn't pay!)
  144. //---------------------------------------------------------------------------
  145. public:
  146. // Load object (should call base class version!)
  147. short Load( // Returns 0 if successfull, non-zero otherwise
  148. RFile* pFile, // In: File to load from
  149. bool bEditMode, // In: True for edit mode, false otherwise
  150. short sFileCount, // In: File count (unique per file, never 0)
  151. ULONG ulFileVersion); // In: Version of file format to load.
  152. // Save object (should call base class version!)
  153. short Save( // Returns 0 if successfull, non-zero otherwise
  154. RFile* pFile, // In: File to save to
  155. short sFileCount); // In: File count (unique per file, never 0)
  156. // Update object
  157. void Update(void);
  158. // Render object
  159. void Render(void); // Returns nothing.
  160. // Called by editor to init new object at specified position
  161. short EditNew( // Returns 0 if successfull, non-zero otherwise
  162. short sX, // In: New x coord
  163. short sY, // In: New y coord
  164. short sZ); // In: New z coord
  165. // Called by editor to modify object.
  166. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  167. //---------------------------------------------------------------------------
  168. // Other functions
  169. //---------------------------------------------------------------------------
  170. public:
  171. // Setup object after creating it
  172. virtual // Override to implement additional functionality.
  173. // Call base class to get default functionality.
  174. short Setup( // Returns 0 on success.
  175. short sX, // In: Starting X position
  176. short sY, // In: Starting Y position
  177. short sZ, // In: Starting Z position
  178. ItemType type, // In: Known item type or Custom.
  179. char* pszCustomBaseName = NULL, // In: Required if type == Custom.
  180. // Base name for custom type resources.
  181. U16 u16IdParentInstance = CIdBank::IdNil); // In: Parent instance ID.
  182. // Message handling functions ////////////////////////////////////////////
  183. // Handles a Shot_Message.
  184. virtual // Override to implement additional functionality.
  185. // Call base class to get default functionality.
  186. void OnShotMsg( // Returns nothing.
  187. Shot_Message* pshotmsg); // In: Message to handle.
  188. // Handles an Explosion_Message.
  189. virtual // Override to implement additional functionality.
  190. // Call base class to get default functionality.
  191. void OnExplosionMsg( // Returns nothing.
  192. Explosion_Message* pexplosionmsg); // In: Message to handle.
  193. // Handles a Burn_Message.
  194. virtual // Override to implement additional functionality.
  195. // Call base class to get default functionality.
  196. void OnBurnMsg( // Returns nothing.
  197. Burn_Message* pburnmsg); // In: Message to handle.
  198. // Handles an ObjectDelete_Message.
  199. virtual // Override to implement additional functionality.
  200. // Call base class to get default functionality.
  201. void OnDeleteMsg( // Returns nothing.
  202. ObjectDelete_Message* pdeletemsg); // In: Message to handle.
  203. //---------------------------------------------------------------------------
  204. // Internal functions
  205. //---------------------------------------------------------------------------
  206. protected:
  207. // Init item3d
  208. short Init(void); // Returns 0 if successfull, non-zero otherwise
  209. // Kill item3d
  210. void Kill(void);
  211. // Get all required resources
  212. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  213. // Free all resources
  214. void FreeResources(void);
  215. };
  216. #endif //ITEM3D_H
  217. ////////////////////////////////////////////////////////////////////////////////
  218. // EOF
  219. ////////////////////////////////////////////////////////////////////////////////