SpinningCloud.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //==========================================================================//
  2. // File: gosFX_SpinningCloud.hpp //
  3. // Contents: SpinningCloud Component //
  4. //---------------------------------------------------------------------------//
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. //===========================================================================//
  7. //
  8. #pragma once
  9. #include "gosFX.hpp"
  10. #include "ParticleCloud.hpp"
  11. namespace gosFX
  12. {
  13. //############################################################################
  14. //######################## SpinningCloud__Specification #############################
  15. //############################################################################
  16. class SpinningCloud;
  17. class SpinningCloud__Specification:
  18. public ParticleCloud__Specification
  19. {
  20. friend class SpinningCloud;
  21. //----------------------------------------------------------------------
  22. // Constructors/Destructors
  23. //
  24. protected:
  25. SpinningCloud__Specification(
  26. Stuff::RegisteredClass::ClassID class_id,
  27. Stuff::MemoryStream *stream,
  28. int gfx_version
  29. );
  30. public:
  31. SpinningCloud__Specification(Stuff::RegisteredClass::ClassID class_id);
  32. void
  33. Copy(SpinningCloud__Specification *spec);
  34. void
  35. Save(Stuff::MemoryStream *stream);
  36. void
  37. BuildDefaults();
  38. bool
  39. IsDataValid(bool fix_data=false);
  40. //-------------------------------------------------------------------------
  41. // FCurves
  42. //
  43. public:
  44. SeededCurveOf<ConstantCurve, LinearCurve,Curve::e_ConstantLinearType>
  45. m_pSpin;
  46. SeededCurveOf<ComplexCurve, ComplexCurve,Curve::e_ComplexComplexType>
  47. m_pScale;
  48. bool
  49. m_randomStartingRotation,
  50. m_alignYUsingVelocity,
  51. m_alignZUsingX,
  52. m_alignZUsingY;
  53. };
  54. //############################################################################
  55. //######################## ParticleCloud__Particle #############################
  56. //############################################################################
  57. class SpinningCloud__Particle:
  58. public ParticleCloud__Particle
  59. {
  60. public:
  61. Stuff::Vector3D
  62. m_angularVelocity;
  63. Stuff::Point3D
  64. m_localTranslation,
  65. m_worldTranslation;
  66. Stuff::UnitQuaternion
  67. m_localRotation,
  68. m_worldRotation;
  69. Stuff::Scalar
  70. m_radius,
  71. m_scale;
  72. };
  73. //############################################################################
  74. //############################# SpinningCloud #################################
  75. //############################################################################
  76. class _declspec(novtable) SpinningCloud:
  77. public ParticleCloud
  78. {
  79. //----------------------------------------------------------------------------
  80. // Class Registration Support
  81. //
  82. public:
  83. static void InitializeClass();
  84. static void TerminateClass();
  85. static ClassData
  86. *DefaultData;
  87. //----------------------------------------------------------------------------
  88. // Class Data Support
  89. //
  90. public:
  91. typedef SpinningCloud__Specification Specification;
  92. typedef SpinningCloud__Particle Particle;
  93. protected:
  94. SpinningCloud(
  95. ClassData *class_data,
  96. Specification *spec,
  97. unsigned flags
  98. );
  99. public:
  100. Specification*
  101. GetSpecification()
  102. {
  103. Check_Object(this);
  104. return
  105. Cast_Object(Specification*, m_specification);
  106. }
  107. Particle*
  108. GetParticle(unsigned index)
  109. {
  110. Check_Object(this); Check_Object(GetSpecification());
  111. return
  112. Cast_Pointer(
  113. Particle*,
  114. &m_data[index*GetSpecification()->m_particleClassSize]
  115. );
  116. }
  117. //----------------------------------------------------------------------------
  118. // Testing
  119. //
  120. public:
  121. void
  122. TestInstance() const;
  123. //----------------------------------------------------------------------------
  124. // API
  125. //
  126. protected:
  127. bool
  128. AnimateParticle(
  129. unsigned index,
  130. const Stuff::LinearMatrix4D *world_to_new_local,
  131. Stuff::Time till
  132. );
  133. void
  134. CreateNewParticle(
  135. unsigned index,
  136. Stuff::Point3D *translation
  137. );
  138. public:
  139. bool
  140. Execute(ExecuteInfo *info);
  141. };
  142. }