item3d.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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.cpp
  19. // Project: Nostril (aka Postal)
  20. //
  21. // This module impliments the CItem3d class, which is a simple one animationed
  22. // 3D object.
  23. //
  24. // History:
  25. // 03/06/97 JMI Started this 3D item class.
  26. //
  27. // 03/06/97 JMI EditModify() now allows you to pick or specify an anim.
  28. //
  29. // 03/06/97 JMI Fixed Custom selection in EditModify() dialog.
  30. //
  31. // 03/06/97 JMI Now loads parents instance ID and overrides Render().
  32. //
  33. // 03/06/97 JMI Added Trumpet, Horn, and Sax and descriptions for known
  34. // types.
  35. //
  36. // 03/07/97 JMI Added handy everything-to-get-started Setup().
  37. //
  38. // 03/12/97 JMI Update() now calculates the duration in seconds, updates
  39. // m_lPrevTime, and passes the duration to DeluxeUpdatePosVel.
  40. //
  41. // 03/13/97 JMI Load now takes a version number.
  42. //
  43. // 03/18/97 JMI Now based on CThing3d instead of CCharacter.
  44. //
  45. // 03/18/97 JMI Now processes State_BlownUp.
  46. //
  47. // 03/18/97 JMI EditModify() was not selecting the current item in the
  48. // listbox.
  49. // Also, removed Render() override.
  50. //
  51. // 03/18/97 JMI Forgot to set the parent instance ID to the one passed in
  52. // the Setup() function.
  53. //
  54. // 03/19/97 JMI m_lAnimTime was not being reset to 0 ever. Now it is set
  55. // in Init().
  56. //
  57. // 03/19/97 JMI Now starts object spinning around Y and Z when an explosive
  58. // force affects it and stops the spinning when WhileBlownUp()
  59. // returns false.
  60. //
  61. // 03/25/97 JMI Changed EDIT_GUI_FILE to 8.3 compliant name.
  62. //
  63. // 04/23/97 JMI Now sets its m_smash's bits to Misc instead of Item.
  64. //
  65. // 05/13/97 JMI Now FreeResources() checks to make sure we have some
  66. // some animation resources before Release()ing them.
  67. // This allows GetResources() to call FreeResources()
  68. // indiscriminantly before getting new resources.
  69. //
  70. // 06/09/97 JMI Added rotation velocities to EditModify().
  71. // Now saves these values as of FileVersion 18.
  72. //
  73. // 06/17/97 JMI Converted all occurrences of rand() to GetRand() and
  74. // srand() to SeedRand().
  75. //
  76. // 06/25/97 JMI Now calls PrepareShadow() in Init() which loads and sets up
  77. // a shadow sprite.
  78. //
  79. // 06/25/97 JMI Uses smaller shadow now....If we need multiple sizes later,
  80. // we can make an additional array.
  81. //
  82. // 07/09/97 JMI Now uses m_pRealm->Make2dResPath() to get the fullpath
  83. // for 2D image components.
  84. //
  85. // 08/07/97 JMI Added ability to optionally load a rigid body and child
  86. // anim for this item3d.
  87. //
  88. // 08/07/97 JMI Added additional parameter to CAnim3D::Get() call.
  89. //
  90. // 08/13/97 JMI EditModify() sets m_type to Custom if it is None.
  91. //
  92. // 08/28/97 JMI Now if a GetResources() fails, it removes the sprite from
  93. // the scene just in case it was already there. Also, only
  94. // call base class Render(), if there's loaded anim data.
  95. // The problem is that the EditModify() can fail b/c the
  96. // user's anim choice failed to load. In this case, we're
  97. // forced to persist without anim data. This will probably
  98. // cause the realm not to load, though, if saved in such a
  99. // state.
  100. //
  101. ////////////////////////////////////////////////////////////////////////////////
  102. #define ITEM3D_CPP
  103. #include "RSPiX.h"
  104. #include <math.h>
  105. #include "item3d.h"
  106. #include "reality.h"
  107. ////////////////////////////////////////////////////////////////////////////////
  108. // Macros/types/etc.
  109. ////////////////////////////////////////////////////////////////////////////////
  110. #define NUM_RES_NAMES 7
  111. #define EDIT_GUI_FILE "res/editor/Item3d.gui"
  112. #define SHADOW_RES_NAME "SmallShadow.img"
  113. #define LIST_BOX_ID 200
  114. #define RESNAME_EDIT_ID 100
  115. #define RIGID_RESNAME_EDIT_ID 101
  116. #define CHILD_RESNAME_EDIT_ID 102
  117. #define YROTVEL_EDIT_ID 300
  118. #define ZROTVEL_EDIT_ID 301
  119. ////////////////////////////////////////////////////////////////////////////////
  120. // Variables/data
  121. ////////////////////////////////////////////////////////////////////////////////
  122. // Let this auto-init to 0
  123. short CItem3d::ms_sFileCount;
  124. // Array of known animation base names.
  125. char* CItem3d::ms_apszKnownAnimBaseNames[CItem3d::NumTypes] =
  126. {
  127. "None", // None.
  128. "Custom", // Custom.
  129. "3d/Trumpet", // Trumpet.
  130. "3d/Horn", // Horn.
  131. "3d/Sax", // Sax.
  132. };
  133. // Array of known animation descriptions.
  134. char* CItem3d::ms_apszKnownAnimDescriptions[CItem3d::NumTypes] =
  135. {
  136. "None",
  137. "Custom",
  138. "Trumpet",
  139. "Horn",
  140. "Sax",
  141. };
  142. static char* ms_apszResExtensions[NUM_RES_NAMES] =
  143. {
  144. "sop",
  145. "mesh",
  146. "tex",
  147. "hot",
  148. "bounds",
  149. "floor",
  150. };
  151. ////////////////////////////////////////////////////////////////////////////////
  152. // Load object (should call base class version!)
  153. ////////////////////////////////////////////////////////////////////////////////
  154. short CItem3d::Load( // Returns 0 if successfull, non-zero otherwise
  155. RFile* pFile, // In: File to load from
  156. bool bEditMode, // In: True for edit mode, false otherwise
  157. short sFileCount, // In: File count (unique per file, never 0)
  158. ULONG ulFileVersion) // In: Version of file format to load.
  159. {
  160. short sResult = 0;
  161. // In most cases, the base class Load() should be called.
  162. sResult = CThing3d::Load(pFile, bEditMode, sFileCount, ulFileVersion);
  163. if (sResult == 0)
  164. {
  165. // Load common data just once per file (not with each object)
  166. if (ms_sFileCount != sFileCount)
  167. {
  168. ms_sFileCount = sFileCount;
  169. // Load static data
  170. switch (ulFileVersion)
  171. {
  172. default:
  173. case 1:
  174. break;
  175. }
  176. }
  177. // Load object data
  178. switch (ulFileVersion)
  179. {
  180. default:
  181. case 42:
  182. pFile->Read(m_szAnimRigidName);
  183. pFile->Read(m_szChildAnimBaseName);
  184. case 41:
  185. case 40:
  186. case 39:
  187. case 38:
  188. case 37:
  189. case 36:
  190. case 35:
  191. case 34:
  192. case 33:
  193. case 32:
  194. case 31:
  195. case 30:
  196. case 29:
  197. case 28:
  198. case 27:
  199. case 26:
  200. case 25:
  201. case 24:
  202. case 23:
  203. case 22:
  204. case 21:
  205. case 20:
  206. case 19:
  207. case 18:
  208. pFile->Read(&m_dExtRotVelY);
  209. pFile->Read(&m_dExtRotVelZ);
  210. case 17:
  211. case 16:
  212. case 15:
  213. case 14:
  214. case 13:
  215. case 12:
  216. case 11:
  217. case 10:
  218. case 9:
  219. case 8:
  220. case 7:
  221. case 6:
  222. case 5:
  223. case 4:
  224. case 3:
  225. case 2:
  226. case 1:
  227. pFile->Read(m_szAnimBaseName);
  228. U32 u32Temp;
  229. pFile->Read(&u32Temp);
  230. m_type = (ItemType)u32Temp;
  231. pFile->Read(&m_u16IdParent);
  232. break;
  233. }
  234. // Make sure there were no file errors or format errors . . .
  235. if (!pFile->Error() && sResult == 0)
  236. {
  237. // Init item3d
  238. sResult = Init();
  239. }
  240. else
  241. {
  242. sResult = -1;
  243. TRACE("CItem3d::Load(): Error reading from file!\n");
  244. }
  245. }
  246. else
  247. {
  248. TRACE("CItem3d::Load(): CThing3d::Load() failed.\n");
  249. }
  250. return sResult;
  251. }
  252. ////////////////////////////////////////////////////////////////////////////////
  253. // Save object (should call base class version!)
  254. ////////////////////////////////////////////////////////////////////////////////
  255. short CItem3d::Save( // Returns 0 if successfull, non-zero otherwise
  256. RFile* pFile, // In: File to save to
  257. short sFileCount) // In: File count (unique per file, never 0)
  258. {
  259. short sResult = 0;
  260. // In most cases, the base class Save() should be called.
  261. sResult = CThing3d::Save(pFile, sFileCount);
  262. if (sResult == 0)
  263. {
  264. // Save common data just once per file (not with each object)
  265. if (ms_sFileCount != sFileCount)
  266. {
  267. ms_sFileCount = sFileCount;
  268. // Save static data
  269. }
  270. // Save object data
  271. pFile->Write(m_szAnimRigidName);
  272. pFile->Write(m_szChildAnimBaseName);
  273. pFile->Write(m_dExtRotVelY);
  274. pFile->Write(m_dExtRotVelZ);
  275. pFile->Write(m_szAnimBaseName);
  276. pFile->Write((U32)m_type);
  277. pFile->Write(m_u16IdParent);
  278. sResult = pFile->Error();
  279. }
  280. else
  281. {
  282. TRACE("CItem3d::Save(): CThing3d::Save() failed.\n");
  283. }
  284. return sResult;
  285. }
  286. ////////////////////////////////////////////////////////////////////////////////
  287. // Update object
  288. ////////////////////////////////////////////////////////////////////////////////
  289. void CItem3d::Update(void)
  290. {
  291. if (!m_sSuspend)
  292. {
  293. // Get new time
  294. long lThisTime = m_pRealm->m_time.GetGameTime();
  295. // Advance the animation timer.
  296. long lDifTime = lThisTime - m_lAnimPrevUpdateTime;
  297. m_lAnimTime += lDifTime;
  298. // Update prev time.
  299. m_lAnimPrevUpdateTime = lThisTime;
  300. // Service message queue.
  301. ProcessMessages();
  302. // Switch on state.
  303. switch (m_state)
  304. {
  305. case State_BlownUp:
  306. // Handle state. If done . . .
  307. if (WhileBlownUp() == false)
  308. {
  309. m_state = State_Idle;
  310. // Stop the spinning.
  311. m_dExtRotVelY = 0;
  312. m_dExtRotVelZ = 0;
  313. }
  314. break;
  315. default:
  316. if (m_u16IdParent == CIdBank::IdNil)
  317. {
  318. // Get time from last call in seconds.
  319. double dSeconds = double(lThisTime - m_lPrevTime) / 1000.0;
  320. DeluxeUpdatePosVel(dSeconds);
  321. }
  322. break;
  323. }
  324. // Update sphere.
  325. m_smash.m_sphere.sphere.X = m_dX;
  326. m_smash.m_sphere.sphere.Y = m_dY;
  327. m_smash.m_sphere.sphere.Z = m_dZ;
  328. m_smash.m_sphere.sphere.lRadius = m_sprite.m_sRadius;
  329. // Update the smash.
  330. m_pRealm->m_smashatorium.Update(&m_smash);
  331. // Save time for next time
  332. m_lPrevTime = lThisTime;
  333. }
  334. }
  335. ////////////////////////////////////////////////////////////////////////////////
  336. // Render object
  337. ////////////////////////////////////////////////////////////////////////////////
  338. void CItem3d::Render(void) // Returns nothing.
  339. {
  340. // Sometimes this thing can exist after a failed EditModify().
  341. if (m_panimCur->m_psops)
  342. {
  343. // Call base class.
  344. CThing3d::Render();
  345. }
  346. // If we have a child and a rigid transform . . .
  347. if (m_animChild.m_pmeshes && m_anim.m_ptransRigid)
  348. {
  349. // Update the child sprite.
  350. m_spriteChild.m_pmesh = m_animChild.m_pmeshes->GetAtTime(m_lAnimTime);
  351. m_spriteChild.m_psop = m_animChild.m_psops->GetAtTime(m_lAnimTime);
  352. m_spriteChild.m_ptex = m_animChild.m_ptextures->GetAtTime(m_lAnimTime);
  353. m_spriteChild.m_psphere = m_animChild.m_pbounds->GetAtTime(m_lAnimTime);
  354. // Use parent's rigid body transform for transform.
  355. m_spriteChild.m_ptrans = m_panimCur->m_ptransRigid->GetAtTime(m_lAnimTime);
  356. }
  357. }
  358. ////////////////////////////////////////////////////////////////////////////////
  359. // Called by editor to init new object at specified position
  360. ////////////////////////////////////////////////////////////////////////////////
  361. short CItem3d::EditNew( // Returns 0 if successfull, non-zero otherwise
  362. short sX, // In: New x coord
  363. short sY, // In: New y coord
  364. short sZ) // In: New z coord
  365. {
  366. short sResult = CThing3d::EditNew(sX, sY, sZ);
  367. if (sResult == 0)
  368. {
  369. sResult = EditModify();
  370. }
  371. return sResult;
  372. }
  373. ////////////////////////////////////////////////////////////////////////////////
  374. // Called by editor to modify object
  375. ////////////////////////////////////////////////////////////////////////////////
  376. short CItem3d::EditModify(void) // Returns 0 if successfull, non-zero otherwise
  377. {
  378. short sResult = CThing3d::EditModify();
  379. RGuiItem* pguiRoot = RGuiItem::LoadInstantiate(FullPathVD(EDIT_GUI_FILE));
  380. if (pguiRoot != NULL)
  381. {
  382. // Get listbox.
  383. RListBox* plb = (RListBox*)pguiRoot->GetItemFromId(LIST_BOX_ID);
  384. REdit* peditName = (REdit*)pguiRoot->GetItemFromId(RESNAME_EDIT_ID);
  385. REdit* peditRigidName = (REdit*)pguiRoot->GetItemFromId(RIGID_RESNAME_EDIT_ID);
  386. REdit* peditChildName = (REdit*)pguiRoot->GetItemFromId(CHILD_RESNAME_EDIT_ID);
  387. REdit* peditRotY = (REdit*)pguiRoot->GetItemFromId(YROTVEL_EDIT_ID);
  388. REdit* peditRotZ = (REdit*)pguiRoot->GetItemFromId(ZROTVEL_EDIT_ID);
  389. if (peditName && plb && peditRotY && peditRotZ && peditChildName && peditRigidName)
  390. {
  391. ASSERT(peditName->m_type == RGuiItem::Edit);
  392. ASSERT(peditRotY->m_type == RGuiItem::Edit);
  393. ASSERT(peditRotZ->m_type == RGuiItem::Edit);
  394. ASSERT(plb->m_type == RGuiItem::ListBox);
  395. peditName->SetText("%s", m_szAnimBaseName);
  396. peditName->Compose();
  397. peditRigidName->SetText("%s", m_szAnimRigidName);
  398. peditRigidName->Compose();
  399. peditChildName->SetText("%s", m_szChildAnimBaseName);
  400. peditChildName->Compose();
  401. peditRotY->SetText("%g", m_dExtRotVelY);
  402. peditRotY->Compose();
  403. peditRotZ->SetText("%g", m_dExtRotVelZ);
  404. peditRotZ->Compose();
  405. // If no type . . .
  406. if (m_type == None)
  407. {
  408. // Default to custom for ease of user interface.
  409. m_type = Custom;
  410. }
  411. short i;
  412. RGuiItem* pguiItem;
  413. for (i = Custom; i < NumTypes; i++)
  414. {
  415. pguiItem = plb->AddString(ms_apszKnownAnimDescriptions[i]);
  416. if (pguiItem != NULL)
  417. {
  418. // Set item number.
  419. pguiItem->m_ulUserData = i;
  420. // If this item is the current type . . .
  421. if (m_type == i)
  422. {
  423. // Select it.
  424. plb->SetSel(pguiItem);
  425. }
  426. }
  427. }
  428. plb->AdjustContents();
  429. if (DoGui(pguiRoot) == 1)
  430. {
  431. RGuiItem* pguiSel = plb->GetSel();
  432. if (pguiSel != NULL)
  433. {
  434. m_type = (ItemType)pguiSel->m_ulUserData;
  435. if (m_type != Custom)
  436. {
  437. strcpy(m_szAnimBaseName, ms_apszKnownAnimBaseNames[m_type]);
  438. }
  439. else
  440. {
  441. strcpy(m_szAnimBaseName, peditName->m_szText);
  442. }
  443. }
  444. else
  445. {
  446. sResult = 1;
  447. }
  448. // Get new rigid body name.
  449. strcpy(m_szAnimRigidName, peditRigidName->m_szText);
  450. // Get new child anim name.
  451. strcpy(m_szChildAnimBaseName, peditChildName->m_szText);
  452. // Get new rotation velocities.
  453. m_dExtRotVelY = strtod(peditRotY->m_szText, NULL);
  454. m_dExtRotVelZ = strtod(peditRotZ->m_szText, NULL);
  455. }
  456. else
  457. {
  458. sResult = 1;
  459. }
  460. }
  461. else
  462. {
  463. TRACE("EditModify(): Missing GUI items in %s.\n", EDIT_GUI_FILE);
  464. sResult = -2;
  465. }
  466. }
  467. else
  468. {
  469. TRACE("EditModify(): Failed to load %s.\n", EDIT_GUI_FILE);
  470. sResult = -1;
  471. }
  472. // If successful so far . . .
  473. if (sResult == 0)
  474. {
  475. // Init item3d
  476. sResult = Init();
  477. }
  478. return sResult;
  479. }
  480. ////////////////////////////////////////////////////////////////////////////////
  481. // Init item3d
  482. ////////////////////////////////////////////////////////////////////////////////
  483. short CItem3d::Init(void) // Returns 0 if successfull, non-zero otherwise
  484. {
  485. short sResult = 0;
  486. m_lPrevTime = m_pRealm->m_time.GetGameTime();
  487. // Get resources
  488. sResult = GetResources();
  489. // Prepare shadow (get resources and setup sprite).
  490. sResult |= PrepareShadow();
  491. m_smash.m_bits = CSmash::Misc;
  492. m_smash.m_pThing = this;
  493. m_panimCur = &m_anim;
  494. m_lAnimTime = 0;
  495. // If the child sprite is functional . . .
  496. if (m_animChild.m_pmeshes && m_anim.m_ptransRigid)
  497. {
  498. // Attach to main sprite.
  499. m_sprite.AddChild(&m_spriteChild);
  500. }
  501. // No special flags.
  502. m_sprite.m_sInFlags = 0;
  503. return sResult;
  504. }
  505. ////////////////////////////////////////////////////////////////////////////////
  506. // Kill item3d
  507. ////////////////////////////////////////////////////////////////////////////////
  508. void CItem3d::Kill(void)
  509. {
  510. // Free resources
  511. FreeResources();
  512. }
  513. ////////////////////////////////////////////////////////////////////////////////
  514. // Get all required resources
  515. ////////////////////////////////////////////////////////////////////////////////
  516. short CItem3d::GetResources(void) // Returns 0 if successfull, non-zero otherwise
  517. {
  518. short sResult = 0;
  519. // Free existing resources, if any.
  520. FreeResources();
  521. ASSERT(m_type > None && m_type < NumTypes);
  522. // If a known type . . .
  523. if (m_type != Custom)
  524. {
  525. strcpy(m_szAnimBaseName, ms_apszKnownAnimBaseNames[m_type]);
  526. }
  527. // Load main anim.
  528. sResult = m_anim.Get(m_szAnimBaseName, m_szAnimRigidName, NULL, NULL, RChannel_LoopAtStart | RChannel_LoopAtEnd);
  529. // If there is a child name . . .
  530. if (m_szChildAnimBaseName[0])
  531. {
  532. // Load child naim.
  533. sResult |= m_animChild.Get(m_szChildAnimBaseName, NULL, NULL, NULL, RChannel_LoopAtStart | RChannel_LoopAtEnd);
  534. }
  535. // Get shadow.
  536. sResult |= rspGetResource(&g_resmgrGame, m_pRealm->Make2dResPath(SHADOW_RES_NAME), &m_spriteShadow.m_pImage);
  537. // If errors . . .
  538. if (sResult)
  539. {
  540. // Remove just in case we're already in scene. Can happen in editor after
  541. // a failed EditModify().
  542. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  543. }
  544. return sResult;
  545. }
  546. ////////////////////////////////////////////////////////////////////////////////
  547. // Free all resources
  548. ////////////////////////////////////////////////////////////////////////////////
  549. void CItem3d::FreeResources(void)
  550. {
  551. // If we have any anim resources . . .
  552. if (m_anim.m_pmeshes)
  553. {
  554. // Release resources for animation.
  555. m_anim.Release();
  556. }
  557. if (m_animChild.m_pmeshes)
  558. {
  559. // Release resources for animation.
  560. m_animChild.Release();
  561. }
  562. }
  563. ////////////////////////////////////////////////////////////////////////////////
  564. // Handles a msg_Shot.
  565. // (virtual).
  566. ////////////////////////////////////////////////////////////////////////////////
  567. void CItem3d::OnShotMsg( // Returns nothing.
  568. Shot_Message* pshotmsg) // In: Message to handle.
  569. {
  570. }
  571. ////////////////////////////////////////////////////////////////////////////////
  572. // Handles an Explosion_Message.
  573. // (virtual).
  574. ////////////////////////////////////////////////////////////////////////////////
  575. void CItem3d::OnExplosionMsg( // Returns nothing.
  576. Explosion_Message* pexplosionmsg) // In: Message to handle.
  577. {
  578. CThing3d::OnExplosionMsg(pexplosionmsg);
  579. m_state = State_BlownUp;
  580. // Send it spinning.
  581. m_dExtRotVelY = GetRand() % 720;
  582. m_dExtRotVelZ = GetRand() % 720;
  583. }
  584. ////////////////////////////////////////////////////////////////////////////////
  585. // Handles a Burn_Message.
  586. // (virtual).
  587. ////////////////////////////////////////////////////////////////////////////////
  588. void CItem3d::OnBurnMsg( // Returns nothing.
  589. Burn_Message* pburnmsg) // In: Message to handle.
  590. {
  591. }
  592. ////////////////////////////////////////////////////////////////////////////////
  593. // Handles an ObjectDelete_Message.
  594. // (virtual).
  595. ////////////////////////////////////////////////////////////////////////////////
  596. void CItem3d::OnDeleteMsg( // Returns nothing.
  597. ObjectDelete_Message* pdeletemsg) // In: Message to handle.
  598. {
  599. CThing3d::OnDeleteMsg(pdeletemsg);
  600. }
  601. ////////////////////////////////////////////////////////////////////////////////
  602. // Setup object after creating it
  603. // (virtual).
  604. ////////////////////////////////////////////////////////////////////////////////
  605. short CItem3d::Setup( // Returns 0 on success.
  606. short sX, // In: Starting X position
  607. short sY, // In: Starting Y position
  608. short sZ, // In: Starting Z position
  609. ItemType type, // In: Known item type or Custom.
  610. char* pszCustomBaseName /*= NULL*/, // In: Required if type == Custom.
  611. // Base name for custom type resources.
  612. U16 u16IdParentInstance /*= CIdBank::IdNil*/) // In: Parent instance ID.
  613. {
  614. short sResult = 0;
  615. m_dX = sX;
  616. m_dY = sY;
  617. m_dZ = sZ;
  618. m_type = type;
  619. if (pszCustomBaseName != NULL)
  620. {
  621. strcpy(m_szAnimBaseName, pszCustomBaseName);
  622. }
  623. m_u16IdParent = u16IdParentInstance;
  624. sResult = Init();
  625. return sResult;
  626. }
  627. ////////////////////////////////////////////////////////////////////////////////
  628. // EOF
  629. ////////////////////////////////////////////////////////////////////////////////