warpIGC.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. ** Copyright (C) 1996, 1997 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: warpIGC.cpp
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Implementation of the CwarpIGC class. This file was initially created by
  10. ** the ATL wizard.
  11. **
  12. ** History:
  13. */
  14. // warpIGC.cpp : Implementation of CwarpIGC
  15. #include "pch.h"
  16. #include "warpIGC.h"
  17. #include <stdio.h>
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CwarpIGC
  20. HRESULT CwarpIGC::Initialize(ImissionIGC* pMission, Time now, const void* data, int dataSize)
  21. {
  22. TmodelIGC<IwarpIGC>::Initialize(pMission, now, data, dataSize);
  23. ZRetailAssert (data && (dataSize == sizeof(DataWarpIGC)));
  24. {
  25. DataWarpIGC* dataWarp = (DataWarpIGC*)data;
  26. m_warpDef = dataWarp->warpDef;
  27. IclusterIGC* cluster = pMission->GetCluster(dataWarp->clusterID);
  28. ZRetailAssert (cluster);
  29. {
  30. // , use the real texture name
  31. HRESULT rc = LoadWarp(dataWarp->warpDef.textureName,
  32. dataWarp->warpDef.iconName,
  33. c_mtStatic | c_mtHitable | c_mtSeenBySide | c_mtPredictable);
  34. assert (SUCCEEDED(rc));
  35. {
  36. SetRadius((float)m_warpDef.radius);
  37. SetPosition(dataWarp->position);
  38. SetVelocity(Vector::GetZero());
  39. {
  40. Orientation o(dataWarp->forward);
  41. SetOrientation(o);
  42. }
  43. SetRotation(dataWarp->rotation);
  44. SetCluster(cluster);
  45. SetMass(0.0f);
  46. SetName(dataWarp->name);
  47. SetSignature(dataWarp->signature);
  48. pMission->AddWarp(this);
  49. }
  50. }
  51. }
  52. return S_OK;
  53. }
  54. int CwarpIGC::Export(void* data) const
  55. {
  56. if (data)
  57. {
  58. DataWarpIGC* dataWarp = (DataWarpIGC*)data;
  59. dataWarp->warpDef = m_warpDef;
  60. dataWarp->position = GetPosition();
  61. dataWarp->forward = GetOrientation().GetForward();
  62. dataWarp->rotation = GetRotation();
  63. assert (GetCluster());
  64. dataWarp->clusterID = GetCluster()->GetObjectID();
  65. UTL::putName(dataWarp->name, GetName());
  66. dataWarp->signature = GetSignature();
  67. }
  68. return sizeof(DataWarpIGC);
  69. }