Tube.hpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //==========================================================================//
  2. // File: gosFX_Tube.hpp //
  3. // Contents: Base Tube Profile //
  4. //---------------------------------------------------------------------------//
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. //===========================================================================//
  7. //
  8. #pragma once
  9. #include "gosFX.hpp"
  10. #include "Effect.hpp"
  11. namespace MidLevelRenderer {class MLRIndexedTriangleCloud;}
  12. namespace gosFX
  13. {
  14. //############################################################################
  15. //######################## Tube__Specification #############################
  16. //############################################################################
  17. class Tube__Specification:
  18. public Effect__Specification
  19. {
  20. //----------------------------------------------------------------------
  21. // Constructors/Destructors
  22. //
  23. protected:
  24. Tube__Specification(
  25. Stuff::MemoryStream *stream,
  26. int gfx_version
  27. );
  28. public:
  29. Tube__Specification();
  30. static Tube__Specification*
  31. Make(
  32. Stuff::MemoryStream *stream,
  33. int gfx_version
  34. );
  35. void
  36. Copy(Tube__Specification *spec);
  37. void
  38. Save(Stuff::MemoryStream *stream);
  39. void
  40. BuildDefaults();
  41. bool
  42. IsDataValid(bool fix_data=false);
  43. bool
  44. CalculateUBias(bool adjust);
  45. //-------------------------------------------------------------------------
  46. // FCurves
  47. //
  48. public:
  49. ConstantCurve
  50. m_profilesPerSecond,
  51. m_pLifeSpan;
  52. LinearCurve
  53. m_emitterSizeX,
  54. m_emitterSizeY,
  55. m_emitterSizeZ;
  56. ConstantCurve
  57. m_minimumDeviation;
  58. ComplexCurve
  59. m_maximumDeviation;
  60. SeededCurveOf<ComplexCurve, SplineCurve,Curve::e_ComplexSplineType>
  61. m_pDisplacement,
  62. m_pScale;
  63. SeededCurveOf<ComplexCurve, LinearCurve,Curve::e_ComplexLinearType>
  64. m_pRed,
  65. m_pGreen,
  66. m_pBlue,
  67. m_pAlpha;
  68. SeededCurveOf<ComplexCurve, SplineCurve,Curve::e_ComplexSplineType>
  69. m_pUOffset,
  70. m_pVOffset;
  71. SeededCurveOf<SplineCurve, SplineCurve,Curve::e_SplineSplineType>
  72. m_pUSize,
  73. m_pVSize;
  74. //----------------------------------------------------------------------
  75. // Data
  76. //
  77. public:
  78. int
  79. m_maxProfileCount;
  80. enum ProfileType {
  81. e_Ribbon,
  82. e_AlignedRibbon,
  83. e_Triangle,
  84. e_Square,
  85. e_Cross,
  86. e_Pentagon,
  87. e_Hexagon,
  88. e_VerticalRibbon
  89. }
  90. m_profileType;
  91. bool
  92. m_insideOut;
  93. Stuff::DynamicArrayOf<Stuff::Point3D>
  94. m_vertices;
  95. Stuff::DynamicArrayOf<Stuff::Vector2DOf<Stuff::Scalar> >
  96. m_uvs;
  97. Stuff::Scalar
  98. m_UBias;
  99. void
  100. BuildTemplate();
  101. };
  102. //############################################################################
  103. //######################## Tube__Profile #############################
  104. //############################################################################
  105. class Tube__Profile
  106. {
  107. public:
  108. Stuff::LinearMatrix4D
  109. m_profileToWorld;
  110. Stuff::UnitVector3D
  111. m_direction;
  112. Stuff::Scalar
  113. m_age,
  114. m_ageRate,
  115. m_seed;
  116. void
  117. TestInstance() const
  118. {}
  119. };
  120. //############################################################################
  121. //############################## Tube #############################
  122. //############################################################################
  123. class Tube:
  124. public Effect
  125. {
  126. public:
  127. static void
  128. InitializeClass();
  129. static void
  130. TerminateClass();
  131. static ClassData
  132. *DefaultData;
  133. typedef Tube__Specification Specification;
  134. typedef Tube__Profile Profile;
  135. protected:
  136. int
  137. m_headProfile,
  138. m_tailProfile,
  139. m_activeProfileCount,
  140. m_triangleCount,
  141. m_vertexCount;
  142. Stuff::Scalar
  143. m_birthAccumulator;
  144. Stuff::DynamicArrayOf<Profile>
  145. m_profiles;
  146. Stuff::DynamicArrayOf<char>
  147. m_data;
  148. MidLevelRenderer::MLRIndexedTriangleCloud
  149. *m_mesh;
  150. Stuff::Point3D
  151. *m_P_vertices;
  152. Stuff::RGBAColor
  153. *m_P_colors;
  154. Stuff::Vector2DOf<Stuff::Scalar>
  155. *m_P_uvs;
  156. void
  157. BuildMesh(unsigned short *indices);
  158. Tube(
  159. Specification *spec,
  160. unsigned flags
  161. );
  162. //----------------------------------------------------------------------------
  163. // Class Data Support
  164. //
  165. public:
  166. ~Tube();
  167. static Tube*
  168. Make(
  169. Specification *spec,
  170. unsigned flags
  171. );
  172. Specification*
  173. GetSpecification()
  174. {
  175. Check_Object(this);
  176. return
  177. Cast_Object(Specification*, m_specification);
  178. }
  179. Profile*
  180. GetProfile(unsigned index)
  181. {
  182. Check_Object(this); Check_Object(GetSpecification());
  183. return &m_profiles[index];
  184. }
  185. //----------------------------------------------------------------------------
  186. // Testing
  187. //
  188. public:
  189. void
  190. TestInstance() const;
  191. //----------------------------------------------------------------------------
  192. // API
  193. //
  194. protected:
  195. bool
  196. Execute(ExecuteInfo *info);
  197. bool
  198. AnimateProfile(
  199. unsigned index,
  200. unsigned profile,
  201. const Stuff::LinearMatrix4D &world_to_new_local,
  202. Stuff::Time till,
  203. Stuff::Sphere *sphere
  204. );
  205. void
  206. CreateNewProfile(
  207. unsigned index,
  208. const Stuff::LinearMatrix4D &origin
  209. );
  210. void
  211. DestroyProfile(unsigned index);
  212. void
  213. ComputeNewLinearVelocity(
  214. Profile *particle,
  215. Stuff::Scalar time_slice
  216. );
  217. public:
  218. void
  219. Start(ExecuteInfo *info);
  220. void
  221. Kill();
  222. bool
  223. HasFinished();
  224. void
  225. Draw(DrawInfo *info);
  226. };
  227. }