Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
7.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // game model input - gets its values from an MDL within the game
  4. //
  5. //=============================================================================
  6. #include "movieobjects/dmegamemodelinput.h"
  7. #include "movieobjects_interfaces.h"
  8. #include "datamodel/dmelementfactoryhelper.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //-----------------------------------------------------------------------------
  12. // Expose this class to the scene database
  13. //-----------------------------------------------------------------------------
  14. IMPLEMENT_ELEMENT_FACTORY( DmeGameModelInput, CDmeGameModelInput );
  15. //-----------------------------------------------------------------------------
  16. // Purpose:
  17. //-----------------------------------------------------------------------------
  18. void CDmeGameModelInput::OnConstruction()
  19. {
  20. m_skin.Init( this, "skin" );
  21. m_body.Init( this, "body" );
  22. m_sequence.Init( this, "sequence" );
  23. m_visible.Init( this, "visible" );
  24. m_flags.Init( this, "flags" );
  25. m_flexWeights.Init( this, "flexWeights" );
  26. m_viewTarget.Init( this, "viewTarget" );
  27. m_bonePositions.Init( this, "bonePositions" );
  28. m_boneRotations.Init( this, "boneRotations" );
  29. m_position.Init( this, "position" );
  30. m_rotation.Init( this, "rotation" );
  31. }
  32. void CDmeGameModelInput::OnDestruction()
  33. {
  34. }
  35. //-----------------------------------------------------------------------------
  36. // Operator methods
  37. //-----------------------------------------------------------------------------
  38. bool CDmeGameModelInput::IsDirty()
  39. {
  40. return true; // TODO - keep some bit of state that remembers when its changed
  41. }
  42. void CDmeGameModelInput::Operate()
  43. {
  44. }
  45. void CDmeGameModelInput::GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs )
  46. {
  47. attrs.AddToTail( m_skin.GetAttribute() );
  48. attrs.AddToTail( m_body.GetAttribute() );
  49. attrs.AddToTail( m_sequence.GetAttribute() );
  50. attrs.AddToTail( m_visible.GetAttribute() );
  51. attrs.AddToTail( m_flags.GetAttribute() );
  52. attrs.AddToTail( m_flexWeights.GetAttribute() );
  53. attrs.AddToTail( m_viewTarget.GetAttribute() );
  54. attrs.AddToTail( m_bonePositions.GetAttribute() );
  55. attrs.AddToTail( m_boneRotations.GetAttribute() );
  56. attrs.AddToTail( m_position.GetAttribute() );
  57. attrs.AddToTail( m_rotation.GetAttribute() );
  58. }
  59. //-----------------------------------------------------------------------------
  60. // accessors
  61. //-----------------------------------------------------------------------------
  62. void CDmeGameModelInput::SetFlags( int nFlags )
  63. {
  64. m_flags = nFlags;
  65. }
  66. //-----------------------------------------------------------------------------
  67. // accessors
  68. //-----------------------------------------------------------------------------
  69. void CDmeGameModelInput::AddBone( const Vector& pos, const Quaternion& rot )
  70. {
  71. m_bonePositions.AddToTail( pos );
  72. m_boneRotations.AddToTail( rot );
  73. }
  74. void CDmeGameModelInput::SetBone( uint index, const Vector& pos, const Quaternion& rot )
  75. {
  76. m_bonePositions.Set( index, pos );
  77. m_boneRotations.Set( index, rot );
  78. }
  79. void CDmeGameModelInput::SetRootBone( const Vector& pos, const Quaternion& rot )
  80. {
  81. m_position.Set( pos );
  82. m_rotation.Set( rot );
  83. }
  84. uint CDmeGameModelInput::NumBones() const
  85. {
  86. Assert( m_bonePositions.Count() == m_boneRotations.Count() );
  87. return m_bonePositions.Count();
  88. }
  89. void CDmeGameModelInput::SetFlexWeights( uint nFlexWeights, const float* flexWeights )
  90. {
  91. m_flexWeights.CopyArray( flexWeights, nFlexWeights );
  92. }
  93. uint CDmeGameModelInput::NumFlexWeights() const
  94. {
  95. return m_flexWeights.Count();
  96. }
  97. const Vector& CDmeGameModelInput::GetViewTarget() const
  98. {
  99. return m_viewTarget;
  100. }
  101. void CDmeGameModelInput::SetViewTarget( const Vector &viewTarget )
  102. {
  103. m_viewTarget = viewTarget;
  104. }
  105. //-----------------------------------------------------------------------------
  106. // Expose this class to the scene database
  107. //-----------------------------------------------------------------------------
  108. IMPLEMENT_ELEMENT_FACTORY( DmeGameSpriteInput, CDmeGameSpriteInput );
  109. //-----------------------------------------------------------------------------
  110. // Purpose:
  111. //-----------------------------------------------------------------------------
  112. void CDmeGameSpriteInput::OnConstruction()
  113. {
  114. m_visible .Init( this, "visible" );
  115. m_frame .Init( this, "frame" );
  116. m_rendermode .Init( this, "rendermode" );
  117. m_renderfx .Init( this, "renderfx" );
  118. m_renderscale.Init( this, "renderscale" );
  119. m_proxyRadius.Init( this, "proxyRadius" );
  120. m_position .Init( this, "position" );
  121. m_rotation .Init( this, "rotation" );
  122. m_color .Init( this, "color" );
  123. }
  124. void CDmeGameSpriteInput::OnDestruction()
  125. {
  126. }
  127. //-----------------------------------------------------------------------------
  128. // Operator methods
  129. //-----------------------------------------------------------------------------
  130. bool CDmeGameSpriteInput::IsDirty()
  131. {
  132. return true; // TODO - keep some bit of state that remembers when its changed
  133. }
  134. void CDmeGameSpriteInput::Operate()
  135. {
  136. }
  137. void CDmeGameSpriteInput::GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs )
  138. {
  139. attrs.AddToTail( m_visible.GetAttribute() );
  140. attrs.AddToTail( m_frame.GetAttribute() );
  141. attrs.AddToTail( m_rendermode.GetAttribute() );
  142. attrs.AddToTail( m_renderfx.GetAttribute() );
  143. attrs.AddToTail( m_renderscale.GetAttribute() );
  144. attrs.AddToTail( m_proxyRadius.GetAttribute() );
  145. attrs.AddToTail( m_position.GetAttribute() );
  146. attrs.AddToTail( m_rotation.GetAttribute() );
  147. attrs.AddToTail( m_color.GetAttribute() );
  148. }
  149. //-----------------------------------------------------------------------------
  150. // accessors
  151. //-----------------------------------------------------------------------------
  152. void CDmeGameSpriteInput::SetState( bool bVisible, float nFrame, int nRenderMode, int nRenderFX, float flRenderScale, float flProxyRadius,
  153. const Vector &pos, const Quaternion &rot, const Color &color )
  154. {
  155. m_visible = bVisible;
  156. m_frame = nFrame;
  157. m_rendermode = nRenderMode;
  158. m_renderfx = nRenderFX;
  159. m_renderscale = flRenderScale;
  160. m_proxyRadius = flProxyRadius;
  161. m_position = pos;
  162. m_rotation = rot;
  163. m_color = color;
  164. }
  165. //-----------------------------------------------------------------------------
  166. // Expose this class to the scene database
  167. //-----------------------------------------------------------------------------
  168. IMPLEMENT_ELEMENT_FACTORY( DmeGameCameraInput, CDmeGameCameraInput );
  169. //-----------------------------------------------------------------------------
  170. // Purpose:
  171. //-----------------------------------------------------------------------------
  172. void CDmeGameCameraInput::OnConstruction()
  173. {
  174. m_position.Init( this, "position" );
  175. m_rotation.Init( this, "rotation" );
  176. m_fov.Init( this, "fov" );
  177. }
  178. void CDmeGameCameraInput::OnDestruction()
  179. {
  180. }
  181. //-----------------------------------------------------------------------------
  182. // Operator methods
  183. //-----------------------------------------------------------------------------
  184. bool CDmeGameCameraInput::IsDirty()
  185. {
  186. return true; // TODO - keep some bit of state that remembers when its changed
  187. }
  188. void CDmeGameCameraInput::Operate()
  189. {
  190. }
  191. void CDmeGameCameraInput::GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs )
  192. {
  193. attrs.AddToTail( m_position.GetAttribute() );
  194. attrs.AddToTail( m_rotation.GetAttribute() );
  195. attrs.AddToTail( m_fov.GetAttribute() );
  196. }
  197. //-----------------------------------------------------------------------------
  198. // accessors
  199. //-----------------------------------------------------------------------------
  200. void CDmeGameCameraInput::SetPosition( const Vector& pos )
  201. {
  202. m_position.Set( pos );
  203. }
  204. void CDmeGameCameraInput::SetOrientation( const Quaternion& rot )
  205. {
  206. m_rotation.Set( rot );
  207. }
  208. void CDmeGameCameraInput::SetFOV( float fov )
  209. {
  210. m_fov = fov;
  211. }