Counter Strike : Global Offensive Source Code
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.

3733 lines
132 KiB

  1. //===== Copyright (c) 1996-2008, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef STUDIO_PS3_H
  9. #define STUDIO_PS3_H
  10. #include "basetypes.h"
  11. //#include "mathlib/vector2d.h"
  12. #include "mathlib/vector.h"
  13. #include "mathlib/vector4d.h"
  14. #include "mathlib/compressed_vector.h"
  15. // #include "tier0/dbg.h"
  16. // #include "tier0/threadtools.h"
  17. #include "mathlib/mathlib.h"
  18. //#include "utlvector.h"
  19. // #include "utlhash.h"
  20. // #include "datamap.h"
  21. // #include "generichash.h"
  22. // #include "localflexcontroller.h"
  23. // #include "utlsymbol.h"
  24. // #include "convar.h"
  25. // duplicated defined from studio.h for spu
  26. #if defined(__SPU__)
  27. #define STUDIO_LOCAL 0x0200 // sequence has a local context sequence
  28. #define STUDIO_LOOPING 0x0001 // ending frame should be the same as the starting frame
  29. #define BONE_FIXED_ALIGNMENT 0x00100000 // bone can't spin 360 degrees, all interpolation is normalized around a fixed orientation
  30. #define BONE_HAS_SAVEFRAME_POS 0x00200000 // Vector48
  31. #define BONE_HAS_SAVEFRAME_ROT64 0x00400000 // Quaternion64
  32. #define BONE_HAS_SAVEFRAME_ROT32 0x00800000 // Quaternion32
  33. #define STUDIO_FRAME_CONST_POS 0x01 // Vector48 in constants
  34. #define STUDIO_FRAME_CONST_ROT 0x02 // Quaternion48 in constants
  35. #define STUDIO_FRAME_ANIM_POS 0x04 // Vector48 in framedata
  36. #define STUDIO_FRAME_ANIM_ROT 0x08 // Quaternion48 in framedata
  37. #define STUDIO_FRAME_ANIM_POS2 0x10 // Vector in framedata
  38. #define STUDIO_FRAME_CONST_POS2 0x20 // Vector in constants
  39. #define STUDIO_FRAME_CONST_ROT2 0x40 // Quaternion48S in constants
  40. #define STUDIO_FRAME_ANIM_ROT2 0x80 // Quaternion48S in framedata
  41. #define STUDIO_DELTA 0x0004 // this sequence "adds" to the base sequences, not slerp blends
  42. #define STUDIO_FRAMEANIM 0x0040 // animation is encoded as by frame x bone instead of RLE bone x frame
  43. #define STUDIO_POST 0x0010 //
  44. #define STUDIO_WORLD 0x4000 // sequence blends in worldspace
  45. #endif
  46. // #define STUDIO_ENABLE_PERF_COUNTERS
  47. // #define STUDIO_SEQUENCE_ACTIVITY_LOOKUPS_ARE_SLOW 0
  48. //-----------------------------------------------------------------------------
  49. // forward declarations
  50. //-----------------------------------------------------------------------------
  51. // class IMaterial;
  52. // class IMesh;
  53. // class IMorph;
  54. // struct virtualmodel_t;
  55. // struct vertexFileHeader_t;
  56. // struct thinModelVertices_t;
  57. //
  58. // namespace OptimizedModel
  59. // {
  60. // struct StripHeader_t;
  61. // }
  62. class CThreadFastMutex_PS3 // here for size only
  63. {
  64. uint32 m_ownerID;
  65. int m_depth;
  66. };
  67. /*
  68. ==============================================================================
  69. STUDIO MODELS
  70. Studio models are position independent, so the cache manager can move them.
  71. ==============================================================================
  72. */
  73. // #define STUDIO_VERSION 49
  74. struct studiohdr_t_PS3;
  75. // #ifdef _GAMECONSOLE
  76. // #define MAXSTUDIOTRIANGLES 65536 //
  77. // #define MAXSTUDIOVERTS 32768 // These numbers save memory in CCachedRenderData, but restrict usable model sizes on 360
  78. // #define MAXSTUDIOFLEXVERTS 4096 //
  79. // #else
  80. // #define MAXSTUDIOTRIANGLES 65536 // TODO: tune this
  81. // #define MAXSTUDIOVERTS 65536 // TODO: tune this
  82. // #define MAXSTUDIOFLEXVERTS 10000 // max number of verts that can be flexed per mesh. TODO: tune this
  83. // #endif
  84. // #define MAXSTUDIOSKINS 32 // total textures
  85. #define MAXSTUDIOBONES_PS3 128 // 256 // total bones actually used
  86. // #define MAXSTUDIOFLEXDESC 1024 // maximum number of low level flexes (actual morph targets)
  87. // #define MAXSTUDIOFLEXCTRL 96 // maximum number of flexcontrollers (input sliders)
  88. #define MAXSTUDIOPOSEPARAM_PS3 24
  89. // #define MAXSTUDIOBONECTRLS 4
  90. // #define MAXSTUDIOANIMBLOCKS 256
  91. #define MAXSTUDIOBONEBITS_PS3 7 //8 // NOTE: MUST MATCH MAXSTUDIOBONES
  92. // NOTE!!! : Changing this number also changes the vtx file format!!!!!
  93. // #define MAX_NUM_BONES_PER_VERT 3
  94. //Adrian - Remove this when we completely phase out the old event system.
  95. // #define NEW_EVENT_STYLE ( 1 << 10 )
  96. // struct mstudiodata_t
  97. // {
  98. // int count;
  99. // int offset;
  100. // };
  101. // #define STUDIO_PROC_AXISINTERP 1
  102. // #define STUDIO_PROC_QUATINTERP 2
  103. // #define STUDIO_PROC_AIMATBONE 3
  104. // #define STUDIO_PROC_AIMATATTACH 4
  105. // #define STUDIO_PROC_JIGGLE 5
  106. // #define STUDIO_PROC_TWIST_MASTER 6
  107. // #define STUDIO_PROC_TWIST_SLAVE 7 // Multiple twist bones are computed at once for the same parent/child combo so TWIST_NULL do nothing
  108. // #define STUDIO_PROC_POINT_CONSTRAINT 8
  109. // #define STUDIO_PROC_ORIENT_CONSTRAINT 9
  110. // #define STUDIO_PROC_AIM_CONSTRAINT 10
  111. // #define STUDIO_PROC_IK_CONSTRAINT 11
  112. // #define STUDIO_PROC_PARENT_CONSTRAINT 12
  113. // struct mstudioaxisinterpbone_t
  114. // {
  115. // DECLARE_BYTESWAP_DATADESC();
  116. // int control;// local transformation of this bone used to calc 3 point blend
  117. // int axis; // axis to check
  118. // Vector pos[6]; // X+, X-, Y+, Y-, Z+, Z-
  119. // Quaternion quat[6];// X+, X-, Y+, Y-, Z+, Z-
  120. //
  121. // mstudioaxisinterpbone_t(){}
  122. // private:
  123. // // No copy constructors allowed
  124. // mstudioaxisinterpbone_t(const mstudioaxisinterpbone_t& vOther);
  125. // };
  126. // struct mstudioquatinterpinfo_t
  127. // {
  128. // DECLARE_BYTESWAP_DATADESC();
  129. // float inv_tolerance; // 1 / radian angle of trigger influence
  130. // Quaternion trigger; // angle to match
  131. // Vector pos; // new position
  132. // Quaternion quat; // new angle
  133. //
  134. // mstudioquatinterpinfo_t(){}
  135. // private:
  136. // // No copy constructors allowed
  137. // mstudioquatinterpinfo_t(const mstudioquatinterpinfo_t& vOther);
  138. // };
  139. // struct mstudioquatinterpbone_t
  140. // {
  141. // DECLARE_BYTESWAP_DATADESC();
  142. // int control;// local transformation to check
  143. // int numtriggers;
  144. // int triggerindex;
  145. // inline mstudioquatinterpinfo_t *pTrigger( int i ) const { return (mstudioquatinterpinfo_t *)(((byte *)this) + triggerindex) + i; };
  146. //
  147. // mstudioquatinterpbone_t(){}
  148. // private:
  149. // // No copy constructors allowed
  150. // mstudioquatinterpbone_t(const mstudioquatinterpbone_t& vOther);
  151. // };
  152. // #define JIGGLE_IS_FLEXIBLE 0x01
  153. // #define JIGGLE_IS_RIGID 0x02
  154. // #define JIGGLE_HAS_YAW_CONSTRAINT 0x04
  155. // #define JIGGLE_HAS_PITCH_CONSTRAINT 0x08
  156. // #define JIGGLE_HAS_ANGLE_CONSTRAINT 0x10
  157. // #define JIGGLE_HAS_LENGTH_CONSTRAINT 0x20
  158. // #define JIGGLE_HAS_BASE_SPRING 0x40
  159. //
  160. // struct mstudiojigglebone_t
  161. // {
  162. // DECLARE_BYTESWAP_DATADESC();
  163. //
  164. // int flags;
  165. //
  166. // // general params
  167. // float length; // how from from bone base, along bone, is tip
  168. // float tipMass;
  169. //
  170. // // flexible params
  171. // float yawStiffness;
  172. // float yawDamping;
  173. // float pitchStiffness;
  174. // float pitchDamping;
  175. // float alongStiffness;
  176. // float alongDamping;
  177. //
  178. // // angle constraint
  179. // float angleLimit; // maximum deflection of tip in radians
  180. //
  181. // // yaw constraint
  182. // float minYaw; // in radians
  183. // float maxYaw; // in radians
  184. // float yawFriction;
  185. // float yawBounce;
  186. //
  187. // // pitch constraint
  188. // float minPitch; // in radians
  189. // float maxPitch; // in radians
  190. // float pitchFriction;
  191. // float pitchBounce;
  192. //
  193. // // base spring
  194. // float baseMass;
  195. // float baseStiffness;
  196. // float baseDamping;
  197. // float baseMinLeft;
  198. // float baseMaxLeft;
  199. // float baseLeftFriction;
  200. // float baseMinUp;
  201. // float baseMaxUp;
  202. // float baseUpFriction;
  203. // float baseMinForward;
  204. // float baseMaxForward;
  205. // float baseForwardFriction;
  206. //
  207. // private:
  208. // // No copy constructors allowed
  209. // //mstudiojigglebone_t(const mstudiojigglebone_t& vOther);
  210. // };
  211. // struct mstudioaimatbone_t
  212. // {
  213. // DECLARE_BYTESWAP_DATADESC();
  214. //
  215. // int parent;
  216. // int aim; // Might be bone or attach
  217. // Vector aimvector;
  218. // Vector upvector;
  219. // Vector basepos;
  220. //
  221. // mstudioaimatbone_t() {}
  222. // private:
  223. // // No copy constructors allowed
  224. // mstudioaimatbone_t(const mstudioaimatbone_t& vOther);
  225. // };
  226. //-----------------------------------------------------------------------------
  227. //
  228. //-----------------------------------------------------------------------------
  229. // struct mstudiotwistbonetarget_t
  230. // {
  231. // DECLARE_BYTESWAP_DATADESC();
  232. //
  233. // int m_nBone;
  234. // float m_flWeight;
  235. // Vector m_vBaseTranslate;
  236. // Quaternion m_qBaseRotation;
  237. //
  238. // mstudiotwistbonetarget_t() {}
  239. // private:
  240. // // No copy constructors allowed
  241. // mstudiotwistbonetarget_t( const mstudiotwistbonetarget_t &vOther );
  242. // };
  243. //-----------------------------------------------------------------------------
  244. //
  245. //-----------------------------------------------------------------------------
  246. // struct mstudiotwistbone_t
  247. // {
  248. // DECLARE_BYTESWAP_DATADESC();
  249. //
  250. // bool m_bInverse; // False: Apply child rotation to twist targets True: Apply parent rotation to twist targets
  251. // Vector m_vUpVector; // In parent space, projected into plane defined by vector between parent & child
  252. // int m_nParentBone;
  253. // Quaternion m_qBaseInv; // The base rotation of the parent, used if m_bInverse is true
  254. // int m_nChildBone;
  255. //
  256. // int m_nTargetCount;
  257. // int m_nTargetIndex;
  258. // inline mstudiotwistbonetarget_t *pTarget( int i ) const { return ( mstudiotwistbonetarget_t * )( ( ( byte * )this) + m_nTargetIndex ) + i; }
  259. //
  260. // mstudiotwistbone_t() {}
  261. // private:
  262. // // No copy constructors allowed
  263. // mstudiotwistbone_t( const mstudiotwistbone_t &vOther );
  264. // };
  265. //-----------------------------------------------------------------------------
  266. //
  267. //-----------------------------------------------------------------------------
  268. // struct mstudioconstraintslave_t
  269. // {
  270. // DECLARE_BYTESWAP_DATADESC();
  271. //
  272. // int m_nBone;
  273. // Vector m_vBasePosition;
  274. // Quaternion m_qBaseOrientation;
  275. //
  276. // mstudioconstraintslave_t() {}
  277. // private:
  278. // // No copy constructors allowed
  279. // mstudioconstraintslave_t( const mstudioconstraintslave_t &vOther );
  280. // };
  281. //-----------------------------------------------------------------------------
  282. //
  283. //-----------------------------------------------------------------------------
  284. // struct mstudioconstrainttarget_t
  285. // {
  286. // DECLARE_BYTESWAP_DATADESC();
  287. //
  288. // int m_nBone;
  289. // float m_flWeight;
  290. // Vector m_vOffset;
  291. // Quaternion m_qOffset;
  292. //
  293. // mstudioconstrainttarget_t() {}
  294. // private:
  295. // // No copy constructors allowed
  296. // mstudioconstrainttarget_t( const mstudioconstrainttarget_t &vOther );
  297. // };
  298. //-----------------------------------------------------------------------------
  299. // Point constraint, slave position matches target position
  300. //-----------------------------------------------------------------------------
  301. // struct mstudiopointconstraint_t
  302. // {
  303. // DECLARE_BYTESWAP_DATADESC();
  304. //
  305. // mstudioconstraintslave_t m_slave; // DEFINE_EMBEDDED
  306. //
  307. // int m_nTargetCount;
  308. // int m_nTargetIndex;
  309. // inline mstudioconstrainttarget_t *pTarget( int i ) const { return ( mstudioconstrainttarget_t * )( ( ( byte * )this) + m_nTargetIndex ) + i; }
  310. //
  311. // mstudiopointconstraint_t() {}
  312. // private:
  313. // // No copy constructors allowed
  314. // mstudiopointconstraint_t( const mstudiopointconstraint_t &vOther );
  315. // };
  316. //-----------------------------------------------------------------------------
  317. // Orient constraint, slave orientation matches target orientation
  318. //-----------------------------------------------------------------------------
  319. // struct mstudioorientconstraint_t
  320. // {
  321. // DECLARE_BYTESWAP_DATADESC();
  322. //
  323. // mstudioconstraintslave_t m_slave; // DEFINE_EMBEDDED
  324. //
  325. // int m_nTargetCount;
  326. // int m_nTargetIndex;
  327. // inline mstudioconstrainttarget_t *pTarget( int i ) const { return ( mstudioconstrainttarget_t * )( ( ( byte * )this) + m_nTargetIndex ) + i; }
  328. //
  329. // mstudioorientconstraint_t() {}
  330. // private:
  331. // // No copy constructors allowed
  332. // mstudioorientconstraint_t( const mstudioorientconstraint_t &vOther );
  333. // };
  334. //-----------------------------------------------------------------------------
  335. //
  336. //-----------------------------------------------------------------------------
  337. // struct mstudioaimconstraint_t
  338. // {
  339. // DECLARE_BYTESWAP_DATADESC();
  340. //
  341. // mstudioconstraintslave_t m_slave; // DEFINE_EMBEDDED
  342. //
  343. // int m_nTargetCount;
  344. // int m_nTargetIndex;
  345. // inline mstudioconstrainttarget_t *pTarget( int i ) const { return ( mstudioconstrainttarget_t * )( ( ( byte * )this) + m_nTargetIndex ) + i; }
  346. //
  347. // Quaternion m_qAimOffset;
  348. // Vector m_vUp;
  349. // int m_nUpSpaceTarget;
  350. //
  351. // mstudioaimconstraint_t() {}
  352. // private:
  353. // // No copy constructors allowed
  354. // mstudioaimconstraint_t( const mstudioaimconstraint_t &vOther );
  355. // };
  356. //-----------------------------------------------------------------------------
  357. //
  358. //-----------------------------------------------------------------------------
  359. // struct mstudioikconstraint_t
  360. // {
  361. // DECLARE_BYTESWAP_DATADESC();
  362. //
  363. // mstudioikconstraint_t() {}
  364. // private:
  365. // // No copy constructors allowed
  366. // mstudioikconstraint_t( const mstudioaimconstraint_t &vOther );
  367. // };
  368. //-----------------------------------------------------------------------------
  369. // Parent constraint, slave position and orientation are updated to behave as children of the target
  370. //-----------------------------------------------------------------------------
  371. // struct mstudioparentconstraint_t
  372. // {
  373. // DECLARE_BYTESWAP_DATADESC();
  374. //
  375. // mstudioconstraintslave_t m_slave; // DEFINE_EMBEDDED
  376. //
  377. // int m_nTargetCount;
  378. // int m_nTargetIndex;
  379. // inline mstudioconstrainttarget_t *pTarget( int i ) const { return ( mstudioconstrainttarget_t * )( ( ( byte * )this) + m_nTargetIndex ) + i; }
  380. //
  381. // mstudioparentconstraint_t() {}
  382. // private:
  383. // // No copy constructors allowed
  384. // mstudioparentconstraint_t( const mstudioparentconstraint_t &vOther );
  385. // };
  386. // bones
  387. struct mstudiobone_t_PS3
  388. {
  389. // DECLARE_BYTESWAP_DATADESC();
  390. int sznameindex;
  391. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  392. int parent; // parent bone
  393. int bonecontroller[6]; // bone controller index, -1 == none
  394. // default values
  395. Vector pos;
  396. Quaternion quat;
  397. RadianEuler rot;
  398. // compression scale
  399. Vector posscale;
  400. Vector rotscale;
  401. matrix3x4_t poseToBone;
  402. Quaternion qAlignment;
  403. int flags;
  404. int proctype;
  405. int procindex; // procedural rule
  406. mutable int physicsbone; // index into physically simulated bone
  407. // inline void *pProcedure( ) const { if (procindex == 0) return NULL; else return (void *)(((byte *)this) + procindex); };
  408. int surfacepropidx; // index into string tablefor property name
  409. // inline char * const pszSurfaceProp( void ) const { return ((char *)this) + surfacepropidx; }
  410. // inline int GetSurfaceProp( void ) const { return surfacepropLookup; }
  411. int contents; // See BSPFlags.h for the contents flags
  412. int surfacepropLookup; // this index must be cached by the loader, not saved in the file
  413. int unused[7]; // remove as appropriate
  414. mstudiobone_t_PS3(){}
  415. private:
  416. // No copy constructors allowed
  417. mstudiobone_t_PS3(const mstudiobone_t_PS3& vOther);
  418. };
  419. // middle chunk from mstudiobone_t_PS3
  420. struct mstudiobone_t_PS3_postoqalignment
  421. {
  422. Vector pos;
  423. Quaternion quat;
  424. RadianEuler rot;
  425. Vector posscale;
  426. Vector rotscale;
  427. matrix3x4_t poseToBone;
  428. Quaternion qAlignment;
  429. int flags;
  430. };
  431. struct mstudiolinearbone_t_PS3
  432. {
  433. // DECLARE_BYTESWAP_DATADESC();
  434. int numbones;
  435. int flagsindex;
  436. // inline int flags( int i ) const { Assert( i >= 0 && i < numbones); return *((int *)(((byte *)this) + flagsindex) + i); };
  437. // inline int *pflags( int i ) { Assert( i >= 0 && i < numbones); return ((int *)(((byte *)this) + flagsindex) + i); };
  438. int parentindex;
  439. // inline int parent( int i ) const { Assert( i >= 0 && i < numbones); return *((int *)(((byte *)this) + parentindex) + i); };
  440. int posindex;
  441. // inline const Vector &pos( byte *pEA_this, int i ) const { Assert( i >= 0 && i < numbones); return (Vector *)((pEA_this) + posindex) + i; };
  442. int quatindex;
  443. // inline const Quaternion &quat( int i ) const { Assert( i >= 0 && i < numbones); return *((Quaternion *)((pEA_this) + quatindex) + i); };
  444. int rotindex;
  445. // inline const RadianEuler &rot( int i ) const { Assert( i >= 0 && i < numbones); return *((RadianEuler *)(((byte *)this) + rotindex) + i); };
  446. int posetoboneindex;
  447. // inline const matrix3x4_t &poseToBone( int i ) const { Assert( i >= 0 && i < numbones); return *((matrix3x4_t *)(((byte *)this) + posetoboneindex) + i); };
  448. int posscaleindex;
  449. // inline const Vector &posscale( int i ) const { Assert( i >= 0 && i < numbones); return *((Vector *)(((byte *)this) + posscaleindex) + i); };
  450. int rotscaleindex;
  451. // inline const Vector &rotscale( int i ) const { Assert( i >= 0 && i < numbones); return *((Vector *)(((byte *)this) + rotscaleindex) + i); };
  452. int qalignmentindex;
  453. // inline const Quaternion &qalignment( int i ) const { Assert( i >= 0 && i < numbones); return *((Quaternion *)(((byte *)this) + qalignmentindex) + i); };
  454. int unused[6];
  455. mstudiolinearbone_t_PS3(){}
  456. private:
  457. // No copy constructors allowed
  458. mstudiolinearbone_t_PS3(const mstudiolinearbone_t_PS3& vOther);
  459. };
  460. //-----------------------------------------------------------------------------
  461. // The component of the bone used by mstudioboneflexdriver_t
  462. //-----------------------------------------------------------------------------
  463. // enum StudioBoneFlexComponent_t
  464. // {
  465. // STUDIO_BONE_FLEX_INVALID = -1, // Invalid
  466. // STUDIO_BONE_FLEX_TX = 0, // Translate X
  467. // STUDIO_BONE_FLEX_TY = 1, // Translate Y
  468. // STUDIO_BONE_FLEX_TZ = 2 // Translate Z
  469. // };
  470. //-----------------------------------------------------------------------------
  471. // Component is one of Translate X, Y or Z [0,2] (StudioBoneFlexComponent_t)
  472. //-----------------------------------------------------------------------------
  473. // struct mstudioboneflexdrivercontrol_t
  474. // {
  475. // DECLARE_BYTESWAP_DATADESC();
  476. //
  477. // int m_nBoneComponent; // Bone component that drives flex, StudioBoneFlexComponent_t
  478. // int m_nFlexControllerIndex; // Flex controller to drive
  479. // float m_flMin; // Min value of bone component mapped to 0 on flex controller
  480. // float m_flMax; // Max value of bone component mapped to 1 on flex controller
  481. //
  482. // mstudioboneflexdrivercontrol_t(){}
  483. // private:
  484. // // No copy constructors allowed
  485. // mstudioboneflexdrivercontrol_t( const mstudioboneflexdrivercontrol_t &vOther );
  486. // };
  487. //-----------------------------------------------------------------------------
  488. // Drive flex controllers from bone components
  489. //-----------------------------------------------------------------------------
  490. // struct mstudioboneflexdriver_t
  491. // {
  492. // DECLARE_BYTESWAP_DATADESC();
  493. //
  494. // int m_nBoneIndex; // Bone to drive flex controller
  495. // int m_nControlCount; // Number of flex controllers being driven
  496. // int m_nControlIndex; // Index into data where controllers are (relative to this)
  497. //
  498. // inline mstudioboneflexdrivercontrol_t *pBoneFlexDriverControl( int i ) const
  499. // {
  500. // Assert( i >= 0 && i < m_nControlCount );
  501. // return (mstudioboneflexdrivercontrol_t *)(((byte *)this) + m_nControlIndex) + i;
  502. // }
  503. //
  504. // int unused[3];
  505. //
  506. // mstudioboneflexdriver_t(){}
  507. // private:
  508. // // No copy constructors allowed
  509. // mstudioboneflexdriver_t( const mstudioboneflexdriver_t &vOther );
  510. // };
  511. // #define BONE_CALCULATE_MASK 0x1F
  512. // #define BONE_PHYSICALLY_SIMULATED 0x01 // bone is physically simulated when physics are active
  513. // #define BONE_PHYSICS_PROCEDURAL 0x02 // procedural when physics is active
  514. // #define BONE_ALWAYS_PROCEDURAL 0x04 // bone is always procedurally animated
  515. // #define BONE_SCREEN_ALIGN_SPHERE 0x08 // bone aligns to the screen, not constrained in motion.
  516. // #define BONE_SCREEN_ALIGN_CYLINDER 0x10 // bone aligns to the screen, constrained by it's own axis.
  517. //
  518. // #define BONE_USED_MASK 0x0007FF00
  519. // #define BONE_USED_BY_ANYTHING 0x0007FF00
  520. // #define BONE_USED_BY_HITBOX 0x00000100 // bone (or child) is used by a hit box
  521. // #define BONE_USED_BY_ATTACHMENT 0x00000200 // bone (or child) is used by an attachment point
  522. // #define BONE_USED_BY_VERTEX_MASK 0x0003FC00
  523. // #define BONE_USED_BY_VERTEX_LOD0 0x00000400 // bone (or child) is used by the toplevel model via skinned vertex
  524. // #define BONE_USED_BY_VERTEX_LOD1 0x00000800
  525. // #define BONE_USED_BY_VERTEX_LOD2 0x00001000
  526. // #define BONE_USED_BY_VERTEX_LOD3 0x00002000
  527. // #define BONE_USED_BY_VERTEX_LOD4 0x00004000
  528. // #define BONE_USED_BY_VERTEX_LOD5 0x00008000
  529. // #define BONE_USED_BY_VERTEX_LOD6 0x00010000
  530. // #define BONE_USED_BY_VERTEX_LOD7 0x00020000
  531. // #define BONE_USED_BY_BONE_MERGE 0x00040000 // bone is available for bone merge to occur against it
  532. //
  533. // #define BONE_USED_BY_VERTEX_AT_LOD(lod) ( BONE_USED_BY_VERTEX_LOD0 << (lod) )
  534. // #define BONE_USED_BY_ANYTHING_AT_LOD(lod) ( ( BONE_USED_BY_ANYTHING & ~BONE_USED_BY_VERTEX_MASK ) | BONE_USED_BY_VERTEX_AT_LOD(lod) )
  535. //
  536. // #define MAX_NUM_LODS 8
  537. //
  538. // #define BONE_TYPE_MASK 0x00F00000
  539. // #define BONE_FIXED_ALIGNMENT 0x00100000 // bone can't spin 360 degrees, all interpolation is normalized around a fixed orientation
  540. //
  541. // #define BONE_HAS_SAVEFRAME_POS 0x00200000 // Vector48
  542. // #define BONE_HAS_SAVEFRAME_ROT64 0x00400000 // Quaternion64
  543. // #define BONE_HAS_SAVEFRAME_ROT32 0x00800000 // Quaternion32
  544. // bone controllers
  545. struct mstudiobonecontroller_t_PS3
  546. {
  547. // DECLARE_BYTESWAP_DATADESC();
  548. int bone; // -1 == 0
  549. int type; // X, Y, Z, XR, YR, ZR, M
  550. float start;
  551. float end;
  552. int rest; // byte index value at rest
  553. int inputfield; // 0-3 user set controller, 4 mouth
  554. int unused[8];
  555. };
  556. // intersection boxes
  557. struct mstudiobbox_t_PS3
  558. {
  559. // DECLARE_BYTESWAP_DATADESC();
  560. int bone;
  561. int group; // intersection group
  562. Vector bbmin; // bounding box
  563. Vector bbmax;
  564. int szhitboxnameindex; // offset to the name of the hitbox.
  565. int unused[8];
  566. // const char* pszHitboxName() const
  567. // {
  568. // if( szhitboxnameindex == 0 )
  569. // return "";
  570. //
  571. // return ((const char*)this) + szhitboxnameindex;
  572. // }
  573. mstudiobbox_t_PS3() {}
  574. private:
  575. // No copy constructors allowed
  576. mstudiobbox_t_PS3(const mstudiobbox_t_PS3& vOther);
  577. };
  578. // demand loaded sequence groups
  579. // struct mstudiomodelgroup_t_PS3
  580. // {
  581. // DECLARE_BYTESWAP_DATADESC();
  582. // int szlabelindex; // textual name
  583. // inline char * const pszLabel( void ) const { return ((char *)this) + szlabelindex; }
  584. // int sznameindex; // file name
  585. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  586. // };
  587. // struct mstudiomodelgrouplookup_t
  588. // {
  589. // int modelgroup;
  590. // int indexwithingroup;
  591. // };
  592. // events
  593. // NOTE: If you modify this struct you MUST also modify mstudioevent_for_client_server_t in npcevent.h!!!
  594. // struct mstudioevent_t
  595. // {
  596. // DECLARE_BYTESWAP_DATADESC();
  597. // float cycle;
  598. // int event;
  599. // int type;
  600. // inline const char * pszOptions( void ) const { return options; }
  601. // char options[64];
  602. //
  603. // int szeventindex;
  604. // inline char * const pszEventName( void ) const { return ((char *)this) + szeventindex; }
  605. // };
  606. //#define ATTACHMENT_FLAG_WORLD_ALIGN 0x10000
  607. // attachment
  608. struct mstudioattachment_t_PS3
  609. {
  610. // DECLARE_BYTESWAP_DATADESC();
  611. int sznameindex;
  612. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  613. unsigned int flags;
  614. int localbone;
  615. matrix3x4_t local; // attachment point
  616. int unused[8];
  617. };
  618. #if defined(__SPU__)
  619. #define IK_SELF 1
  620. #define IK_WORLD 2
  621. #define IK_GROUND 3
  622. #define IK_RELEASE 4
  623. #define IK_ATTACHMENT 5
  624. #define IK_UNLATCH 6
  625. #endif
  626. struct mstudioikerror_t_PS3
  627. {
  628. // DECLARE_BYTESWAP_DATADESC();
  629. Vector pos;
  630. Quaternion q;
  631. mstudioikerror_t_PS3() {}
  632. private:
  633. // No copy constructors allowed
  634. mstudioikerror_t_PS3(const mstudioikerror_t_PS3& vOther);
  635. };
  636. union mstudioanimvalue_t_PS3;
  637. struct mstudiocompressedikerror_t_PS3
  638. {
  639. // DECLARE_BYTESWAP_DATADESC();
  640. float scale[6];
  641. short offset[6];
  642. inline mstudioanimvalue_t_PS3 *pAnimvalue( void *pEA_this, int i ) const { if (offset[i] > 0) return (mstudioanimvalue_t_PS3 *)(((byte *)pEA_this) + offset[i]); else return NULL; };
  643. mstudiocompressedikerror_t_PS3(){}
  644. private:
  645. // No copy constructors allowed
  646. mstudiocompressedikerror_t_PS3(const mstudiocompressedikerror_t_PS3& vOther);
  647. };
  648. struct mstudioikrule_t_PS3
  649. {
  650. // DECLARE_BYTESWAP_DATADESC();
  651. int index;
  652. int type;
  653. int chain;
  654. int bone;
  655. int slot; // iktarget slot. Usually same as chain.
  656. float height;
  657. float radius;
  658. float floor;
  659. Vector pos;
  660. Quaternion q;
  661. int compressedikerrorindex;
  662. // inline mstudiocompressedikerror_t *pCompressedError() const { return (mstudiocompressedikerror_t *)(((byte *)this) + compressedikerrorindex); };
  663. inline mstudiocompressedikerror_t_PS3 *pCompressedError( void *pEA_this ) const { return (mstudiocompressedikerror_t_PS3 *)(((byte *)pEA_this) + compressedikerrorindex); };
  664. int unused2;
  665. int iStart;
  666. int ikerrorindex;
  667. // inline mstudioikerror_t *pError( int i ) const { return (ikerrorindex) ? (mstudioikerror_t *)(((byte *)this) + ikerrorindex) + (i - iStart) : NULL; };
  668. inline mstudioikerror_t_PS3 *pError( void *pEA_this, int i ) const { return (ikerrorindex) ? (mstudioikerror_t_PS3 *)(((byte *)pEA_this) + ikerrorindex) + (i - iStart) : NULL; };
  669. float start; // beginning of influence
  670. float peak; // start of full influence
  671. float tail; // end of full influence
  672. float end; // end of all influence
  673. float unused3; //
  674. float contact; // frame footstep makes ground concact
  675. float drop; // how far down the foot should drop when reaching for IK
  676. float top; // top of the foot box
  677. int unused6;
  678. int unused7;
  679. int unused8;
  680. int szattachmentindex; // name of world attachment
  681. // inline char * const pszAttachment( void ) const { return ((char *)this) + szattachmentindex; }
  682. int unused[7];
  683. // int unused[6];
  684. // void* pEA_this;
  685. mstudioikrule_t_PS3() {}
  686. private:
  687. // No copy constructors allowed
  688. mstudioikrule_t_PS3(const mstudioikrule_t_PS3& vOther);
  689. };
  690. struct mstudioikrulezeroframe_t_PS3
  691. {
  692. short chain;
  693. short slot;
  694. float16 start; // beginning of influence
  695. float16 peak; // start of full influence
  696. float16 tail; // end of full influence
  697. float16 end; // end of all influence
  698. };
  699. struct mstudioiklock_t_PS3
  700. {
  701. // DECLARE_BYTESWAP_DATADESC();
  702. int chain;
  703. float flPosWeight;
  704. float flLocalQWeight;
  705. int flags;
  706. int unused[4];
  707. };
  708. // struct mstudiolocalhierarchy_t
  709. // {
  710. // DECLARE_BYTESWAP_DATADESC();
  711. // int iBone; // bone being adjusted
  712. // int iNewParent; // the bones new parent
  713. //
  714. // float start; // beginning of influence
  715. // float peak; // start of full influence
  716. // float tail; // end of full influence
  717. // float end; // end of all influence
  718. //
  719. // int iStart; // first frame
  720. //
  721. // int localanimindex;
  722. // inline mstudiocompressedikerror_t *pLocalAnim() const { return (mstudiocompressedikerror_t *)(((byte *)this) + localanimindex); };
  723. //
  724. // int unused[4];
  725. // };
  726. // animation frames
  727. union mstudioanimvalue_t_PS3
  728. {
  729. struct
  730. {
  731. byte valid;
  732. byte total;
  733. } num;
  734. short value;
  735. };
  736. struct mstudioanim_valueptr_t_PS3
  737. {
  738. // DECLARE_BYTESWAP_DATADESC();
  739. short offset[3];
  740. inline mstudioanimvalue_t_PS3 *pAnimvalue( void *pEA_this, int i ) const { if (offset[i] > 0) return (mstudioanimvalue_t_PS3 *)(((byte *)pEA_this) + offset[i]); else return NULL; };
  741. };
  742. #if defined(__SPU__)
  743. #define STUDIO_ANIM_RAWPOS 0x01 // Vector48
  744. #define STUDIO_ANIM_RAWROT 0x02 // Quaternion48
  745. #define STUDIO_ANIM_ANIMPOS 0x04 // mstudioanim_valueptr_t
  746. #define STUDIO_ANIM_ANIMROT 0x08 // mstudioanim_valueptr_t
  747. #define STUDIO_ANIM_DELTA 0x10
  748. #define STUDIO_ANIM_RAWROT2 0x20 // Quaternion64
  749. #endif
  750. // per bone per animation DOF and weight pointers, RLE encoded
  751. struct mstudio_rle_anim_t_PS3
  752. {
  753. // DECLARE_BYTESWAP_DATADESC();
  754. byte bone;
  755. byte flags; // weighing options
  756. // valid for animating data only
  757. inline byte *pData( void *pEA_this ) const { return (((byte *)pEA_this) + sizeof( struct mstudio_rle_anim_t_PS3 )); };
  758. inline mstudioanim_valueptr_t_PS3 *pRotV( void *pEA_this ) const { return (mstudioanim_valueptr_t_PS3 *)(pData( pEA_this )); };
  759. inline mstudioanim_valueptr_t_PS3 *pPosV( void *pEA_this ) const { return (mstudioanim_valueptr_t_PS3 *)(pData( pEA_this )) + ((flags & STUDIO_ANIM_ANIMROT) != 0); };
  760. // valid if animation unvaring over timeline
  761. inline Quaternion48 *pQuat48( void *pEA_this ) const { return (Quaternion48 *)(pData( pEA_this )); };
  762. inline Quaternion64 *pQuat64( void *pEA_this ) const { return (Quaternion64 *)(pData( pEA_this )); };
  763. inline Vector48 *pPos( void *pEA_this ) const { return (Vector48 *)(pData( pEA_this ) + ((flags & STUDIO_ANIM_RAWROT) != 0) * sizeof( *pQuat48( pEA_this ) ) + ((flags & STUDIO_ANIM_RAWROT2) != 0) * sizeof( *pQuat64( pEA_this ) ) ); };
  764. // inline Vector48 *pPos( void *pEA_this ) const { return (Vector48 *)(pData( pEA_this ) + ((flags & STUDIO_ANIM_RAWROT) != 0) * sizeof( Quaternion48 ) + ((flags & STUDIO_ANIM_RAWROT2) != 0) * sizeof( Quaternion64 ) ); };
  765. // points to next bone in the list
  766. short nextoffset;
  767. inline mstudio_rle_anim_t_PS3 *pNext( void *pEA_this ) const { if (nextoffset != 0) return (mstudio_rle_anim_t_PS3 *)(((byte *)pEA_this) + nextoffset); else return NULL; };
  768. };
  769. // #define STUDIO_FRAME_CONST_POS 0x01 // Vector48 in constants
  770. // #define STUDIO_FRAME_CONST_ROT 0x02 // Quaternion48 in constants
  771. // #define STUDIO_FRAME_ANIM_POS 0x04 // Vector48 in framedata
  772. // #define STUDIO_FRAME_ANIM_ROT 0x08 // Quaternion48 in framedata
  773. // #define STUDIO_FRAME_ANIM_POS2 0x10 // Vector in framedata
  774. // #define STUDIO_FRAME_CONST_POS2 0x20 // Vector in constants
  775. // #define STUDIO_FRAME_CONST_ROT2 0x40 // Quaternion48S in constants
  776. // #define STUDIO_FRAME_ANIM_ROT2 0x80 // Quaternion48S in framedata
  777. struct mstudio_frame_anim_t_PS3
  778. {
  779. // DECLARE_BYTESWAP_DATADESC();
  780. inline byte *pBoneFlags( void *pEA_this ) const { return (((byte *)pEA_this) + sizeof( struct mstudio_frame_anim_t_PS3 )); };
  781. int constantsoffset;
  782. inline byte *pConstantData( void *pEA_this ) const { return (((byte *)pEA_this) + constantsoffset); };
  783. int frameoffset;
  784. int framelength;
  785. inline byte *pFrameData( void *pEA_this, int iFrame ) const { return (((byte *)pEA_this) + frameoffset + iFrame * framelength); };
  786. int unused[3];
  787. };
  788. // struct mstudiomovement_t_PS3
  789. // {
  790. // // DECLARE_BYTESWAP_DATADESC();
  791. // int endframe;
  792. // int motionflags;
  793. // float v0; // velocity at start of block
  794. // float v1; // velocity at end of block
  795. // float angle; // YAW rotation at end of this blocks movement
  796. // Vector vector; // movement vector relative to this blocks initial angle
  797. // Vector position; // relative to start of animation???
  798. //
  799. // mstudiomovement_t_PS3(){}
  800. // private:
  801. // // No copy constructors allowed
  802. // mstudiomovement_t_PS3(const mstudiomovement_t_PS3& vOther);
  803. // };
  804. // used for piecewise loading of animation data
  805. struct mstudioanimblock_t_PS3
  806. {
  807. // DECLARE_BYTESWAP_DATADESC();
  808. int datastart;
  809. int dataend;
  810. };
  811. struct mstudioanimsections_t_PS3
  812. {
  813. // DECLARE_BYTESWAP_DATADESC();
  814. int animblock;
  815. int animindex;
  816. };
  817. struct mstudioanimdesc_t_PS3
  818. {
  819. // DECLARE_BYTESWAP_DATADESC();
  820. int baseptr;
  821. // inline studiohdr_t *pStudiohdr( void ) const { return (studiohdr_t *)(((byte *)this) + baseptr); }
  822. // inline studiohdr_t *pStudiohdr( void *pEA_this ) const { return (studiohdr_t *)(((byte *)pEA_this) + baseptr); }
  823. int sznameindex;
  824. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  825. inline char * const pszName( void *pEA_this ) const { return ((char *)pEA_this) + sznameindex; }
  826. float fps; // frames per second
  827. int flags; // looping/non-looping flags
  828. int numframes;
  829. // piecewise movement
  830. int nummovements;
  831. int movementindex;
  832. // inline mstudiomovement_t * const pMovement( int i ) const { return (mstudiomovement_t *)(((byte *)this) + movementindex) + i; };
  833. // inline mstudiomovement_t * const pMovement( void *pEA_this, int i ) const { return (mstudiomovement_t *)(((byte *)pEA_this) + movementindex) + i; };
  834. int ikrulezeroframeindex;
  835. // mstudioikrulezeroframe_t *pIKRuleZeroFrame( int i ) const { if (ikrulezeroframeindex) return (mstudioikrulezeroframe_t *)(((byte *)this) + ikrulezeroframeindex) + i; else return NULL; };
  836. // mstudioikrulezeroframe_t *pIKRuleZeroFrame( void *pEA_this, int i ) const { if (ikrulezeroframeindex) return (mstudioikrulezeroframe_t *)(((byte *)pEA_this) + ikrulezeroframeindex) + i; else return NULL; };
  837. int unused1[5]; // remove as appropriate (and zero if loading older versions)
  838. int animblock;
  839. int animindex; // non-zero when anim data isn't in sections
  840. // byte *pAnimBlock( int block, int index, bool preloadIfMissing = true) const; // returns pointer to a specific anim block (local or external)
  841. // bool hasAnimBlockBeenPreloaded( int block ) const;
  842. // byte *pAnim( int *piFrame, float &flStall ) const; // returns pointer to data and new frame index
  843. // byte *pAnim( int *piFrame ) const; // returns pointer to data and new frame index
  844. int numikrules;
  845. int ikruleindex; // non-zero when IK rule is stored in the mdl
  846. int animblockikruleindex; // non-zero when IK data is stored in animblock file
  847. // mstudioikrule_t *pIKRule( int i ) const;
  848. int numlocalhierarchy;
  849. int localhierarchyindex;
  850. // mstudiolocalhierarchy_t *pHierarchy( int i ) const;
  851. int sectionindex;
  852. int sectionframes; // number of frames used in each fast lookup section, zero if not used
  853. // inline mstudioanimsections_t * const pSection( int i ) const { return (mstudioanimsections_t *)(((byte *)this) + sectionindex) + i; }
  854. // inline mstudioanimsections_t * const pSection( void *pEA_this, int i ) const { return (mstudioanimsections_t *)(((byte *)pEA_this) + sectionindex) + i; }
  855. short zeroframespan; // frames per span
  856. short zeroframecount; // number of spans
  857. int zeroframeindex;
  858. // byte *pZeroFrameData( ) const { if (zeroframeindex) return (((byte *)this) + zeroframeindex); else return NULL; };
  859. byte *pZeroFrameData( void *pEA_this ) const { if (zeroframeindex) return (((byte *)pEA_this) + zeroframeindex); else return NULL; };
  860. mutable float zeroframestalltime; // saved during read stalls
  861. mstudioanimdesc_t_PS3(){}
  862. private:
  863. // No copy constructors allowed
  864. mstudioanimdesc_t_PS3(const mstudioanimdesc_t_PS3& vOther);
  865. };
  866. struct mstudioikrule_t_PS3;
  867. struct mstudioautolayer_t_PS3
  868. {
  869. // DECLARE_BYTESWAP_DATADESC();
  870. //private:
  871. short iSequence;
  872. short iPose;
  873. //public:
  874. int flags;
  875. float start; // beginning of influence
  876. float peak; // start of full influence
  877. float tail; // end of full influence
  878. float end; // end of all influence
  879. };
  880. // struct mstudioactivitymodifier_t
  881. // {
  882. // DECLARE_BYTESWAP_DATADESC();
  883. //
  884. // int sznameindex;
  885. // inline char *pszName() { return (sznameindex) ? (char *)(((byte *)this) + sznameindex ) : NULL; }
  886. // };
  887. // sequence descriptions
  888. struct mstudioseqdesc_t_PS3
  889. {
  890. // DECLARE_BYTESWAP_DATADESC();
  891. int baseptr;
  892. // inline studiohdr_t *pStudiohdr( void *pEA_this ) const { return (studiohdr_t *)(((byte *)pEA_this) + baseptr); }
  893. int szlabelindex;
  894. // inline char * const pszLabel( void *pEA_this ) const { return ((char *)pEA_this) + szlabelindex; }
  895. int szactivitynameindex;
  896. // inline char * const pszActivityName( void ) const { return ((char *)this) + szactivitynameindex; }
  897. // inline char * const pszActivityName( void ) const { return pEA_this + szactivitynameindex; }
  898. int flags; // looping/non-looping flags
  899. int activity; // initialized at loadtime to game DLL values
  900. int actweight;
  901. int numevents;
  902. int eventindex;
  903. // inline mstudioevent_t *pEvent( int i ) const { Assert( i >= 0 && i < numevents); return (mstudioevent_t *)(((byte *)this) + eventindex) + i; };
  904. // inline mstudioevent_t *pEvent( int i ) const { Assert( i >= 0 && i < numevents); return (mstudioevent_t *)(pEA_this + eventindex) + i; };
  905. Vector bbmin; // per sequence bounding box
  906. Vector bbmax;
  907. int numblends;
  908. // Index into array of shorts which is groupsize[0] x groupsize[1] in length
  909. int animindexindex;
  910. inline int anim( void *pEA_this, int x, int y ) const
  911. {
  912. if ( x >= groupsize[0] )
  913. {
  914. x = groupsize[0] - 1;
  915. }
  916. if ( y >= groupsize[1] )
  917. {
  918. y = groupsize[ 1 ] - 1;
  919. }
  920. int offset = y * groupsize[0] + x;
  921. short *blends = (short *)(((byte *)pEA_this) + animindexindex);
  922. int value = (int)blends[ offset ];
  923. return value;
  924. }
  925. int movementindex; // [blend] float array for blended movement
  926. int groupsize[2];
  927. int paramindex[2]; // X, Y, Z, XR, YR, ZR
  928. float paramstart[2]; // local (0..1) starting value
  929. float paramend[2]; // local (0..1) ending value
  930. int paramparent;
  931. float fadeintime; // ideal cross fate in time (0.2 default)
  932. float fadeouttime; // ideal cross fade out time (0.2 default)
  933. int localentrynode; // transition node at entry
  934. int localexitnode; // transition node at exit
  935. int nodeflags; // transition rules
  936. float entryphase; // used to match entry gait
  937. float exitphase; // used to match exit gait
  938. float lastframe; // frame that should generation EndOfSequence
  939. int nextseq; // auto advancing sequences
  940. int pose; // index of delta animation between end and nextseq
  941. int numikrules;
  942. int numautolayers; //
  943. int autolayerindex;
  944. // inline mstudioautolayer_t *pAutolayer( int i ) const { Assert( i >= 0 && i < numautolayers); return (mstudioautolayer_t *)(((byte *)this) + autolayerindex) + i; };
  945. // inline mstudioautolayer_t *pAutolayer( int i ) const { Assert( i >= 0 && i < numautolayers); return (mstudioautolayer_t *)(pEA_this + autolayerindex) + i; };
  946. int weightlistindex;
  947. inline float *pBoneweight( void *pEA_this, int i ) const { return ((float *)(((byte *)pEA_this) + weightlistindex) + i); };
  948. inline float weight( void *pEA_this, int i ) const { return *(pBoneweight( pEA_this, i )); };
  949. // FIXME: make this 2D instead of 2x1D arrays
  950. int posekeyindex;
  951. // float *pPoseKey( int iParam, int iAnim ) const { return (float *)(((byte *)this) + posekeyindex) + iParam * groupsize[0] + iAnim; }
  952. // float poseKey( int iParam, int iAnim ) const { return *(pPoseKey( iParam, iAnim )); }
  953. int numiklocks;
  954. int iklockindex;
  955. inline mstudioiklock_t_PS3 *pIKLock( void *pEA_this, int i ) const { Assert( i >= 0 && i < numiklocks); return (mstudioiklock_t_PS3 *)(((byte *)pEA_this) + iklockindex) + i; };
  956. // Key values
  957. int keyvalueindex;
  958. int keyvaluesize;
  959. // inline const char * KeyValueText( void ) const { return keyvaluesize != 0 ? ((char *)this) + keyvalueindex : NULL; }
  960. int cycleposeindex; // index of pose parameter to use as cycle index
  961. int activitymodifierindex;
  962. int numactivitymodifiers;
  963. // inline mstudioactivitymodifier_t *pActivityModifier( int i ) const { Assert( i >= 0 && i < numactivitymodifiers); return activitymodifierindex != 0 ? (mstudioactivitymodifier_t *)(((byte *)this) + activitymodifierindex) + i : NULL; };
  964. int unused[5]; // remove/add as appropriate (grow back to 8 ints on version change!)
  965. mstudioseqdesc_t_PS3(){}
  966. private:
  967. // No copy constructors allowed
  968. mstudioseqdesc_t_PS3(const mstudioseqdesc_t_PS3& vOther);
  969. };
  970. struct mstudioposeparamdesc_t_PS3
  971. {
  972. // DECLARE_BYTESWAP_DATADESC();
  973. int sznameindex;
  974. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  975. int flags; // ????
  976. float start; // starting value
  977. float end; // ending value
  978. float loop; // looping range, 0 for no looping, 360 for rotations, etc.
  979. };
  980. // struct mstudioflexdesc_t
  981. // {
  982. // DECLARE_BYTESWAP_DATADESC();
  983. // int szFACSindex;
  984. // inline char * const pszFACS( void ) const { return ((char *)this) + szFACSindex; }
  985. // };
  986. // struct mstudioflexcontroller_t
  987. // {
  988. // DECLARE_BYTESWAP_DATADESC();
  989. // int sztypeindex;
  990. // inline char * const pszType( void ) const { return ((char *)this) + sztypeindex; }
  991. // int sznameindex;
  992. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  993. // mutable int localToGlobal; // remapped at load time to master list
  994. // float min;
  995. // float max;
  996. // };
  997. // enum FlexControllerRemapType_t
  998. // {
  999. // FLEXCONTROLLER_REMAP_PASSTHRU = 0,
  1000. // FLEXCONTROLLER_REMAP_2WAY, // Control 0 -> ramps from 1-0 from 0->0.5. Control 1 -> ramps from 0-1 from 0.5->1
  1001. // FLEXCONTROLLER_REMAP_NWAY, // StepSize = 1 / (control count-1) Control n -> ramps from 0-1-0 from (n-1)*StepSize to n*StepSize to (n+1)*StepSize. A second control is needed to specify amount to use
  1002. // FLEXCONTROLLER_REMAP_EYELID
  1003. // };
  1004. //class CStudioHdr_PS3;
  1005. // struct mstudioflexcontrollerui_t
  1006. // {
  1007. // DECLARE_BYTESWAP_DATADESC();
  1008. // int sznameindex;
  1009. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  1010. //
  1011. // // These are used like a union to save space
  1012. // // Here are the possible configurations for a UI controller
  1013. // //
  1014. // // SIMPLE NON-STEREO: 0: control 1: unused 2: unused
  1015. // // STEREO: 0: left 1: right 2: unused
  1016. // // NWAY NON-STEREO: 0: control 1: unused 2: value
  1017. // // NWAY STEREO: 0: left 1: right 2: value
  1018. //
  1019. // int szindex0;
  1020. // int szindex1;
  1021. // int szindex2;
  1022. //
  1023. // inline const mstudioflexcontroller_t *pController( void ) const
  1024. // {
  1025. // return !stereo ? (mstudioflexcontroller_t *)( (char *)this + szindex0 ) : NULL;
  1026. // }
  1027. // inline char * const pszControllerName( void ) const { return !stereo ? pController()->pszName() : NULL; }
  1028. // inline int controllerIndex( const CStudioHdr &cStudioHdr ) const;
  1029. //
  1030. // inline const mstudioflexcontroller_t *pLeftController( void ) const
  1031. // {
  1032. // return stereo ? (mstudioflexcontroller_t *)( (char *)this + szindex0 ) : NULL;
  1033. // }
  1034. // inline char * const pszLeftName( void ) const { return stereo ? pLeftController()->pszName() : NULL; }
  1035. // inline int leftIndex( const CStudioHdr &cStudioHdr ) const;
  1036. //
  1037. // inline const mstudioflexcontroller_t *pRightController( void ) const
  1038. // {
  1039. // return stereo ? (mstudioflexcontroller_t *)( (char *)this + szindex1 ): NULL;
  1040. // }
  1041. // inline char * const pszRightName( void ) const { return stereo ? pRightController()->pszName() : NULL; }
  1042. // inline int rightIndex( const CStudioHdr &cStudioHdr ) const;
  1043. //
  1044. // inline const mstudioflexcontroller_t *pNWayValueController( void ) const
  1045. // {
  1046. // return remaptype == FLEXCONTROLLER_REMAP_NWAY ? (mstudioflexcontroller_t *)( (char *)this + szindex2 ) : NULL;
  1047. // }
  1048. // inline char * const pszNWayValueName( void ) const { return remaptype == FLEXCONTROLLER_REMAP_NWAY ? pNWayValueController()->pszName() : NULL; }
  1049. // inline int nWayValueIndex( const CStudioHdr &cStudioHdr ) const;
  1050. //
  1051. // // Number of controllers this ui description contains, 1, 2 or 3
  1052. // inline int Count() const { return ( stereo ? 2 : 1 ) + ( remaptype == FLEXCONTROLLER_REMAP_NWAY ? 1 : 0 ); }
  1053. // inline const mstudioflexcontroller_t *pController( int index ) const;
  1054. //
  1055. // unsigned char remaptype; // See the FlexControllerRemapType_t enum
  1056. // bool stereo; // Is this a stereo control?
  1057. // byte unused[2];
  1058. // };
  1059. // this is the memory image of vertex anims (16-bit fixed point)
  1060. // struct mstudiovertanim_t
  1061. // {
  1062. // DECLARE_BYTESWAP_DATADESC();
  1063. // unsigned short index;
  1064. // byte speed; // 255/max_length_in_flex
  1065. // byte side; // 255/left_right
  1066. //
  1067. // protected:
  1068. // union
  1069. // {
  1070. // short delta[3];
  1071. // float16 flDelta[3];
  1072. // };
  1073. //
  1074. // union
  1075. // {
  1076. // short ndelta[3];
  1077. // float16 flNDelta[3];
  1078. // };
  1079. //
  1080. // public:
  1081. // inline void ConvertToFixed( float flVertAnimFixedPointScale )
  1082. // {
  1083. // delta[0] = ( short )( flDelta[0].GetFloat() / flVertAnimFixedPointScale );
  1084. // delta[1] = ( short )( flDelta[1].GetFloat() / flVertAnimFixedPointScale );
  1085. // delta[2] = ( short )( flDelta[2].GetFloat() / flVertAnimFixedPointScale );
  1086. // ndelta[0] = ( short )( flNDelta[0].GetFloat() / flVertAnimFixedPointScale );
  1087. // ndelta[1] = ( short )( flNDelta[1].GetFloat() / flVertAnimFixedPointScale );
  1088. // ndelta[2] = ( short )( flNDelta[2].GetFloat() / flVertAnimFixedPointScale );
  1089. // }
  1090. //
  1091. // inline Vector GetDeltaFixed( float flVertAnimFixedPointScale )
  1092. // {
  1093. // return Vector( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale );
  1094. // }
  1095. // inline Vector GetNDeltaFixed( float flVertAnimFixedPointScale )
  1096. // {
  1097. // return Vector( ndelta[0] * flVertAnimFixedPointScale, ndelta[1] * flVertAnimFixedPointScale, ndelta[2] * flVertAnimFixedPointScale );
  1098. // }
  1099. // inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale )
  1100. // {
  1101. // vFillIn->Set( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, 0.0f );
  1102. // }
  1103. // inline void GetNDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale )
  1104. // {
  1105. // vFillIn->Set( ndelta[0] * flVertAnimFixedPointScale, ndelta[1] * flVertAnimFixedPointScale, ndelta[2] * flVertAnimFixedPointScale, 0.0f );
  1106. // }
  1107. // inline Vector GetDeltaFloat()
  1108. // {
  1109. // return Vector (flDelta[0].GetFloat(), flDelta[1].GetFloat(), flDelta[2].GetFloat());
  1110. // }
  1111. // inline Vector GetNDeltaFloat()
  1112. // {
  1113. // return Vector (flNDelta[0].GetFloat(), flNDelta[1].GetFloat(), flNDelta[2].GetFloat());
  1114. // }
  1115. // inline void SetDeltaFixed( const Vector& vInput, float flVertAnimFixedPointScale )
  1116. // {
  1117. // delta[0] = ( short )( vInput.x / flVertAnimFixedPointScale );
  1118. // delta[1] = ( short )( vInput.y / flVertAnimFixedPointScale );
  1119. // delta[2] = ( short )( vInput.z / flVertAnimFixedPointScale );
  1120. // }
  1121. // inline void SetNDeltaFixed( const Vector& vInputNormal, float flVertAnimFixedPointScale )
  1122. // {
  1123. // ndelta[0] = ( short )( vInputNormal.x / flVertAnimFixedPointScale );
  1124. // ndelta[1] = ( short )( vInputNormal.y / flVertAnimFixedPointScale );
  1125. // ndelta[2] = ( short )( vInputNormal.z / flVertAnimFixedPointScale );
  1126. // }
  1127. //
  1128. // // Ick...can also force fp16 data into this structure for writing to file in legacy format...
  1129. // inline void SetDeltaFloat( const Vector& vInput )
  1130. // {
  1131. // flDelta[0].SetFloat( vInput.x );
  1132. // flDelta[1].SetFloat( vInput.y );
  1133. // flDelta[2].SetFloat( vInput.z );
  1134. // }
  1135. // inline void SetNDeltaFloat( const Vector& vInputNormal )
  1136. // {
  1137. // flNDelta[0].SetFloat( vInputNormal.x );
  1138. // flNDelta[1].SetFloat( vInputNormal.y );
  1139. // flNDelta[2].SetFloat( vInputNormal.z );
  1140. // }
  1141. //
  1142. // class CSortByIndex
  1143. // {
  1144. // public:
  1145. // bool operator()(const mstudiovertanim_t &left, const mstudiovertanim_t & right)const
  1146. // {
  1147. // return left.index < right.index;
  1148. // }
  1149. // };
  1150. // friend class CSortByIndex;
  1151. //
  1152. // mstudiovertanim_t(){}
  1153. // //private:
  1154. // // No copy constructors allowed, but it's needed for std::sort()
  1155. // // mstudiovertanim_t(const mstudiovertanim_t& vOther);
  1156. // };
  1157. // this is the memory image of vertex anims (16-bit fixed point)
  1158. // struct mstudiovertanim_wrinkle_t : public mstudiovertanim_t
  1159. // {
  1160. // DECLARE_BYTESWAP_DATADESC();
  1161. //
  1162. // short wrinkledelta;
  1163. //
  1164. // inline void SetWrinkleFixed( float flWrinkle, float flVertAnimFixedPointScale )
  1165. // {
  1166. // int nWrinkleDeltaInt = ( int )( flWrinkle / flVertAnimFixedPointScale );
  1167. // wrinkledelta = clamp( nWrinkleDeltaInt, -32767, 32767 );
  1168. // }
  1169. //
  1170. // inline Vector4D GetDeltaFixed( float flVertAnimFixedPointScale )
  1171. // {
  1172. // return Vector4D( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, wrinkledelta * flVertAnimFixedPointScale );
  1173. // }
  1174. //
  1175. // inline void GetDeltaFixed4DAligned( Vector4DAligned *vFillIn, float flVertAnimFixedPointScale )
  1176. // {
  1177. // vFillIn->Set( delta[0] * flVertAnimFixedPointScale, delta[1] * flVertAnimFixedPointScale, delta[2] * flVertAnimFixedPointScale, wrinkledelta * flVertAnimFixedPointScale );
  1178. // }
  1179. //
  1180. // inline float GetWrinkleDeltaFixed( float flVertAnimFixedPointScale )
  1181. // {
  1182. // return wrinkledelta * flVertAnimFixedPointScale;
  1183. // }
  1184. // };
  1185. // enum StudioVertAnimType_t
  1186. // {
  1187. // STUDIO_VERT_ANIM_NORMAL = 0,
  1188. // STUDIO_VERT_ANIM_WRINKLE,
  1189. // };
  1190. // struct mstudioflex_t
  1191. // {
  1192. // DECLARE_BYTESWAP_DATADESC();
  1193. // int flexdesc; // input value
  1194. //
  1195. // float target0; // zero
  1196. // float target1; // one
  1197. // float target2; // one
  1198. // float target3; // zero
  1199. //
  1200. // int numverts;
  1201. // int vertindex;
  1202. //
  1203. // inline mstudiovertanim_t *pVertanim( int i ) const { Assert( vertanimtype == STUDIO_VERT_ANIM_NORMAL ); return (mstudiovertanim_t *)(((byte *)this) + vertindex) + i; };
  1204. // inline mstudiovertanim_wrinkle_t *pVertanimWrinkle( int i ) const { Assert( vertanimtype == STUDIO_VERT_ANIM_WRINKLE ); return (mstudiovertanim_wrinkle_t *)(((byte *)this) + vertindex) + i; };
  1205. //
  1206. // inline byte *pBaseVertanim( ) const { return ((byte *)this) + vertindex; };
  1207. // inline int VertAnimSizeBytes() const { return ( vertanimtype == STUDIO_VERT_ANIM_NORMAL ) ? sizeof(mstudiovertanim_t) : sizeof(mstudiovertanim_wrinkle_t); }
  1208. //
  1209. // int flexpair; // second flex desc
  1210. // unsigned char vertanimtype; // See StudioVertAnimType_t
  1211. // unsigned char unusedchar[3];
  1212. // int unused[6];
  1213. //
  1214. // };
  1215. // struct mstudioflexop_t
  1216. // {
  1217. // DECLARE_BYTESWAP_DATADESC();
  1218. // int op;
  1219. // union
  1220. // {
  1221. // int index;
  1222. // float value;
  1223. // } d;
  1224. // };
  1225. // struct mstudioflexrule_t
  1226. // {
  1227. // DECLARE_BYTESWAP_DATADESC();
  1228. // int flex;
  1229. // int numops;
  1230. // int opindex;
  1231. // inline mstudioflexop_t *iFlexOp( int i ) const { return (mstudioflexop_t *)(((byte *)this) + opindex) + i; };
  1232. // };
  1233. // 16 bytes
  1234. // struct mstudioboneweight_t
  1235. // {
  1236. // DECLARE_BYTESWAP_DATADESC();
  1237. // float weight[MAX_NUM_BONES_PER_VERT];
  1238. // byte bone[MAX_NUM_BONES_PER_VERT];
  1239. // byte numbones;
  1240. //
  1241. // // byte material;
  1242. // // short firstref;
  1243. // // short lastref;
  1244. // };
  1245. // NOTE: This is exactly 48 bytes
  1246. // struct mstudiovertex_t
  1247. // {
  1248. // DECLARE_BYTESWAP_DATADESC();
  1249. // mstudioboneweight_t m_BoneWeights;
  1250. // Vector m_vecPosition;
  1251. // Vector m_vecNormal;
  1252. // Vector2D m_vecTexCoord;
  1253. //
  1254. // mstudiovertex_t() {}
  1255. //
  1256. // private:
  1257. // // No copy constructors allowed
  1258. // mstudiovertex_t(const mstudiovertex_t& vOther);
  1259. // };
  1260. // skin info
  1261. // struct mstudiotexture_t
  1262. // {
  1263. // DECLARE_BYTESWAP_DATADESC();
  1264. // int sznameindex;
  1265. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  1266. // int flags;
  1267. // int used;
  1268. // int unused1;
  1269. // mutable IMaterial *material; // fixme: this needs to go away . .isn't used by the engine, but is used by studiomdl
  1270. // mutable void *clientmaterial; // gary, replace with client material pointer if used
  1271. //
  1272. // int unused[10];
  1273. // };
  1274. // eyeball
  1275. // struct mstudioeyeball_t
  1276. // {
  1277. // DECLARE_BYTESWAP_DATADESC();
  1278. // int sznameindex;
  1279. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  1280. // int bone;
  1281. // Vector org;
  1282. // float zoffset;
  1283. // float radius;
  1284. // Vector up;
  1285. // Vector forward;
  1286. // int texture;
  1287. //
  1288. // int unused1;
  1289. // float iris_scale;
  1290. // int unused2;
  1291. //
  1292. // int upperflexdesc[3]; // index of raiser, neutral, and lowerer flexdesc that is set by flex controllers
  1293. // int lowerflexdesc[3];
  1294. // float uppertarget[3]; // angle (radians) of raised, neutral, and lowered lid positions
  1295. // float lowertarget[3];
  1296. //
  1297. // int upperlidflexdesc; // index of flex desc that actual lid flexes look to
  1298. // int lowerlidflexdesc;
  1299. // int unused[4]; // These were used before, so not guaranteed to be 0
  1300. // bool m_bNonFACS; // Never used before version 44
  1301. // char unused3[3];
  1302. // int unused4[7];
  1303. //
  1304. // mstudioeyeball_t(){}
  1305. // private:
  1306. // // No copy constructors allowed
  1307. // mstudioeyeball_t(const mstudioeyeball_t& vOther);
  1308. // };
  1309. // ikinfo
  1310. struct mstudioiklink_t_PS3
  1311. {
  1312. // DECLARE_BYTESWAP_DATADESC();
  1313. int bone;
  1314. Vector kneeDir; // ideal bending direction (per link, if applicable)
  1315. Vector unused0; // unused
  1316. mstudioiklink_t_PS3(){}
  1317. private:
  1318. // No copy constructors allowed
  1319. mstudioiklink_t_PS3(const mstudioiklink_t_PS3& vOther);
  1320. };
  1321. struct mstudioikchain_t_PS3
  1322. {
  1323. // DECLARE_BYTESWAP_DATADESC();
  1324. int sznameindex;
  1325. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  1326. int linktype;
  1327. int numlinks;
  1328. int linkindex;
  1329. inline mstudioiklink_t_PS3 *pLink( void *pEA_this, int i ) const { return (mstudioiklink_t_PS3 *)(((byte *)pEA_this) + linkindex) + i; };
  1330. // FIXME: add unused entries
  1331. };
  1332. // struct mstudioiface_t
  1333. // {
  1334. // mstudioiface_t()
  1335. // {
  1336. // a = b = c = d = 0xFFFF;
  1337. // }
  1338. //
  1339. // unsigned short a, b, c, d; // Indices to vertices (If d is 0xFFFF, this is a triangle, else it's a quad)
  1340. // };
  1341. struct mstudiomodel_t_PS3;
  1342. // struct mstudio_modelvertexdata_t
  1343. // {
  1344. // DECLARE_BYTESWAP_DATADESC();
  1345. // Vector *Position( int i ) const;
  1346. // Vector *Normal( int i ) const;
  1347. // Vector4D *TangentS( int i ) const;
  1348. // Vector2D *Texcoord( int i ) const;
  1349. // mstudioboneweight_t *BoneWeights( int i ) const;
  1350. // mstudiovertex_t *Vertex( int i ) const;
  1351. // bool HasTangentData( void ) const;
  1352. // int GetGlobalVertexIndex( int i ) const;
  1353. // int GetGlobalTangentIndex( int i ) const;
  1354. //
  1355. // // base of external vertex data stores
  1356. // const void *pVertexData;
  1357. // const void *pTangentData;
  1358. // };
  1359. // struct mstudio_meshvertexdata_t
  1360. // {
  1361. // DECLARE_BYTESWAP_DATADESC();
  1362. // Vector *Position( int i ) const;
  1363. // Vector *Normal( int i ) const;
  1364. // Vector4D *TangentS( int i ) const;
  1365. // Vector2D *Texcoord( int i ) const;
  1366. // mstudioboneweight_t *BoneWeights( int i ) const;
  1367. // mstudiovertex_t *Vertex( int i ) const;
  1368. // bool HasTangentData( void ) const;
  1369. // int GetModelVertexIndex( int i ) const;
  1370. // int GetGlobalVertexIndex( int i ) const;
  1371. //
  1372. // // indirection to this mesh's model's vertex data
  1373. // const mstudio_modelvertexdata_t *modelvertexdata;
  1374. //
  1375. // // used for fixup calcs when culling top level lods
  1376. // // expected number of mesh verts at desired lod
  1377. // int numLODVertexes[MAX_NUM_LODS];
  1378. // };
  1379. // struct mstudiomesh_t
  1380. // {
  1381. // DECLARE_BYTESWAP_DATADESC();
  1382. // int material;
  1383. //
  1384. // int modelindex;
  1385. // mstudiomodel_t *pModel() const;
  1386. //
  1387. // int numvertices; // number of unique vertices/normals/texcoords
  1388. // int vertexoffset; // vertex mstudiovertex_t
  1389. //
  1390. // // Access thin/fat mesh vertex data (only one will return a non-NULL result)
  1391. // const mstudio_meshvertexdata_t *GetVertexData( void *pModelData = NULL );
  1392. // const thinModelVertices_t *GetThinVertexData( void *pModelData = NULL );
  1393. //
  1394. // int numflexes; // vertex animation
  1395. // int flexindex;
  1396. // inline mstudioflex_t *pFlex( int i ) const { return (mstudioflex_t *)(((byte *)this) + flexindex) + i; };
  1397. //
  1398. // // special codes for material operations
  1399. // int materialtype;
  1400. // int materialparam;
  1401. //
  1402. // // a unique ordinal for this mesh
  1403. // int meshid;
  1404. //
  1405. // Vector center;
  1406. //
  1407. // mstudio_meshvertexdata_t vertexdata;
  1408. //
  1409. // int unused[8]; // remove as appropriate
  1410. //
  1411. // mstudiomesh_t(){}
  1412. // private:
  1413. // // No copy constructors allowed
  1414. // mstudiomesh_t(const mstudiomesh_t& vOther);
  1415. // };
  1416. // studio models
  1417. // struct mstudiomodel_t
  1418. // {
  1419. // DECLARE_BYTESWAP_DATADESC();
  1420. // inline const char * pszName( void ) const { return name; }
  1421. // char name[64];
  1422. //
  1423. // int type;
  1424. //
  1425. // float boundingradius;
  1426. //
  1427. // int nummeshes;
  1428. // int meshindex;
  1429. // inline mstudiomesh_t *pMesh( int i ) const { return (mstudiomesh_t *)(((byte *)this) + meshindex) + i; };
  1430. //
  1431. // // cache purposes
  1432. // int numvertices; // number of unique vertices/normals/texcoords
  1433. // int vertexindex; // vertex Vector
  1434. // int tangentsindex; // tangents Vector
  1435. //
  1436. // // These functions are defined in application-specific code:
  1437. // const vertexFileHeader_t *CacheVertexData( void *pModelData );
  1438. //
  1439. // // Access thin/fat mesh vertex data (only one will return a non-NULL result)
  1440. // const mstudio_modelvertexdata_t *GetVertexData( void *pModelData = NULL );
  1441. // const thinModelVertices_t *GetThinVertexData( void *pModelData = NULL );
  1442. //
  1443. // int numattachments;
  1444. // int attachmentindex;
  1445. //
  1446. // int numeyeballs;
  1447. // int eyeballindex;
  1448. // inline mstudioeyeball_t *pEyeball( int i ) { return (mstudioeyeball_t *)(((byte *)this) + eyeballindex) + i; };
  1449. //
  1450. // mstudio_modelvertexdata_t vertexdata;
  1451. //
  1452. // int unused[8]; // remove as appropriate
  1453. // };
  1454. // inline bool mstudio_modelvertexdata_t::HasTangentData( void ) const
  1455. // {
  1456. // return (pTangentData != NULL);
  1457. // }
  1458. // inline int mstudio_modelvertexdata_t::GetGlobalVertexIndex( int i ) const
  1459. // {
  1460. // mstudiomodel_t *modelptr = (mstudiomodel_t *)((byte *)this - offsetof(mstudiomodel_t, vertexdata));
  1461. // Assert( ( modelptr->vertexindex % sizeof( mstudiovertex_t ) ) == 0 );
  1462. // return ( i + ( modelptr->vertexindex / sizeof( mstudiovertex_t ) ) );
  1463. // }
  1464. //
  1465. // inline int mstudio_modelvertexdata_t::GetGlobalTangentIndex( int i ) const
  1466. // {
  1467. // mstudiomodel_t *modelptr = (mstudiomodel_t *)((byte *)this - offsetof(mstudiomodel_t, vertexdata));
  1468. // Assert( ( modelptr->tangentsindex % sizeof( Vector4D ) ) == 0 );
  1469. // return ( i + ( modelptr->tangentsindex / sizeof( Vector4D ) ) );
  1470. // }
  1471. //
  1472. // inline mstudiovertex_t *mstudio_modelvertexdata_t::Vertex( int i ) const
  1473. // {
  1474. // return (mstudiovertex_t *)pVertexData + GetGlobalVertexIndex( i );
  1475. // }
  1476. //
  1477. // inline Vector *mstudio_modelvertexdata_t::Position( int i ) const
  1478. // {
  1479. // return &Vertex(i)->m_vecPosition;
  1480. // }
  1481. //
  1482. // inline Vector *mstudio_modelvertexdata_t::Normal( int i ) const
  1483. // {
  1484. // return &Vertex(i)->m_vecNormal;
  1485. // }
  1486. //
  1487. // inline Vector4D *mstudio_modelvertexdata_t::TangentS( int i ) const
  1488. // {
  1489. // // NOTE: The tangents vector is 16-bytes in a separate array
  1490. // // because it only exists on the high end, and if I leave it out
  1491. // // of the mstudiovertex_t, the vertex is 64-bytes (good for low end)
  1492. // return (Vector4D *)pTangentData + GetGlobalTangentIndex( i );
  1493. // }
  1494. //
  1495. // inline Vector2D *mstudio_modelvertexdata_t::Texcoord( int i ) const
  1496. // {
  1497. // return &Vertex(i)->m_vecTexCoord;
  1498. // }
  1499. //
  1500. // inline mstudioboneweight_t *mstudio_modelvertexdata_t::BoneWeights( int i ) const
  1501. // {
  1502. // return &Vertex(i)->m_BoneWeights;
  1503. // }
  1504. //
  1505. // inline mstudiomodel_t *mstudiomesh_t::pModel() const
  1506. // {
  1507. // return (mstudiomodel_t *)(((byte *)this) + modelindex);
  1508. // }
  1509. //
  1510. // inline bool mstudio_meshvertexdata_t::HasTangentData( void ) const
  1511. // {
  1512. // return modelvertexdata->HasTangentData();
  1513. // }
  1514. //
  1515. // inline const mstudio_meshvertexdata_t *mstudiomesh_t::GetVertexData( void *pModelData )
  1516. // {
  1517. // // get this mesh's model's vertex data (allow for mstudiomodel_t::GetVertexData
  1518. // // returning NULL if the data has been converted to 'thin' vertices)
  1519. // this->pModel()->GetVertexData( pModelData );
  1520. // vertexdata.modelvertexdata = &( this->pModel()->vertexdata );
  1521. //
  1522. // if ( !vertexdata.modelvertexdata->pVertexData )
  1523. // return NULL;
  1524. //
  1525. // return &vertexdata;
  1526. // }
  1527. //
  1528. // inline const thinModelVertices_t * mstudiomesh_t::GetThinVertexData( void *pModelData )
  1529. // {
  1530. // // get this mesh's model's thin vertex data
  1531. // return this->pModel()->GetThinVertexData( pModelData );
  1532. // }
  1533. //
  1534. // inline int mstudio_meshvertexdata_t::GetModelVertexIndex( int i ) const
  1535. // {
  1536. // mstudiomesh_t *meshptr = (mstudiomesh_t *)((byte *)this - offsetof(mstudiomesh_t,vertexdata));
  1537. // return meshptr->vertexoffset + i;
  1538. // }
  1539. //
  1540. // inline int mstudio_meshvertexdata_t::GetGlobalVertexIndex( int i ) const
  1541. // {
  1542. // return modelvertexdata->GetGlobalVertexIndex( GetModelVertexIndex( i ) );
  1543. // }
  1544. //
  1545. // inline Vector *mstudio_meshvertexdata_t::Position( int i ) const
  1546. // {
  1547. // return modelvertexdata->Position( GetModelVertexIndex( i ) );
  1548. // };
  1549. //
  1550. // inline Vector *mstudio_meshvertexdata_t::Normal( int i ) const
  1551. // {
  1552. // return modelvertexdata->Normal( GetModelVertexIndex( i ) );
  1553. // };
  1554. //
  1555. // inline Vector4D *mstudio_meshvertexdata_t::TangentS( int i ) const
  1556. // {
  1557. // return modelvertexdata->TangentS( GetModelVertexIndex( i ) );
  1558. // }
  1559. //
  1560. // inline Vector2D *mstudio_meshvertexdata_t::Texcoord( int i ) const
  1561. // {
  1562. // return modelvertexdata->Texcoord( GetModelVertexIndex( i ) );
  1563. // };
  1564. //
  1565. // inline mstudioboneweight_t *mstudio_meshvertexdata_t::BoneWeights( int i ) const
  1566. // {
  1567. // return modelvertexdata->BoneWeights( GetModelVertexIndex( i ) );
  1568. // };
  1569. //
  1570. // inline mstudiovertex_t *mstudio_meshvertexdata_t::Vertex( int i ) const
  1571. // {
  1572. // return modelvertexdata->Vertex( GetModelVertexIndex( i ) );
  1573. // }
  1574. //
  1575. // // a group of studio model data
  1576. // enum studiomeshgroupflags_t
  1577. // {
  1578. // MESHGROUP_IS_HWSKINNED = 0x2,
  1579. // MESHGROUP_IS_DELTA_FLEXED = 0x4
  1580. // };
  1581. // ----------------------------------------------------------
  1582. // Runtime stuff
  1583. // ----------------------------------------------------------
  1584. // struct studiomeshgroup_t
  1585. // {
  1586. // IMesh *m_pMesh;
  1587. // int m_NumStrips;
  1588. // int m_Flags; // see studiomeshgroupflags_t
  1589. // OptimizedModel::StripHeader_t *m_pStripData;
  1590. // unsigned short *m_pGroupIndexToMeshIndex;
  1591. // int m_NumVertices;
  1592. // int *m_pUniqueFaces; // for performance measurements
  1593. // unsigned short *m_pIndices;
  1594. // unsigned short *m_pTopologyIndices;
  1595. // bool m_MeshNeedsRestore;
  1596. // short m_ColorMeshID;
  1597. // IMorph *m_pMorph;
  1598. //
  1599. // inline unsigned short MeshIndex( int i ) const { return m_pGroupIndexToMeshIndex[m_pIndices[i]]; }
  1600. // };
  1601. // studio model data
  1602. // struct studiomeshdata_t
  1603. // {
  1604. // int m_NumGroup;
  1605. // studiomeshgroup_t* m_pMeshGroup;
  1606. // };
  1607. //
  1608. // struct studioloddata_t
  1609. // {
  1610. // // not needed - this is really the same as studiohwdata_t.m_NumStudioMeshes
  1611. // //int m_NumMeshes;
  1612. // studiomeshdata_t *m_pMeshData; // there are studiohwdata_t.m_NumStudioMeshes of these.
  1613. // float m_SwitchPoint;
  1614. // // one of these for each lod since we can switch to simpler materials on lower lods.
  1615. // int numMaterials;
  1616. // IMaterial **ppMaterials; /* will have studiohdr_t.numtextures elements allocated */
  1617. // // hack - this needs to go away.
  1618. // int *pMaterialFlags; /* will have studiohdr_t.numtextures elements allocated */
  1619. // #ifndef _CERT
  1620. // int m_NumFaces; /* Total face count for this LOD */
  1621. // #endif // !_CERT
  1622. //
  1623. // // For decals on hardware morphing, we must actually do hardware skinning
  1624. // // For this to work, we have to hope that the total # of bones used by
  1625. // // hw flexed verts is < than the max possible for the dx level we're running under
  1626. // int *m_pHWMorphDecalBoneRemap;
  1627. // int m_nDecalBoneCount;
  1628. // };
  1629. //
  1630. // struct studiohwdata_t
  1631. // {
  1632. // int m_RootLOD; // calced and clamped, nonzero for lod culling
  1633. // int m_NumLODs;
  1634. // studioloddata_t *m_pLODs;
  1635. // int m_NumStudioMeshes;
  1636. //
  1637. // inline float LODMetric( float unitSphereSize ) const { return ( unitSphereSize != 0.0f ) ? (100.0f / unitSphereSize) : 0.0f; }
  1638. // inline int GetLODForMetric( float lodMetric ) const
  1639. // {
  1640. // static ConVarRef r_lod_switch_scale( "r_lod_switch_scale" );
  1641. //
  1642. // if ( !m_NumLODs )
  1643. // return 0;
  1644. //
  1645. // // On low GPU levels, we pull in the LOD transitions with a scale factor
  1646. // float flSwitchPointModifier = r_lod_switch_scale.IsValid() ? r_lod_switch_scale.GetFloat() : 1.0f;
  1647. //
  1648. // // shadow lod is specified on the last lod with a negative switch
  1649. // // never consider shadow lod as viable candidate
  1650. // int numLODs = (m_pLODs[m_NumLODs-1].m_SwitchPoint < 0.0f) ? m_NumLODs-1 : m_NumLODs;
  1651. //
  1652. // for ( int i = m_RootLOD; i < numLODs-1; i++ )
  1653. // {
  1654. // if ( ( m_pLODs[i+1].m_SwitchPoint * flSwitchPointModifier ) > lodMetric )
  1655. // return i;
  1656. // }
  1657. //
  1658. // return numLODs-1;
  1659. // }
  1660. //
  1661. // #ifndef _CERT
  1662. // // Each model counts how many rendered faces it accounts for each frame:
  1663. // inline void UpdateFacesRenderedCount( studiohdr_t *pStudioHdr, CUtlHash< studiohwdata_t * > &hwDataHash, int nLOD, int nInstances, int nFacesOverride = -1 )
  1664. // {
  1665. // if ( hwDataHash.Find( this ) == hwDataHash.InvalidHandle() )
  1666. // {
  1667. // m_NumFacesRenderedThisFrame = 0;
  1668. // m_NumTimesRenderedThisFrame = 0;
  1669. // m_pStudioHdr = pStudioHdr;
  1670. // hwDataHash.Insert( this );
  1671. // }
  1672. // Assert( m_pStudioHdr && ( m_pStudioHdr == pStudioHdr ) );
  1673. // if ( nFacesOverride == -1 )
  1674. // {
  1675. // nFacesOverride = ( nLOD < m_NumLODs ) ? m_pLODs[ nLOD ].m_NumFaces : 0;
  1676. // }
  1677. // m_NumFacesRenderedThisFrame += nInstances * nFacesOverride;
  1678. // m_NumTimesRenderedThisFrame ++;
  1679. // }
  1680. // int m_NumFacesRenderedThisFrame;
  1681. // int m_NumTimesRenderedThisFrame;
  1682. // studiohdr_t *m_pStudioHdr; // There is no way to map between these inside CStudioRender, so we have to store it.
  1683. // #endif // !_CERT
  1684. // };
  1685. // ----------------------------------------------------------
  1686. // ----------------------------------------------------------
  1687. // body part index
  1688. // struct mstudiobodyparts_t
  1689. // {
  1690. // DECLARE_BYTESWAP_DATADESC();
  1691. // int sznameindex;
  1692. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  1693. // int nummodels;
  1694. // int base;
  1695. // int modelindex; // index into models array
  1696. // inline mstudiomodel_t *pModel( int i ) const { return (mstudiomodel_t *)(((byte *)this) + modelindex) + i; };
  1697. // };
  1698. //
  1699. //
  1700. // struct mstudiomouth_t
  1701. // {
  1702. // DECLARE_BYTESWAP_DATADESC();
  1703. // int bone;
  1704. // Vector forward;
  1705. // int flexdesc;
  1706. //
  1707. // mstudiomouth_t(){}
  1708. // private:
  1709. // // No copy constructors allowed
  1710. // mstudiomouth_t(const mstudiomouth_t& vOther);
  1711. // };
  1712. //
  1713. // struct mstudiohitboxset_t
  1714. // {
  1715. // DECLARE_BYTESWAP_DATADESC();
  1716. // int sznameindex;
  1717. // inline char * const pszName( void ) const { return ((char *)this) + sznameindex; }
  1718. // int numhitboxes;
  1719. // int hitboxindex;
  1720. // inline mstudiobbox_t *pHitbox( int i ) const { return (mstudiobbox_t *)(((byte *)this) + hitboxindex) + i; };
  1721. // };
  1722. //-----------------------------------------------------------------------------
  1723. // Src bone transforms are transformations that will convert .dmx or .smd-based animations into .mdl-based animations
  1724. // NOTE: The operation you should apply is: pretransform * bone transform * posttransform
  1725. //-----------------------------------------------------------------------------
  1726. // struct mstudiosrcbonetransform_t
  1727. // {
  1728. // DECLARE_BYTESWAP_DATADESC();
  1729. //
  1730. // int sznameindex;
  1731. // inline const char *pszName( void ) const { return ((char *)this) + sznameindex; }
  1732. // matrix3x4_t pretransform;
  1733. // matrix3x4_t posttransform;
  1734. // };
  1735. // ----------------------------------------------------------
  1736. // Purpose: Load time results on model compositing
  1737. // ----------------------------------------------------------
  1738. class virtualgroup_t_PS3
  1739. {
  1740. public:
  1741. virtualgroup_t_PS3( void ) { cache = NULL; };
  1742. // tool dependant. In engine this is a model_t, in tool it's a direct pointer
  1743. void *cache;
  1744. // converts cache entry into a usable studiohdr_t *
  1745. // const studiohdr_t *GetStudioHdr( void ) const;
  1746. // CUtlVector< int > boneMap; // maps global bone to local bone
  1747. // CUtlVector< int > masterBone; // maps local bone to global bone
  1748. // CUtlVector< int > masterSeq; // maps local sequence to master sequence
  1749. // CUtlVector< int > masterAnim; // maps local animation to master animation
  1750. // CUtlVector< int > masterAttachment; // maps local attachment to global
  1751. // CUtlVector< int > masterPose; // maps local pose parameter to global
  1752. // CUtlVector< int > masterNode; // maps local transition nodes to global
  1753. };
  1754. struct virtualsequence_t_PS3
  1755. {
  1756. int flags;
  1757. int activity;
  1758. int group;
  1759. int index;
  1760. };
  1761. struct virtualgeneric_t_PS3
  1762. {
  1763. int group;
  1764. int index;
  1765. };
  1766. struct virtualmodel_t_PS3
  1767. {
  1768. // void AppendSequences( int group, const studiohdr_t_PS3 *pStudioHdr );
  1769. // void AppendAnimations( int group, const studiohdr_t_PS3 *pStudioHdr );
  1770. // void AppendAttachments( int ground, const studiohdr_t_PS3 *pStudioHdr );
  1771. // void AppendPoseParameters( int group, const studiohdr_t_PS3 *pStudioHdr );
  1772. // void AppendBonemap( int group, const studiohdr_t_PS3 *pStudioHdr );
  1773. // void AppendNodes( int group, const studiohdr_t_PS3 *pStudioHdr );
  1774. // void AppendTransitions( int group, const studiohdr_t_PS3 *pStudioHdr );
  1775. // void AppendIKLocks( int group, const studiohdr_t_PS3 *pStudioHdr );
  1776. // void AppendModels( int group, const studiohdr_t_PS3 *pStudioHdr );
  1777. // void UpdateAutoplaySequences( const studiohdr_t_PS3 *pStudioHdr );
  1778. // virtualgroup_t_PS3 *pAnimGroup( int animation ) { return &m_group[ m_anim[ animation ].group ]; }; // Note: user must manage mutex for this
  1779. // virtualgroup_t_PS3 *pSeqGroup( int sequence ) { return &m_group[ m_seq[ sequence ].group ]; }; // Note: user must manage mutex for this
  1780. CThreadFastMutex_PS3 m_Lock;
  1781. // CUtlVector< virtualsequence_t_PS3 > m_seq;
  1782. // CUtlVector< virtualgeneric_t_PS3 > m_anim;
  1783. // CUtlVector< virtualgeneric_t_PS3 > m_attachment;
  1784. // CUtlVector< virtualgeneric_t_PS3 > m_pose;
  1785. // CUtlVector< virtualgroup_t_PS3 > m_group;
  1786. // CUtlVector< virtualgeneric_t_PS3 > m_node;
  1787. // CUtlVector< virtualgeneric_t_PS3 > m_iklock;
  1788. // CUtlVector< unsigned short > m_autoplaySequences;
  1789. };
  1790. // 'thin' vertex data, used to do model decals (see Studio_CreateThinVertexes())
  1791. // struct thinModelVertices_t
  1792. // {
  1793. // void Init( int numBoneInfluences, Vector *positions, unsigned short *normals, float *boneWeights, byte *boneIndices )
  1794. // {
  1795. // Assert( positions != NULL );
  1796. // Assert( normals != NULL );
  1797. // Assert( ( numBoneInfluences >= 0 ) && ( numBoneInfluences <= 3 ) );
  1798. // Assert( numBoneInfluences > 0 ? !!boneIndices : !boneIndices );
  1799. // Assert( numBoneInfluences > 1 ? !!boneWeights : !boneWeights );
  1800. // m_numBoneInfluences = numBoneInfluences;
  1801. // m_vecPositions = positions;
  1802. // m_vecNormals = normals;
  1803. // m_boneWeights = boneWeights;
  1804. // m_boneIndices = boneIndices;
  1805. // }
  1806. //
  1807. // void SetPosition( int vertIndex, const Vector & position )
  1808. // {
  1809. // Assert( m_vecPositions );
  1810. // m_vecPositions[ vertIndex ] = position;
  1811. // }
  1812. //
  1813. // void SetNormal( int vertIndex, const Vector & normal )
  1814. // {
  1815. // Assert( m_vecNormals );
  1816. // unsigned int packedNormal;
  1817. // PackNormal_UBYTE4( normal.x, normal.y, normal.z, &packedNormal );
  1818. // m_vecNormals[ vertIndex ] = (unsigned short)( 0x0000FFFF & packedNormal );
  1819. // }
  1820. //
  1821. // void SetBoneWeights( int vertIndex, const mstudioboneweight_t & boneWeights )
  1822. // {
  1823. // Assert( ( m_numBoneInfluences >= 1 ) && ( m_numBoneInfluences <= 3 ) );
  1824. // Assert( ( boneWeights.numbones >= 1 ) && ( boneWeights.numbones <= m_numBoneInfluences ) );
  1825. // int numStoredWeights = MAX( 0, ( m_numBoneInfluences - 1 ) );
  1826. // float *pBaseWeight = m_boneWeights + vertIndex*numStoredWeights;
  1827. // byte *pBaseIndex = m_boneIndices + vertIndex*m_numBoneInfluences;
  1828. // for ( int i = 0; i < m_numBoneInfluences; i++ )
  1829. // {
  1830. // pBaseIndex[i] = boneWeights.bone[i];
  1831. // }
  1832. // for ( int i = 0; i < numStoredWeights; i++ )
  1833. // {
  1834. // pBaseWeight[i] = boneWeights.weight[i];
  1835. // }
  1836. // }
  1837. //
  1838. // void GetMeshPosition( mstudiomesh_t *pMesh, int meshIndex, Vector *pPosition ) const
  1839. // {
  1840. // Assert( pMesh );
  1841. // GetPosition( pMesh->vertexdata.GetGlobalVertexIndex( meshIndex ), pPosition );
  1842. // }
  1843. //
  1844. // void GetMeshNormal( mstudiomesh_t *pMesh, int meshIndex, Vector *pNormal ) const
  1845. // {
  1846. // Assert( pMesh );
  1847. // GetNormal( pMesh->vertexdata.GetGlobalVertexIndex( meshIndex ), pNormal );
  1848. // }
  1849. //
  1850. // void GetMeshBoneWeights( mstudiomesh_t *pMesh, int meshIndex, mstudioboneweight_t *pBoneWeights ) const
  1851. // {
  1852. // Assert( pMesh );
  1853. // GetBoneWeights( pMesh->vertexdata.GetGlobalVertexIndex( meshIndex ), pBoneWeights );
  1854. // }
  1855. //
  1856. // void GetModelPosition( mstudiomodel_t *pModel, int modelIndex, Vector *pPosition ) const
  1857. // {
  1858. // Assert( pModel );
  1859. // GetPosition( pModel->vertexdata.GetGlobalVertexIndex( modelIndex ), pPosition );
  1860. // }
  1861. //
  1862. // void GetModelNormal( mstudiomodel_t *pModel, int modelIndex, Vector *pNormal ) const
  1863. // {
  1864. // Assert( pModel );
  1865. // GetNormal( pModel->vertexdata.GetGlobalVertexIndex( modelIndex ), pNormal );
  1866. // }
  1867. //
  1868. // void GetModelBoneWeights( mstudiomodel_t *pModel, int modelIndex, mstudioboneweight_t *pBoneWeights ) const
  1869. // {
  1870. // Assert( pModel );
  1871. // GetBoneWeights( pModel->vertexdata.GetGlobalVertexIndex( modelIndex ), pBoneWeights );
  1872. // }
  1873. //
  1874. // private:
  1875. // void GetPosition( int vertIndex, Vector *pPosition ) const
  1876. // {
  1877. // Assert( pPosition );
  1878. // Assert( m_vecPositions );
  1879. // *pPosition = m_vecPositions[ vertIndex ];
  1880. // }
  1881. //
  1882. // void GetNormal( int vertIndex, Vector *pNormal ) const
  1883. // {
  1884. // Assert( pNormal );
  1885. // Assert( m_vecNormals );
  1886. // unsigned int packedNormal = 0x0000FFFF & m_vecNormals[ vertIndex ];
  1887. // UnpackNormal_UBYTE4( &packedNormal, pNormal->Base() );
  1888. // }
  1889. //
  1890. // void GetBoneWeights( int vertIndex, mstudioboneweight_t * RESTRICT pBoneWeights ) const
  1891. // {
  1892. // Assert( pBoneWeights );
  1893. // Assert( ( m_numBoneInfluences <= 1 ) || ( m_boneWeights != NULL ) );
  1894. // Assert( ( m_numBoneInfluences <= 0 ) || ( m_boneIndices != NULL ) );
  1895. // int numStoredWeights = MAX( 0, ( m_numBoneInfluences - 1 ) );
  1896. // float * RESTRICT pBaseWeight = m_boneWeights + vertIndex*numStoredWeights;
  1897. // byte * RESTRICT pBaseIndex = m_boneIndices + vertIndex*m_numBoneInfluences;
  1898. // float sum = 0.0f;
  1899. // // TODO: unroll this loop? It's only three. We could use a switch
  1900. // // and code it explicitly for the various possible m_numBoneInfluences
  1901. // // which would improve scheduling but bloat code.
  1902. // for (int i = 0;i < MAX_NUM_BONES_PER_VERT;i++)
  1903. // {
  1904. // float weight;
  1905. // if ( i < ( m_numBoneInfluences - 1 ) )
  1906. // {
  1907. // weight = pBaseWeight[i];
  1908. // sum += weight;
  1909. // }
  1910. // else
  1911. // {
  1912. // weight = 1.0f - sum;
  1913. // sum = 1.0f;
  1914. // }
  1915. //
  1916. // pBoneWeights->weight[i] = weight;
  1917. // pBoneWeights->bone[i] = ( i < m_numBoneInfluences ) ? pBaseIndex[i] : 0;
  1918. //
  1919. // /*
  1920. // if ( i < ( m_numBoneInfluences - 1 ) )
  1921. // pBoneWeights->weight[i] = pBaseWeight[i];
  1922. // else
  1923. // pBoneWeights->weight[i] = 1.0f - sum;
  1924. // sum += pBoneWeights->weight[i];
  1925. //
  1926. // pBoneWeights->bone[i] = ( i < m_numBoneInfluences ) ? pBaseIndex[i] : 0;
  1927. // */
  1928. // }
  1929. //
  1930. // // Treat 'zero weights' as '100% binding to bone zero':
  1931. // pBoneWeights->numbones = m_numBoneInfluences ? m_numBoneInfluences : 1;
  1932. // }
  1933. //
  1934. // int m_numBoneInfluences;// Number of bone influences per vertex, N
  1935. // float *m_boneWeights; // This array stores (N-1) weights per vertex (unless N is zero)
  1936. // byte *m_boneIndices; // This array stores N indices per vertex
  1937. // Vector *m_vecPositions;
  1938. // unsigned short *m_vecNormals; // Normals are compressed into 16 bits apiece (see PackNormal_UBYTE4() )
  1939. // };
  1940. // ----------------------------------------------------------
  1941. // Studio Model Stream Data File
  1942. // ----------------------------------------------------------
  1943. // little-endian "IDSS"
  1944. // #define MODEL_STREAM_FILE_ID (('S'<<24)+('S'<<16)+('D'<<8)+'I')
  1945. // #define MODEL_STREAM_FILE_VERSION 1
  1946. // struct vertexStreamFileHeader_t
  1947. // {
  1948. // DECLARE_BYTESWAP_DATADESC();
  1949. // int id; // MODEL_STREAM_FILE_ID
  1950. // int version; // MODEL_STREAM_FILE_VERSION
  1951. // long checksum; // same as studiohdr_t, ensures sync
  1952. // long flags; // flags
  1953. // int numVerts; // number of vertices
  1954. // int uv2StreamStart; // offset from base to uv2 stream
  1955. // int uv2ElementSize; // size of each uv2 element
  1956. // int pad; // pad
  1957. //
  1958. // public:
  1959. //
  1960. // // Accessor to uv2 stream
  1961. // const void *GetStreamUv2() const
  1962. // {
  1963. // if ( ( id == MODEL_STREAM_FILE_ID ) && ( uv2StreamStart != 0 ) )
  1964. // return ( void * ) ( uv2StreamStart + (byte *)this );
  1965. // else
  1966. // return NULL;
  1967. // }
  1968. // };
  1969. // ----------------------------------------------------------
  1970. // Studio Model Vertex Data File
  1971. // Position independent flat data for cache manager
  1972. // ----------------------------------------------------------
  1973. // little-endian "IDSV"
  1974. // #define MODEL_VERTEX_FILE_ID (('V'<<24)+('S'<<16)+('D'<<8)+'I')
  1975. // #define MODEL_VERTEX_FILE_VERSION 4
  1976. // // this id (IDCV) is used once the vertex data has been compressed (see CMDLCache::CreateThinVertexes)
  1977. // #define MODEL_VERTEX_FILE_THIN_ID (('V'<<24)+('C'<<16)+('D'<<8)+'I')
  1978. // // this id (IDDV) is used once the vertex data has been discarded (see CMDLCache::CreateNullVertexes)
  1979. // #define MODEL_VERTEX_FILE_NULL_ID (('V'<<24)+('D'<<16)+('D'<<8)+'I')
  1980. // struct vertexFileHeader_t
  1981. // {
  1982. // DECLARE_BYTESWAP_DATADESC();
  1983. // int id; // MODEL_VERTEX_FILE_ID
  1984. // int version; // MODEL_VERTEX_FILE_VERSION
  1985. // long checksum; // same as studiohdr_t, ensures sync
  1986. // int numLODs; // num of valid lods
  1987. // int numLODVertexes[MAX_NUM_LODS]; // num verts for desired root lod
  1988. // int numFixups; // num of vertexFileFixup_t
  1989. // #ifdef _PS3
  1990. // union
  1991. // {
  1992. // int fixupTableStart;
  1993. // uint32 ps3edgeDmaInputDesc; // [PS3: offset of the EDGE DMA INPUT stream]
  1994. // };
  1995. // uint32 inline GetPs3EdgeDmaInputStart() const { return ( ps3edgeDmaInputDesc & 0xFFFF ) << 8; }
  1996. // uint32 inline GetPs3EdgeDmaInputLength() const { return ( ( ps3edgeDmaInputDesc >> 16 ) & 0x7FFF ) << 8; }
  1997. // #else
  1998. // int fixupTableStart; // offset from base to fixup table
  1999. // #endif
  2000. // int vertexDataStart; // offset from base to vertex block
  2001. // int tangentDataStart; // offset from base to tangent block
  2002. //
  2003. // public:
  2004. //
  2005. // // Accessor to fat vertex data
  2006. // const mstudiovertex_t *GetVertexData() const
  2007. // {
  2008. // if ( ( id == MODEL_VERTEX_FILE_ID ) && ( vertexDataStart != 0 ) )
  2009. // return ( mstudiovertex_t * ) ( vertexDataStart + (byte *)this );
  2010. // else
  2011. // return NULL;
  2012. // }
  2013. // // Accessor to (fat) tangent vertex data (tangents aren't stored in compressed data)
  2014. // const Vector4D *GetTangentData() const
  2015. // {
  2016. // if ( ( id == MODEL_VERTEX_FILE_ID ) && ( tangentDataStart != 0 ) )
  2017. // return ( Vector4D * ) ( tangentDataStart + (byte *)this );
  2018. // else
  2019. // return NULL;
  2020. // }
  2021. // // Accessor to thin vertex data
  2022. // const thinModelVertices_t *GetThinVertexData() const
  2023. // {
  2024. // if ( ( id == MODEL_VERTEX_FILE_THIN_ID ) && ( vertexDataStart != 0 ) )
  2025. // return ( thinModelVertices_t * ) ( vertexDataStart + (byte *)this );
  2026. // else
  2027. // return NULL;
  2028. // }
  2029. //
  2030. // #ifdef _PS3
  2031. // // Accessor to EDGE DMA INPUT format
  2032. // const byte *GetPs3EdgeDmaInput() const
  2033. // {
  2034. // if ( ( id == MODEL_VERTEX_FILE_ID ) && ( ps3edgeDmaInputDesc & 0x80000000 ) )
  2035. // return ( byte * ) ( GetPs3EdgeDmaInputStart() + (byte *)this );
  2036. // else
  2037. // return NULL;
  2038. // }
  2039. // #endif
  2040. // };
  2041. //
  2042. // // model vertex data accessor (defined here so vertexFileHeader_t can be used)
  2043. // inline const mstudio_modelvertexdata_t * mstudiomodel_t::GetVertexData( void *pModelData )
  2044. // {
  2045. // const vertexFileHeader_t * pVertexHdr = CacheVertexData( pModelData );
  2046. // if ( !pVertexHdr )
  2047. // return NULL;
  2048. //
  2049. // vertexdata.pVertexData = pVertexHdr->GetVertexData();
  2050. // vertexdata.pTangentData = pVertexHdr->GetTangentData();
  2051. //
  2052. // if ( !vertexdata.pVertexData )
  2053. // return NULL;
  2054. //
  2055. // return &vertexdata;
  2056. // }
  2057. //
  2058. // // model thin vertex data accessor (defined here so vertexFileHeader_t can be used)
  2059. // inline const thinModelVertices_t * mstudiomodel_t::GetThinVertexData( void *pModelData )
  2060. // {
  2061. // const vertexFileHeader_t * pVertexHdr = CacheVertexData( pModelData );
  2062. // if ( !pVertexHdr )
  2063. // return NULL;
  2064. //
  2065. // return pVertexHdr->GetThinVertexData();
  2066. // }
  2067. //
  2068. // // apply sequentially to lod sorted vertex and tangent pools to re-establish mesh order
  2069. // struct vertexFileFixup_t
  2070. // {
  2071. // DECLARE_BYTESWAP_DATADESC();
  2072. // int lod; // used to skip culled root lod
  2073. // int sourceVertexID; // absolute index from start of vertex/tangent blocks
  2074. // int numVertexes;
  2075. // };
  2076. //
  2077. // // This flag is set if no hitbox information was specified
  2078. // #define STUDIOHDR_FLAGS_AUTOGENERATED_HITBOX ( 1 << 0 )
  2079. //
  2080. // // NOTE: This flag is set at loadtime, not mdl build time so that we don't have to rebuild
  2081. // // models when we change materials.
  2082. // #define STUDIOHDR_FLAGS_USES_ENV_CUBEMAP ( 1 << 1 )
  2083. //
  2084. // // Use this when there are translucent parts to the model but we're not going to sort it
  2085. // #define STUDIOHDR_FLAGS_FORCE_OPAQUE ( 1 << 2 )
  2086. //
  2087. // // Use this when we want to render the opaque parts during the opaque pass
  2088. // // and the translucent parts during the translucent pass
  2089. // #define STUDIOHDR_FLAGS_TRANSLUCENT_TWOPASS ( 1 << 3 )
  2090. //
  2091. // // This is set any time the .qc files has $staticprop in it
  2092. // // Means there's no bones and no transforms
  2093. // #define STUDIOHDR_FLAGS_STATIC_PROP ( 1 << 4 )
  2094. //
  2095. // // NOTE: This flag is set at loadtime, not mdl build time so that we don't have to rebuild
  2096. // // models when we change materials.
  2097. // #define STUDIOHDR_FLAGS_USES_FB_TEXTURE ( 1 << 5 )
  2098. //
  2099. // // This flag is set by studiomdl.exe if a separate "$shadowlod" entry was present
  2100. // // for the .mdl (the shadow lod is the last entry in the lod list if present)
  2101. // #define STUDIOHDR_FLAGS_HASSHADOWLOD ( 1 << 6 )
  2102. //
  2103. // // NOTE: This flag is set at loadtime, not mdl build time so that we don't have to rebuild
  2104. // // models when we change materials.
  2105. // #define STUDIOHDR_FLAGS_USES_BUMPMAPPING ( 1 << 7 )
  2106. //
  2107. // // NOTE: This flag is set when we should use the actual materials on the shadow LOD
  2108. // // instead of overriding them with the default one (necessary for translucent shadows)
  2109. // #define STUDIOHDR_FLAGS_USE_SHADOWLOD_MATERIALS ( 1 << 8 )
  2110. //
  2111. // // NOTE: This flag is set when we should use the actual materials on the shadow LOD
  2112. // // instead of overriding them with the default one (necessary for translucent shadows)
  2113. // #define STUDIOHDR_FLAGS_OBSOLETE ( 1 << 9 )
  2114. //
  2115. // #define STUDIOHDR_FLAGS_UNUSED ( 1 << 10 )
  2116. //
  2117. // // NOTE: This flag is set at mdl build time
  2118. // #define STUDIOHDR_FLAGS_NO_FORCED_FADE ( 1 << 11 )
  2119. //
  2120. // // NOTE: The npc will lengthen the viseme check to always include two phonemes
  2121. // #define STUDIOHDR_FLAGS_FORCE_PHONEME_CROSSFADE ( 1 << 12 )
  2122. //
  2123. // // This flag is set when the .qc has $constantdirectionallight in it
  2124. // // If set, we use constantdirectionallightdot to calculate light intensity
  2125. // // rather than the normal directional dot product
  2126. // // only valid if STUDIOHDR_FLAGS_STATIC_PROP is also set
  2127. // #define STUDIOHDR_FLAGS_CONSTANT_DIRECTIONAL_LIGHT_DOT ( 1 << 13 )
  2128. //
  2129. // // Flag to mark delta flexes as already converted from disk format to memory format
  2130. // #define STUDIOHDR_FLAGS_FLEXES_CONVERTED ( 1 << 14 )
  2131. //
  2132. // // Indicates the studiomdl was built in preview mode
  2133. // #define STUDIOHDR_FLAGS_BUILT_IN_PREVIEW_MODE ( 1 << 15 )
  2134. //
  2135. // // Ambient boost (runtime flag)
  2136. // #define STUDIOHDR_FLAGS_AMBIENT_BOOST ( 1 << 16 )
  2137. //
  2138. // // Don't cast shadows from this model (useful on first-person models)
  2139. // #define STUDIOHDR_FLAGS_DO_NOT_CAST_SHADOWS ( 1 << 17 )
  2140. //
  2141. // // alpha textures should cast shadows in vrad on this model (ONLY prop_static!)
  2142. // #define STUDIOHDR_FLAGS_CAST_TEXTURE_SHADOWS ( 1 << 18 )
  2143. //
  2144. // // Model has a quad-only Catmull-Clark SubD cage
  2145. // #define STUDIOHDR_FLAGS_SUBDIVISION_SURFACE ( 1 << 19 )
  2146. //
  2147. // // flagged on load to indicate no animation events on this model
  2148. // #define STUDIOHDR_FLAGS_NO_ANIM_EVENTS ( 1 << 20 )
  2149. //
  2150. // // If flag is set then studiohdr_t.flVertAnimFixedPointScale contains the
  2151. // // scale value for fixed point vert anim data, if not set then the
  2152. // // scale value is the default of 1.0 / 4096.0. Regardless use
  2153. // // studiohdr_t::VertAnimFixedPointScale() to always retrieve the scale value
  2154. // #define STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE ( 1 << 21 )
  2155. //
  2156. // // If flag is set then model data is processed for EDGE
  2157. // // the flag is set at tool time when producing PS3-format assets
  2158. // #define STUDIOHDR_FLAGS_PS3_EDGE_FORMAT ( 1 << 22 )
  2159. // NOTE! Next time we up the .mdl file format, remove studiohdr2_t
  2160. // and insert all fields in this structure into studiohdr_t.
  2161. struct studiohdr2_t_PS3
  2162. {
  2163. // NOTE: For forward compat, make sure any methods in this struct
  2164. // are also available in studiohdr_t so no leaf code ever directly references
  2165. // a studiohdr2_t structure
  2166. // DECLARE_BYTESWAP_DATADESC();
  2167. int numsrcbonetransform;
  2168. int srcbonetransformindex;
  2169. int illumpositionattachmentindex;
  2170. // inline int IllumPositionAttachmentIndex() const { return illumpositionattachmentindex; }
  2171. float flMaxEyeDeflection;
  2172. // inline float MaxEyeDeflection() const { return flMaxEyeDeflection != 0.0f ? flMaxEyeDeflection : 0.866f; } // default to cos(30) if not set
  2173. int linearboneindex;
  2174. // inline mstudiolinearbone_t *pLinearBones() const { return (linearboneindex) ? (mstudiolinearbone_t *)(((byte *)this) + linearboneindex) : NULL; }
  2175. int sznameindex;
  2176. // inline char *pszName() { return (sznameindex) ? (char *)(((byte *)this) + sznameindex ) : NULL; }
  2177. int m_nBoneFlexDriverCount;
  2178. int m_nBoneFlexDriverIndex;
  2179. // inline mstudioboneflexdriver_t *pBoneFlexDriver( int i ) const { Assert( i >= 0 && i < m_nBoneFlexDriverCount ); return (mstudioboneflexdriver_t *)(((byte *)this) + m_nBoneFlexDriverIndex) + i; }
  2180. int reserved[56];
  2181. };
  2182. struct studiohdr_t_PS3
  2183. {
  2184. // DECLARE_BYTESWAP_DATADESC();
  2185. int id;
  2186. int version;
  2187. long checksum; // this has to be the same in the phy and vtx files to load!
  2188. // inline const char * pszName( void ) const { if (studiohdr2index && pStudioHdr2()->pszName()) return pStudioHdr2()->pszName(); else return name; }
  2189. char name[64];
  2190. int length;
  2191. Vector eyeposition; // ideal eye position
  2192. Vector illumposition; // illumination center
  2193. Vector hull_min; // ideal movement hull size
  2194. Vector hull_max;
  2195. Vector view_bbmin; // clipping bounding box
  2196. Vector view_bbmax;
  2197. int flags;
  2198. int numbones; // bones
  2199. int boneindex;
  2200. // inline mstudiobone_t *pBone( int i ) const { Assert( i >= 0 && i < numbones); return (mstudiobone_t *)(((byte *)this) + boneindex) + i; };
  2201. // int RemapSeqBone( int iSequence, int iLocalBone ) const; // maps local sequence bone to global bone
  2202. // int RemapAnimBone( int iAnim, int iLocalBone ) const; // maps local animations bone to global bone
  2203. int numbonecontrollers; // bone controllers
  2204. int bonecontrollerindex;
  2205. // inline mstudiobonecontroller_t *pBonecontroller( int i ) const { Assert( i >= 0 && i < numbonecontrollers); return (mstudiobonecontroller_t *)(((byte *)this) + bonecontrollerindex) + i; };
  2206. int numhitboxsets;
  2207. int hitboxsetindex;
  2208. // Look up hitbox set by index
  2209. // mstudiohitboxset_t *pHitboxSet( int i ) const
  2210. // {
  2211. // Assert( i >= 0 && i < numhitboxsets);
  2212. // return (mstudiohitboxset_t *)(((byte *)this) + hitboxsetindex ) + i;
  2213. // };
  2214. // Calls through to hitbox to determine size of specified set
  2215. // inline mstudiobbox_t *pHitbox( int i, int set ) const
  2216. // {
  2217. // mstudiohitboxset_t const *s = pHitboxSet( set );
  2218. // if ( !s )
  2219. // return NULL;
  2220. //
  2221. // return s->pHitbox( i );
  2222. // };
  2223. // Calls through to set to get hitbox count for set
  2224. // inline int iHitboxCount( int set ) const
  2225. // {
  2226. // mstudiohitboxset_t const *s = pHitboxSet( set );
  2227. // if ( !s )
  2228. // return 0;
  2229. //
  2230. // return s->numhitboxes;
  2231. // };
  2232. // file local animations? and sequences
  2233. //private:
  2234. int numlocalanim; // animations/poses
  2235. int localanimindex; // animation descriptions
  2236. // inline mstudioanimdesc_t *pLocalAnimdesc( int i ) const { if (i < 0 || i >= numlocalanim) i = 0; return (mstudioanimdesc_t *)(((byte *)this) + localanimindex) + i; };
  2237. int numlocalseq; // sequences
  2238. int localseqindex;
  2239. // inline mstudioseqdesc_t_PS3 *pLocalSeqdesc_PS3( int i ) const { if (i < 0 || i >= numlocalseq) i = 0; return (mstudioseqdesc_t_PS3 *)(((byte *)this) + localseqindex) + i; };
  2240. //public:
  2241. // bool SequencesAvailable() const;
  2242. // int GetNumSeq_Internal() const;
  2243. // inline int GetNumSeq() const
  2244. // {
  2245. // if (numincludemodels == 0)
  2246. // {
  2247. // return numlocalseq;
  2248. // }
  2249. // return GetNumSeq_Internal();
  2250. //
  2251. // }
  2252. // mstudioanimdesc_t &pAnimdesc_Internal( int i ) const;
  2253. // inline mstudioanimdesc_t &pAnimdesc( int i ) const
  2254. // {
  2255. // if (numincludemodels == 0)
  2256. // {
  2257. // return *pLocalAnimdesc( i );
  2258. // }
  2259. //
  2260. // return pAnimdesc_Internal( i );
  2261. // }
  2262. //
  2263. // mstudioseqdesc_t &pSeqdesc_Internal( int i ) const;
  2264. // inline mstudioseqdesc_t &pSeqdesc( int i ) const
  2265. // {
  2266. // if (numincludemodels == 0)
  2267. // {
  2268. // return *pLocalSeqdesc( i );
  2269. // }
  2270. // return pSeqdesc_Internal( i );
  2271. // }
  2272. // int iRelativeAnim_Internal( int baseseq, int relanim ) const; // maps seq local anim reference to global anim index
  2273. // inline int iRelativeAnim( int baseseq, int relanim ) const
  2274. // {
  2275. // if ( numincludemodels == 0 )
  2276. // return relanim;
  2277. // return iRelativeAnim_Internal( baseseq, relanim );
  2278. // }
  2279. // int iRelativeSeq_Internal( int baseseq, int relseq ) const; // maps seq local seq reference to global seq index
  2280. // inline int iRelativeSeq( int baseseq, int relseq ) const
  2281. // {
  2282. // if (numincludemodels == 0)
  2283. // {
  2284. // return relseq;
  2285. // }
  2286. // return iRelativeSeq_Internal( baseseq, relseq );
  2287. // }
  2288. //private:
  2289. mutable int activitylistversion; // initialization flag - have the sequences been indexed?
  2290. mutable int eventsindexed;
  2291. //public:
  2292. // int GetSequenceActivity( int iSequence );
  2293. // void SetSequenceActivity( int iSequence, int iActivity );
  2294. // int GetActivityListVersion( void );
  2295. // void SetActivityListVersion( int version ) const;
  2296. // int GetEventListVersion( void );
  2297. // void SetEventListVersion( int version );
  2298. // raw textures
  2299. int numtextures;
  2300. int textureindex;
  2301. // inline mstudiotexture_t *pTexture( int i ) const { Assert( i >= 0 && i < numtextures ); return (mstudiotexture_t *)(((byte *)this) + textureindex) + i; };
  2302. // raw textures search paths
  2303. int numcdtextures;
  2304. int cdtextureindex;
  2305. // inline char *pCdtexture( int i ) const { return (((char *)this) + *((int *)(((byte *)this) + cdtextureindex) + i)); };
  2306. // replaceable textures tables
  2307. int numskinref;
  2308. int numskinfamilies;
  2309. int skinindex;
  2310. // inline short *pSkinref( int i ) const { return (short *)(((byte *)this) + skinindex) + i; };
  2311. int numbodyparts;
  2312. int bodypartindex;
  2313. // inline mstudiobodyparts_t *pBodypart( int i ) const { return (mstudiobodyparts_t *)(((byte *)this) + bodypartindex) + i; };
  2314. // queryable attachable points
  2315. //private:
  2316. int numlocalattachments;
  2317. int localattachmentindex;
  2318. // inline mstudioattachment_t *pLocalAttachment( int i ) const { Assert( i >= 0 && i < numlocalattachments); return (mstudioattachment_t *)(((byte *)this) + localattachmentindex) + i; };
  2319. ////public:
  2320. // int GetNumAttachments( void ) const;
  2321. // const mstudioattachment_t &pAttachment( int i ) const;
  2322. // int GetAttachmentBone( int i );
  2323. // used on my tools in hlmv, not persistant
  2324. // void SetAttachmentBone( int iAttachment, int iBone );
  2325. // animation node to animation node transition graph
  2326. //private:
  2327. int numlocalnodes;
  2328. int localnodeindex;
  2329. int localnodenameindex;
  2330. // inline char *pszLocalNodeName( int iNode ) const { Assert( iNode >= 0 && iNode < numlocalnodes); return (((char *)this) + *((int *)(((byte *)this) + localnodenameindex) + iNode)); }
  2331. // inline byte *pLocalTransition( int i ) const { Assert( i >= 0 && i < (numlocalnodes * numlocalnodes)); return (byte *)(((byte *)this) + localnodeindex) + i; };
  2332. //// public:
  2333. // int EntryNode( int iSequence );
  2334. // int ExitNode( int iSequence );
  2335. // char *pszNodeName( int iNode );
  2336. // int GetTransition( int iFrom, int iTo ) const;
  2337. int numflexdesc;
  2338. int flexdescindex;
  2339. // inline mstudioflexdesc_t *pFlexdesc( int i ) const { Assert( i >= 0 && i < numflexdesc); return (mstudioflexdesc_t *)(((byte *)this) + flexdescindex) + i; };
  2340. int numflexcontrollers;
  2341. int flexcontrollerindex;
  2342. // inline mstudioflexcontroller_t *pFlexcontroller( LocalFlexController_t i ) const { Assert( i >= 0 && i < numflexcontrollers); return (mstudioflexcontroller_t *)(((byte *)this) + flexcontrollerindex) + i; };
  2343. int numflexrules;
  2344. int flexruleindex;
  2345. // inline mstudioflexrule_t *pFlexRule( int i ) const { Assert( i >= 0 && i < numflexrules); return (mstudioflexrule_t *)(((byte *)this) + flexruleindex) + i; };
  2346. int numikchains;
  2347. int ikchainindex;
  2348. // inline mstudioikchain_t *pIKChain( int i ) const { Assert( i >= 0 && i < numikchains); return (mstudioikchain_t *)(((byte *)this) + ikchainindex) + i; };
  2349. int nummouths;
  2350. int mouthindex;
  2351. // inline mstudiomouth_t *pMouth( int i ) const { Assert( i >= 0 && i < nummouths); return (mstudiomouth_t *)(((byte *)this) + mouthindex) + i; };
  2352. //private:
  2353. int numlocalposeparameters;
  2354. int localposeparamindex;
  2355. // inline mstudioposeparamdesc_t *pLocalPoseParameter( int i ) const { Assert( i >= 0 && i < numlocalposeparameters); return (mstudioposeparamdesc_t *)(((byte *)this) + localposeparamindex) + i; };
  2356. ////public:
  2357. // int GetNumPoseParameters( void ) const;
  2358. // const mstudioposeparamdesc_t &pPoseParameter( int i );
  2359. // int GetSharedPoseParameter( int iSequence, int iLocalPose ) const;
  2360. int surfacepropindex;
  2361. // inline char * const pszSurfaceProp( void ) const { return ((char *)this) + surfacepropindex; }
  2362. // inline int GetSurfaceProp() const { return surfacepropLookup; }
  2363. // Key values
  2364. int keyvalueindex;
  2365. int keyvaluesize;
  2366. // inline const char * KeyValueText( void ) const { return keyvaluesize != 0 ? ((char *)this) + keyvalueindex : NULL; }
  2367. int numlocalikautoplaylocks;
  2368. int localikautoplaylockindex;
  2369. // inline mstudioiklock_t *pLocalIKAutoplayLock( int i ) const { Assert( i >= 0 && i < numlocalikautoplaylocks); return (mstudioiklock_t *)(((byte *)this) + localikautoplaylockindex) + i; };
  2370. // int GetNumIKAutoplayLocks( void ) const;
  2371. // const mstudioiklock_t &pIKAutoplayLock( int i );
  2372. // int CountAutoplaySequences() const;
  2373. // int CopyAutoplaySequences( unsigned short *pOut, int outCount ) const;
  2374. // int GetAutoplayList( unsigned short **pOut ) const;
  2375. // The collision model mass that jay wanted
  2376. float mass;
  2377. int contents;
  2378. // external animations, models, etc.
  2379. int numincludemodels;
  2380. int includemodelindex;
  2381. // inline mstudiomodelgroup_t *pModelGroup( int i ) const { Assert( i >= 0 && i < numincludemodels); return (mstudiomodelgroup_t *)(((byte *)this) + includemodelindex) + i; };
  2382. // implementation specific call to get a named model
  2383. // const studiohdr_t *FindModel( void **cache, char const *modelname ) const;
  2384. // implementation specific back pointer to virtual data
  2385. mutable void *virtualModel;
  2386. // virtualmodel_t *GetVirtualModel( void ) const;
  2387. // for demand loaded animation blocks
  2388. int szanimblocknameindex;
  2389. // inline char * const pszAnimBlockName( void ) const { return ((char *)this) + szanimblocknameindex; }
  2390. int numanimblocks;
  2391. int animblockindex;
  2392. // inline mstudioanimblock_t *pAnimBlock( int i ) const { Assert( i > 0 && i < numanimblocks); return (mstudioanimblock_t *)(((byte *)this) + animblockindex) + i; };
  2393. mutable void *animblockModel;
  2394. // byte * GetAnimBlock( int i, bool preloadIfMissing = true ) const;
  2395. // bool hasAnimBlockBeenPreloaded( int i ) const;
  2396. int bonetablebynameindex;
  2397. // inline const byte *GetBoneTableSortedByName() const { return (byte *)this + bonetablebynameindex; }
  2398. // used by tools only that don't cache, but persist mdl's peer data
  2399. // engine uses virtualModel to back link to cache pointers
  2400. void *pVertexBase;
  2401. void *pIndexBase;
  2402. // if STUDIOHDR_FLAGS_CONSTANT_DIRECTIONAL_LIGHT_DOT is set,
  2403. // this value is used to calculate directional components of lighting
  2404. // on static props
  2405. byte constdirectionallightdot;
  2406. // set during load of mdl data to track *desired* lod configuration (not actual)
  2407. // the *actual* clamped root lod is found in studiohwdata
  2408. // this is stored here as a global store to ensure the staged loading matches the rendering
  2409. byte rootLOD;
  2410. // set in the mdl data to specify that lod configuration should only allow first numAllowRootLODs
  2411. // to be set as root LOD:
  2412. // numAllowedRootLODs = 0 means no restriction, any lod can be set as root lod.
  2413. // numAllowedRootLODs = N means that lod0 - lod(N-1) can be set as root lod, but not lodN or lower.
  2414. byte numAllowedRootLODs;
  2415. byte unused[1];
  2416. int unused4; // zero out if version < 47
  2417. int numflexcontrollerui;
  2418. int flexcontrolleruiindex;
  2419. // mstudioflexcontrollerui_t *pFlexControllerUI( int i ) const { Assert( i >= 0 && i < numflexcontrollerui); return (mstudioflexcontrollerui_t *)(((byte *)this) + flexcontrolleruiindex) + i; }
  2420. float flVertAnimFixedPointScale;
  2421. // inline float VertAnimFixedPointScale() const { return ( flags & STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE ) ? flVertAnimFixedPointScale : 1.0f / 4096.0f; }
  2422. mutable int surfacepropLookup; // this index must be cached by the loader, not saved in the file
  2423. // FIXME: Remove when we up the model version. Move all fields of studiohdr2_t into studiohdr_t.
  2424. int studiohdr2index;
  2425. // studiohdr2_t* pStudioHdr2() const { return (studiohdr2_t *)( ( (byte *)this ) + studiohdr2index ); }
  2426. // Src bone transforms are transformations that will convert .dmx or .smd-based animations into .mdl-based animations
  2427. // int NumSrcBoneTransforms() const { return studiohdr2index ? pStudioHdr2()->numsrcbonetransform : 0; }
  2428. // const mstudiosrcbonetransform_t* SrcBoneTransform( int i ) const { Assert( i >= 0 && i < NumSrcBoneTransforms()); return (mstudiosrcbonetransform_t *)(((byte *)this) + pStudioHdr2()->srcbonetransformindex) + i; }
  2429. // inline int IllumPositionAttachmentIndex() const { return studiohdr2index ? pStudioHdr2()->IllumPositionAttachmentIndex() : 0; }
  2430. // inline float MaxEyeDeflection() const { return studiohdr2index ? pStudioHdr2()->MaxEyeDeflection() : 0.866f; } // default to cos(30) if not set
  2431. // inline mstudiolinearbone_t *pLinearBones() const { return studiohdr2index ? pStudioHdr2()->pLinearBones() : NULL; }
  2432. // inline int BoneFlexDriverCount() const { return studiohdr2index ? pStudioHdr2()->m_nBoneFlexDriverCount : 0; }
  2433. // inline const mstudioboneflexdriver_t* BoneFlexDriver( int i ) const { Assert( i >= 0 && i < BoneFlexDriverCount() ); return studiohdr2index ? pStudioHdr2()->pBoneFlexDriver( i ) : NULL; }
  2434. // NOTE: No room to add stuff? Up the .mdl file format version
  2435. // [and move all fields in studiohdr2_t into studiohdr_t and kill studiohdr2_t],
  2436. // or add your stuff to studiohdr2_t. See NumSrcBoneTransforms/SrcBoneTransform for the pattern to use.
  2437. int unused2[1];
  2438. studiohdr_t_PS3() {}
  2439. private:
  2440. // No copy constructors allowed
  2441. studiohdr_t_PS3(const studiohdr_t_PS3& vOther);
  2442. friend struct virtualmodel_t_PS3;
  2443. };
  2444. //-----------------------------------------------------------------------------
  2445. // Purpose:
  2446. //-----------------------------------------------------------------------------
  2447. //class IDataCache_PS3;
  2448. //class IMDLCache_PS3;
  2449. // class CStudioHdr_PS3
  2450. // {
  2451. // public:
  2452. // CStudioHdr_PS3( void );
  2453. // CStudioHdr_PS3( const studiohdr_t_PS3 *pStudioHdr, IMDLCache_PS3 *mdlcache = NULL );
  2454. // ~CStudioHdr_PS3() { /*Term();*/ m_pActivityToSequence = NULL; }
  2455. // void Init( const studiohdr_t_PS3 *pStudioHdr, IMDLCache_PS3 *mdlcache = NULL );
  2456. // void Term();
  2457. // public:
  2458. // inline bool IsVirtual( void ) { return (m_pVModel != NULL); };
  2459. // inline bool IsValid( void ) { return (m_pStudioHdr != NULL); };
  2460. // inline bool IsReadyForAccess( void ) const { return (m_pStudioHdr != NULL); };
  2461. // inline virtualmodel_t *GetVirtualModel( void ) const { return m_pVModel; };
  2462. // inline const studiohdr_t *GetRenderHdr( void ) const { return m_pStudioHdr; };
  2463. // const studiohdr_t *pSeqStudioHdr( int sequence );
  2464. // const studiohdr_t *pAnimStudioHdr( int animation );
  2465. // private:
  2466. // mutable const studiohdr_t *m_pStudioHdr;
  2467. // mutable virtualmodel_t *m_pVModel;
  2468. // const virtualmodel_t * ResetVModel( const virtualmodel_t *pVModel ) const;
  2469. // const studiohdr_t *GroupStudioHdr( int group );
  2470. // mutable CUtlVector< const studiohdr_t_PS3 * > m_pStudioHdrCache;
  2471. //
  2472. // mutable int m_nFrameUnlockCounter;
  2473. // int * m_pFrameUnlockCounter;
  2474. // CThreadFastMutex_PS3 m_FrameUnlockCounterMutex;
  2475. // public:
  2476. // inline int numbones( void ) const { return m_pStudioHdr->numbones; };
  2477. // inline mstudiobone_t *pBone( int i ) const { return m_pStudioHdr->pBone( i ); };
  2478. // int RemapAnimBone( int iAnim, int iLocalBone ) const; // maps local animations bone to global bone
  2479. // int RemapSeqBone( int iSequence, int iLocalBone ) const; // maps local sequence bone to global bone
  2480. // bool SequencesAvailable() const;
  2481. // int GetNumSeq_Internal( void ) const;
  2482. // inline int GetNumSeq( void ) const
  2483. // {
  2484. // if ( !m_pVModel )
  2485. // return m_pStudioHdr->numlocalseq;
  2486. // return GetNumSeq_Internal();
  2487. // }
  2488. // mstudioanimdesc_t &pAnimdesc_Internal( int i );
  2489. // inline mstudioanimdesc_t &pAnimdesc( int i )
  2490. // {
  2491. // if ( !m_pVModel )
  2492. // return *m_pStudioHdr->pLocalAnimdesc( i );
  2493. // return pAnimdesc_Internal( i );
  2494. // }
  2495. // mstudioseqdesc_t_PS3 &pSeqdesc_Internal_PS3( int iSequence );
  2496. // inline mstudioseqdesc_t_PS3 &pSeqdesc_PS3( int iSequence )
  2497. // {
  2498. // if ( !m_pVModel )
  2499. // return *m_pStudioHdr->pLocalSeqdesc_PS3( iSequence );
  2500. //
  2501. // return pSeqdesc_Internal_PS3( iSequence );
  2502. // }
  2503. // int iRelativeAnim_Internal( int baseseq, int relanim ) const; // maps seq local anim reference to global anim index
  2504. // inline int iRelativeAnim( int baseseq, int relanim ) const
  2505. // {
  2506. // if ( !m_pVModel )
  2507. // return relanim;
  2508. // return iRelativeAnim_Internal( baseseq, relanim );
  2509. // }
  2510. // int iRelativeSeq( int baseseq, int relseq ) const; // maps seq local seq reference to global seq index
  2511. // int GetSequenceActivity( int iSequence );
  2512. // void SetSequenceActivity( int iSequence, int iActivity );
  2513. // int GetActivityListVersion( void );
  2514. // void SetActivityListVersion( int version );
  2515. // int GetEventListVersion( void );
  2516. // void SetEventListVersion( int version );
  2517. // int GetNumAttachments( void ) const;
  2518. // const mstudioattachment_t &pAttachment( int i );
  2519. // int GetAttachmentBone( int i );
  2520. // used on my tools in hlmv, not persistant
  2521. // void SetAttachmentBone( int iAttachment, int iBone );
  2522. // int EntryNode( int iSequence );
  2523. // int ExitNode( int iSequence );
  2524. // char *pszNodeName( int iNode );
  2525. // FIXME: where should this one be?
  2526. // int GetTransition( int iFrom, int iTo ) const;
  2527. // int GetNumPoseParameters( void ) const;
  2528. // const mstudioposeparamdesc_t &pPoseParameter( int i );
  2529. // int GetSharedPoseParameter( int iSequence, int iLocalPose ) const;
  2530. // int GetNumIKAutoplayLocks( void ) const;
  2531. // const mstudioiklock_t &pIKAutoplayLock( int i );
  2532. // inline int CountAutoplaySequences() const { return m_pStudioHdr->CountAutoplaySequences(); };
  2533. // inline int CopyAutoplaySequences( unsigned short *pOut, int outCount ) const { return m_pStudioHdr->CopyAutoplaySequences( pOut, outCount ); };
  2534. // inline int GetAutoplayList( unsigned short **pOut ) const { return m_pStudioHdr->GetAutoplayList( pOut ); };
  2535. // inline int GetNumBoneControllers( void ) const { return m_pStudioHdr->numbonecontrollers; };
  2536. // inline mstudiobonecontroller_t *pBonecontroller( int i ) const { return m_pStudioHdr->pBonecontroller( i ); };
  2537. // inline int numikchains() const { return m_pStudioHdr->numikchains; };
  2538. // inline int GetNumIKChains( void ) const { return m_pStudioHdr->numikchains; };
  2539. // inline mstudioikchain_t *pIKChain( int i ) const { return m_pStudioHdr->pIKChain( i ); };
  2540. // inline int numflexrules() const { return m_pStudioHdr->numflexrules; };
  2541. // inline mstudioflexrule_t *pFlexRule( int i ) const { return m_pStudioHdr->pFlexRule( i ); };
  2542. // inline int numflexdesc() const{ return m_pStudioHdr->numflexdesc; };
  2543. // inline mstudioflexdesc_t *pFlexdesc( int i ) const { return m_pStudioHdr->pFlexdesc( i ); };
  2544. // inline LocalFlexController_t numflexcontrollers() const{ return (LocalFlexController_t)m_pStudioHdr->numflexcontrollers; };
  2545. // inline mstudioflexcontroller_t *pFlexcontroller( LocalFlexController_t i ) const { return m_pStudioHdr->pFlexcontroller( i ); };
  2546. // inline int numflexcontrollerui() const{ return m_pStudioHdr->numflexcontrollerui; };
  2547. // inline mstudioflexcontrollerui_t *pFlexcontrollerUI( int i ) const { return m_pStudioHdr->pFlexControllerUI( i ); };
  2548. // inline const char *name() const { return m_pStudioHdr->pszName(); }; // deprecated -- remove after full xbox merge
  2549. // inline const char *pszName() const { return m_pStudioHdr->pszName(); };
  2550. // inline int numbonecontrollers() const { return m_pStudioHdr->numbonecontrollers; };
  2551. // inline int numhitboxsets() const { return m_pStudioHdr->numhitboxsets; };
  2552. // inline mstudiohitboxset_t *pHitboxSet( int i ) const { return m_pStudioHdr->pHitboxSet( i ); };
  2553. // inline mstudiobbox_t *pHitbox( int i, int set ) const { return m_pStudioHdr->pHitbox( i, set ); };
  2554. // inline int iHitboxCount( int set ) const { return m_pStudioHdr->iHitboxCount( set ); };
  2555. // inline int numbodyparts() const { return m_pStudioHdr->numbodyparts; };
  2556. // inline mstudiobodyparts_t *pBodypart( int i ) const { return m_pStudioHdr->pBodypart( i ); };
  2557. // inline int numskinfamilies() const { return m_pStudioHdr->numskinfamilies; }
  2558. // inline Vector eyeposition() const { return m_pStudioHdr->eyeposition; };
  2559. // inline int flags() const { return m_pStudioHdr->flags; };
  2560. // inline char *const pszSurfaceProp( void ) const { return m_pStudioHdr->pszSurfaceProp(); };
  2561. // inline int GetSurfaceProp()const { return m_pStudioHdr->surfacepropLookup; }
  2562. // inline float mass() const { return m_pStudioHdr->mass; };
  2563. // inline int contents() const { return m_pStudioHdr->contents; }
  2564. // inline const byte *GetBoneTableSortedByName() const { return m_pStudioHdr->GetBoneTableSortedByName(); };
  2565. // inline Vector illumposition() const { return m_pStudioHdr->illumposition; };
  2566. // inline Vector hull_min() const { return m_pStudioHdr->hull_min; }; // ideal movement hull size
  2567. // inline Vector hull_max() const { return m_pStudioHdr->hull_max; };
  2568. // inline Vector view_bbmin() const { return m_pStudioHdr->view_bbmin; }; // clipping bounding box
  2569. // inline Vector view_bbmax() const { return m_pStudioHdr->view_bbmax; };
  2570. // inline int numtextures() const { return m_pStudioHdr->numtextures; };
  2571. // inline int IllumPositionAttachmentIndex() const { return m_pStudioHdr->IllumPositionAttachmentIndex(); }
  2572. // inline float MaxEyeDeflection() const { return m_pStudioHdr->MaxEyeDeflection(); }
  2573. // inline mstudiolinearbone_t *pLinearBones() const { return m_pStudioHdr->pLinearBones(); }
  2574. // inline int BoneFlexDriverCount() const { return m_pStudioHdr->BoneFlexDriverCount(); }
  2575. // inline const mstudioboneflexdriver_t *BoneFlexDriver( int i ) const { return m_pStudioHdr->BoneFlexDriver( i ); }
  2576. // public:
  2577. // int IsSequenceLooping( int iSequence );
  2578. // float GetSequenceCycleRate( int iSequence );
  2579. // void RunFlexRules( const float *src, float *dest );
  2580. // void RunFlexRulesOld( const float *src, float *dest );
  2581. // void RunFlexRulesNew( const float *src, float *dest );
  2582. // public:
  2583. // inline int boneFlags( int iBone ) const { return m_boneFlags[ iBone ]; }
  2584. // inline void setBoneFlags( int iBone, int flags ) { m_boneFlags[ iBone ] |= flags; }
  2585. // inline void clearBoneFlags( int iBone, int flags ) { m_boneFlags[ iBone ] &= ~flags; }
  2586. // inline int boneParent( int iBone ) const { return m_boneParent[ iBone ]; }
  2587. // private:
  2588. // CUtlVector< int > m_boneFlags;
  2589. // CUtlVector< int > m_boneParent;
  2590. // public:
  2591. // This class maps an activity to sequences allowed for that activity, accelerating the resolution
  2592. // of SelectWeightedSequence(), especially on PowerPC. Iterating through every sequence
  2593. // attached to a model turned out to be a very destructive cache access pattern on 360.
  2594. //
  2595. // I've encapsulated this behavior inside a nested class for organizational reasons; there is
  2596. // no particular programmatic or efficiency benefit to it. It just makes clearer what particular
  2597. // code in the otherwise very complicated StudioHdr class has to do with this particular
  2598. // optimization, and it lets you collapse the whole definition down to a single line in Visual
  2599. // Studio.
  2600. // class CActivityToSequenceMapping_PS3 /* final */
  2601. // {
  2602. // public:
  2603. // // A tuple of a sequence and its corresponding weight. Lists of these correspond to activities.
  2604. // struct SequenceTuple_PS3
  2605. // {
  2606. // short seqnum;
  2607. // short weight; // the absolute value of the weight from the sequence header
  2608. // CUtlSymbol *pActivityModifiers; // list of activity modifier symbols
  2609. // int iNumActivityModifiers;
  2610. // };
  2611. // The type of the hash's stored data, a composite of both key and value
  2612. // (because that's how CUtlHash works):
  2613. // key: an int, the activity #
  2614. // values: an index into the m_pSequenceTuples array, a count of the
  2615. // total sequences present for an activity, and the sum of their
  2616. // weights.
  2617. // Note this struct is 128-bits wide, exactly coincident to a PowerPC
  2618. // cache line and VMX register. Please consider very carefully the
  2619. // performance implications before adding any additional fields to this.
  2620. // You could probably do away with totalWeight if you really had to.
  2621. // struct HashValueType_PS3
  2622. // {
  2623. // // KEY (hashed)
  2624. // int activityIdx;
  2625. //
  2626. // // VALUE (not hashed)
  2627. // int startingIdx;
  2628. // int count;
  2629. // int totalWeight;
  2630. // HashValueType(int _actIdx, int _stIdx, int _ct, int _tW) :
  2631. // activityIdx(_actIdx), startingIdx(_stIdx), count(_ct), totalWeight(_tW) {}
  2632. // default constructor (ought not to be actually used)
  2633. // HashValueType() : activityIdx(-1), startingIdx(-1), count(-1), totalWeight(-1)
  2634. // { AssertMsg(false, "Don't use default HashValueType()!"); }
  2635. // class HashFuncs_PS3
  2636. // {
  2637. // public:
  2638. // // dummy constructor (gndn)
  2639. // HashFuncs_PS3( int ) {}
  2640. // COMPARE
  2641. // compare two entries for uniqueness. We should never have two different
  2642. // entries for the same activity, so we only compare the activity index;
  2643. // this allows us to use the utlhash as a dict by constructing dummy entries
  2644. // as hash lookup keys.
  2645. // bool operator()( const HashValueType &lhs, const HashValueType &rhs ) const
  2646. // {
  2647. // return lhs.activityIdx == rhs.activityIdx;
  2648. // }
  2649. // HASH
  2650. // We only hash on the activity index; everything else is data.
  2651. // unsigned int operator()( const HashValueType &item ) const
  2652. // {
  2653. // return HashInt( item.activityIdx );
  2654. // }
  2655. // };
  2656. // };
  2657. // typedef CUtlHash<HashValueType_PS3, HashValueType_PS3::HashFuncs_PS3, HashValueType_PS3::HashFuncs_PS3> ActivityToValueIdxHash_PS3;
  2658. // These must be here because IFM does not compile/link studio.cpp (?!?)
  2659. // ctor
  2660. // CActivityToSequenceMapping( void )
  2661. // : m_pSequenceTuples(NULL), m_iSequenceTuplesCount(0), m_ActToSeqHash(8,0,0), m_expectedVModel(NULL), m_pStudioHdr(NULL)
  2662. // {};
  2663. // dtor -- not virtual because this class has no inheritors
  2664. // ~CActivityToSequenceMapping()
  2665. // {
  2666. // if ( m_pSequenceTuples != NULL )
  2667. // {
  2668. // if ( m_pSequenceTuples->pActivityModifiers != NULL )
  2669. // {
  2670. // delete[] m_pSequenceTuples->pActivityModifiers;
  2671. // }
  2672. // delete[] m_pSequenceTuples;
  2673. // }
  2674. // }
  2675. /// Get the list of sequences for an activity. Returns the pointer to the
  2676. /// first sequence tuple. Output parameters are a count of sequences present,
  2677. /// and the total weight of all the sequences. (it would be more LHS-friendly
  2678. /// to return these on registers, if only C++ offered more than one return
  2679. /// value....)
  2680. // const SequenceTuple *GetSequences( int forActivity, int *outSequenceCount, int *outTotalWeight );
  2681. /// The number of sequences available for an activity.
  2682. // int NumSequencesForActivity( int forActivity );
  2683. // static CActivityToSequenceMapping *FindMapping( const CStudioHdr *pstudiohdr );
  2684. // static void ReleaseMapping( CActivityToSequenceMapping *pMap );
  2685. // static void ResetMappings();
  2686. // private:
  2687. /// Allocate my internal array. (It is freed in the destructor.) Also,
  2688. /// build the hash of activities to sequences and populate m_pSequenceTuples.
  2689. // void Initialize( const CStudioHdr *pstudiohdr );
  2690. /// Force Initialize() to occur again, even if it has already occured.
  2691. // void Reinitialize( CStudioHdr *pstudiohdr );
  2692. /// A more efficient version of the old SelectWeightedSequence() function in animation.cpp.
  2693. // int SelectWeightedSequence( CStudioHdr *pstudiohdr, int activity, int curSequence );
  2694. // selects the sequence with the most matching modifiers
  2695. // int SelectWeightedSequenceFromModifiers( CStudioHdr *pstudiohdr, int activity, CUtlSymbol *pActivityModifiers, int iModifierCount );
  2696. // Actually a big array, into which the hash values index.
  2697. // SequenceTuple_PS3 *m_pSequenceTuples;
  2698. // unsigned int m_iSequenceTuplesCount; // (size of the whole array)
  2699. // we don't store an outer pointer because we can't initialize it at construction time
  2700. // (warning c4355) -- there are ways around this but it's easier to just pass in a
  2701. // pointer to the CStudioHdr when we need it, since this class isn't supposed to
  2702. // export its interface outside the studio header anyway.
  2703. // CStudioHdr * const m_pOuter;
  2704. // ActivityToValueIdxHash_PS3 m_ActToSeqHash;
  2705. //
  2706. // const studiohdr_t_PS3 *m_pStudioHdr;
  2707. // we store these so we can know if the contents of the studiohdr have changed
  2708. // from underneath our feet (this is an emergency data integrity check)
  2709. // const void *m_expectedVModel;
  2710. // double-check that the data I point to hasn't changed
  2711. // bool ValidateAgainst( const CStudioHdr * RESTRICT pstudiohdr ) RESTRICT;
  2712. // void SetValidation( const CStudioHdr *RESTRICT pstudiohdr ) RESTRICT;
  2713. // friend class CStudioHdr_PS3;
  2714. // };
  2715. // CActivityToSequenceMapping_PS3 *m_pActivityToSequence;
  2716. // void InitActivityToSequence()
  2717. // {
  2718. // if ( !m_pActivityToSequence )
  2719. // {
  2720. // m_pActivityToSequence = CActivityToSequenceMapping::FindMapping( this );
  2721. // }
  2722. // }
  2723. /// A more efficient version of the old SelectWeightedSequence() function in animation.cpp.
  2724. /// Returns -1 on failure to find a sequence
  2725. // inline int SelectWeightedSequence( int activity, int curSequence )
  2726. // {
  2727. // InitActivityToSequence();
  2728. // return m_pActivityToSequence->SelectWeightedSequence( this, activity, curSequence );
  2729. // }
  2730. // inline int SelectWeightedSequenceFromModifiers( int activity, CUtlSymbol *pActivityModifiers, int iModifierCount )
  2731. // {
  2732. // InitActivityToSequence();
  2733. // return m_pActivityToSequence->SelectWeightedSequenceFromModifiers( this, activity, pActivityModifiers, iModifierCount );
  2734. // }
  2735. /// True iff there is at least one sequence for the given activity.
  2736. // inline bool HaveSequenceForActivity( int activity )
  2737. // {
  2738. // InitActivityToSequence();
  2739. // return (m_pActivityToSequence->NumSequencesForActivity( activity ) > 0);
  2740. // }
  2741. // Force this CStudioHdr's activity-to-sequence mapping to be reinitialized
  2742. // inline void ReinitializeSequenceMapping(void)
  2743. // {
  2744. // if ( m_pActivityToSequence )
  2745. // {
  2746. // CActivityToSequenceMapping::ReleaseMapping( m_pActivityToSequence );
  2747. // m_pActivityToSequence = NULL;
  2748. // }
  2749. // m_pActivityToSequence = CActivityToSequenceMapping::FindMapping( this );
  2750. // }
  2751. // #ifdef STUDIO_ENABLE_PERF_COUNTERS
  2752. // public:
  2753. // inline void ClearPerfCounters_PS3( void )
  2754. // {
  2755. // m_nPerfAnimatedBones = 0;
  2756. // m_nPerfUsedBones = 0;
  2757. // m_nPerfAnimationLayers = 0;
  2758. // };
  2759. //
  2760. // // timing info
  2761. // mutable int m_nPerfAnimatedBones;
  2762. // mutable int m_nPerfUsedBones;
  2763. // mutable int m_nPerfAnimationLayers;
  2764. // #endif
  2765. // };
  2766. /*
  2767. class CModelAccess
  2768. {
  2769. public:
  2770. CModelAccess(CStudioHdr *pSemaphore)
  2771. : m_pStudioHdr(pSemaphore)
  2772. {
  2773. m_pStudioHdr->IncrementAccess();
  2774. }
  2775. ~CModelAccess()
  2776. {
  2777. m_pStudioHdr->DecrementAccess();
  2778. }
  2779. private:
  2780. CStudioHdr *m_pStudioHdr;
  2781. };
  2782. #define ENABLE_MODEL_ACCESS( a ) \
  2783. CModelAccess ModelAccess##__LINE__( a->m_pStudioHdr )
  2784. */
  2785. //-----------------------------------------------------------------------------
  2786. // Purpose:
  2787. //-----------------------------------------------------------------------------
  2788. // struct flexweight_t
  2789. // {
  2790. // DECLARE_BYTESWAP_DATADESC();
  2791. // int key;
  2792. // float weight;
  2793. // float influence;
  2794. // };
  2795. //
  2796. // struct flexsetting_t
  2797. // {
  2798. // DECLARE_BYTESWAP_DATADESC();
  2799. // int nameindex;
  2800. //
  2801. // inline char *pszName( void ) const
  2802. // {
  2803. // return (char *)(((byte *)this) + nameindex);
  2804. // }
  2805. //
  2806. // // Leaving this for legacy support
  2807. // int obsolete1;
  2808. //
  2809. // // Number of flex settings
  2810. // int numsettings;
  2811. // int index;
  2812. //
  2813. // // OBSOLETE:
  2814. // int obsolete2;
  2815. //
  2816. // // Index of start of contiguous array of flexweight_t structures
  2817. // int settingindex;
  2818. //
  2819. // //-----------------------------------------------------------------------------
  2820. // // Purpose: Retrieves a pointer to the flexweight_t, including resolving
  2821. // // any markov chain hierarchy. Because of this possibility, we return
  2822. // // the number of settings in the weights array returned. We'll generally
  2823. // // call this function with i == 0
  2824. // // Input : *base -
  2825. // // i -
  2826. // // **weights -
  2827. // // Output : int
  2828. // //-----------------------------------------------------------------------------
  2829. // inline int psetting( byte *base, int i, flexweight_t **weights ) const;
  2830. // };
  2831. //
  2832. //
  2833. // struct flexsettinghdr_t
  2834. // {
  2835. // DECLARE_BYTESWAP_DATADESC();
  2836. // int id;
  2837. // int version;
  2838. //
  2839. // inline const char * pszName( void ) const { return name; }
  2840. // char name[64];
  2841. // int length;
  2842. //
  2843. // int numflexsettings;
  2844. // int flexsettingindex;
  2845. // inline flexsetting_t *pSetting( int i ) const { return (flexsetting_t *)(((byte *)this) + flexsettingindex) + i; };
  2846. // int nameindex;
  2847. //
  2848. // // look up flex settings by "index"
  2849. // int numindexes;
  2850. // int indexindex;
  2851. //
  2852. // inline flexsetting_t *pIndexedSetting( int index ) const
  2853. // {
  2854. // if ( index < 0 || index >= numindexes )
  2855. // {
  2856. // return NULL;
  2857. // }
  2858. //
  2859. // int i = *((int *)(((byte *)this) + indexindex) + index);
  2860. //
  2861. // if (i == -1)
  2862. // {
  2863. // return NULL;
  2864. // }
  2865. //
  2866. // return pSetting( i );
  2867. // }
  2868. //
  2869. // // index names of "flexcontrollers"
  2870. // int numkeys;
  2871. // int keynameindex;
  2872. // inline char *pLocalName( int i ) const { return (char *)(((byte *)this) + *((int *)(((byte *)this) + keynameindex) + i)); };
  2873. //
  2874. // int keymappingindex;
  2875. // inline int *pLocalToGlobal( int i ) const { return (int *)(((byte *)this) + keymappingindex) + i; };
  2876. // inline int LocalToGlobal( int i ) const { return *pLocalToGlobal( i ); };
  2877. // };
  2878. //-----------------------------------------------------------------------------
  2879. // Purpose: Retrieves a pointer to the flexweight_t.
  2880. // Input : *base - flexsettinghdr_t * pointer
  2881. // i - index of flex setting to retrieve
  2882. // **weights - destination for weights array starting at index i.
  2883. // Output : int
  2884. //-----------------------------------------------------------------------------
  2885. // inline int flexsetting_t::psetting( byte *base, int i, flexweight_t **weights ) const
  2886. // {
  2887. // // Grab array pointer
  2888. // *weights = (flexweight_t *)(((byte *)this) + settingindex) + i;
  2889. // // Return true number of settings
  2890. // return numsettings;
  2891. // };
  2892. //-----------------------------------------------------------------------------
  2893. // For a given flex controller ui struct, these return the index of the
  2894. // studiohdr_t flex controller that correspond to the the left and right
  2895. // flex controllers if the ui controller is a stereo control.
  2896. // nWayValueIndex returns the index of the flex controller that is the value
  2897. // flex controller for an NWAY combination
  2898. // If these functions are called and the ui controller isn't of the type
  2899. // specified then -1 is returned
  2900. //-----------------------------------------------------------------------------
  2901. // inline int mstudioflexcontrollerui_t::controllerIndex( const CStudioHdr &cStudioHdr ) const
  2902. // {
  2903. // return !stereo ? pController() - cStudioHdr.pFlexcontroller( (LocalFlexController_t)0 ) : -1;
  2904. // }
  2905. //
  2906. //
  2907. // inline int mstudioflexcontrollerui_t::rightIndex( const CStudioHdr &cStudioHdr ) const
  2908. // {
  2909. // return stereo ? pRightController() - cStudioHdr.pFlexcontroller( (LocalFlexController_t)0 ) : -1;
  2910. // }
  2911. //
  2912. //
  2913. // inline int mstudioflexcontrollerui_t::leftIndex( const CStudioHdr &cStudioHdr ) const
  2914. // {
  2915. // return stereo ? pLeftController() - cStudioHdr.pFlexcontroller((LocalFlexController_t) 0 ) : -1;
  2916. // }
  2917. //
  2918. //
  2919. // inline int mstudioflexcontrollerui_t::nWayValueIndex( const CStudioHdr &cStudioHdr ) const
  2920. // {
  2921. // return remaptype == FLEXCONTROLLER_REMAP_NWAY ? pNWayValueController() - cStudioHdr.pFlexcontroller( (LocalFlexController_t)0 ) : -1;
  2922. // }
  2923. // inline const mstudioflexcontroller_t *mstudioflexcontrollerui_t::pController( int index ) const
  2924. // {
  2925. // if ( index < 0 || index > Count() )
  2926. // return NULL;
  2927. //
  2928. // if ( remaptype == FLEXCONTROLLER_REMAP_NWAY )
  2929. // {
  2930. // if ( stereo )
  2931. // return (mstudioflexcontroller_t *)( ( char * ) this ) + *( &szindex0 + index );
  2932. //
  2933. // if ( index == 0 )
  2934. // return pController();
  2935. //
  2936. // if ( index == 1 )
  2937. // return pNWayValueController();
  2938. //
  2939. // return NULL;
  2940. // }
  2941. //
  2942. // if ( index > 1 )
  2943. // return NULL;
  2944. //
  2945. // if ( stereo )
  2946. // return (mstudioflexcontroller_t *)( ( char * ) this ) + *( &szindex0 + index );
  2947. //
  2948. // if ( index > 0 )
  2949. // return NULL;
  2950. //
  2951. // return pController();
  2952. // }
  2953. // #define STUDIO_CONST 1 // get float
  2954. // #define STUDIO_FETCH1 2 // get Flexcontroller value
  2955. // #define STUDIO_FETCH2 3 // get flex weight
  2956. // #define STUDIO_ADD 4
  2957. // #define STUDIO_SUB 5
  2958. // #define STUDIO_MUL 6
  2959. // #define STUDIO_DIV 7
  2960. // #define STUDIO_NEG 8 // not implemented
  2961. // #define STUDIO_EXP 9 // not implemented
  2962. // #define STUDIO_OPEN 10 // only used in token parsing
  2963. // #define STUDIO_CLOSE 11
  2964. // #define STUDIO_COMMA 12 // only used in token parsing
  2965. // #define STUDIO_MAX 13
  2966. // #define STUDIO_MIN 14
  2967. // #define STUDIO_2WAY_0 15 // Fetch a value from a 2 Way slider for the 1st value RemapVal( 0.0, 0.5, 0.0, 1.0 )
  2968. // #define STUDIO_2WAY_1 16 // Fetch a value from a 2 Way slider for the 2nd value RemapVal( 0.5, 1.0, 0.0, 1.0 )
  2969. // #define STUDIO_NWAY 17 // Fetch a value from a 2 Way slider for the 2nd value RemapVal( 0.5, 1.0, 0.0, 1.0 )
  2970. // #define STUDIO_COMBO 18 // Perform a combo operation (essentially multiply the last N values on the stack)
  2971. // #define STUDIO_DOMINATE 19 // Performs a combination domination operation
  2972. // #define STUDIO_DME_LOWER_EYELID 20 //
  2973. // #define STUDIO_DME_UPPER_EYELID 21 //
  2974. //
  2975. // // motion flags
  2976. // #define STUDIO_X 0x00000001
  2977. // #define STUDIO_Y 0x00000002
  2978. // #define STUDIO_Z 0x00000004
  2979. // #define STUDIO_XR 0x00000008
  2980. // #define STUDIO_YR 0x00000010
  2981. // #define STUDIO_ZR 0x00000020
  2982. //
  2983. // #define STUDIO_LX 0x00000040
  2984. // #define STUDIO_LY 0x00000080
  2985. // #define STUDIO_LZ 0x00000100
  2986. // #define STUDIO_LXR 0x00000200
  2987. // #define STUDIO_LYR 0x00000400
  2988. // #define STUDIO_LZR 0x00000800
  2989. //
  2990. // #define STUDIO_LINEAR 0x00001000
  2991. //
  2992. // #define STUDIO_TYPES 0x0003FFFF
  2993. // #define STUDIO_RLOOP 0x00040000 // controller that wraps shortest distance
  2994. //
  2995. // // sequence and autolayer flags
  2996. // #define STUDIO_LOOPING 0x0001 // ending frame should be the same as the starting frame
  2997. // #define STUDIO_SNAP 0x0002 // do not interpolate between previous animation and this one
  2998. // #define STUDIO_DELTA 0x0004 // this sequence "adds" to the base sequences, not slerp blends
  2999. // #define STUDIO_AUTOPLAY 0x0008 // temporary flag that forces the sequence to always play
  3000. // #define STUDIO_POST 0x0010 //
  3001. // #define STUDIO_ALLZEROS 0x0020 // this animation/sequence has no real animation data
  3002. // #define STUDIO_FRAMEANIM 0x0040 // animation is encoded as by frame x bone instead of RLE bone x frame
  3003. // #define STUDIO_CYCLEPOSE 0x0080 // cycle index is taken from a pose parameter index
  3004. // #define STUDIO_REALTIME 0x0100 // cycle index is taken from a real-time clock, not the animations cycle index
  3005. // #define STUDIO_LOCAL 0x0200 // sequence has a local context sequence
  3006. // #define STUDIO_HIDDEN 0x0400 // don't show in default selection views
  3007. // #define STUDIO_OVERRIDE 0x0800 // a forward declared sequence (empty)
  3008. // #define STUDIO_ACTIVITY 0x1000 // Has been updated at runtime to activity index
  3009. // #define STUDIO_EVENT 0x2000 // Has been updated at runtime to event index on server
  3010. // #define STUDIO_WORLD 0x4000 // sequence blends in worldspace
  3011. // #define STUDIO_NOFORCELOOP 0x8000 // do not force the animation loop
  3012. // #define STUDIO_EVENT_CLIENT 0x10000 // Has been updated at runtime to event index on client
  3013. // autolayer flags
  3014. // 0x0001
  3015. // 0x0002
  3016. // 0x0004
  3017. // 0x0008
  3018. //#define STUDIO_AL_POST 0x0010 //
  3019. // 0x0020
  3020. //#define STUDIO_AL_SPLINE 0x0040 // convert layer ramp in/out curve is a spline instead of linear
  3021. //#define STUDIO_AL_XFADE 0x0080 // pre-bias the ramp curve to compense for a non-1 weight, assuming a second layer is also going to accumulate
  3022. // 0x0100
  3023. //#define STUDIO_AL_NOBLEND 0x0200 // animation always blends at 1.0 (ignores weight)
  3024. // 0x0400
  3025. // 0x0800
  3026. //#define STUDIO_AL_LOCAL 0x1000 // layer is a local context sequence
  3027. // 0x2000
  3028. //#define STUDIO_AL_POSE 0x4000 // layer blends using a pose parameter instead of parent cycle
  3029. // Insert this code anywhere that you need to allow for conversion from an old STUDIO_VERSION to a new one.
  3030. // If we only support the current version, this function should be empty.
  3031. // inline bool Studio_ConvertStudioHdrToNewVersion( studiohdr_t *pStudioHdr )
  3032. // {
  3033. // COMPILE_TIME_ASSERT( STUDIO_VERSION == 49 ); // put this to make sure this code is updated upon changing version.
  3034. //
  3035. // int version = pStudioHdr->version;
  3036. // if ( version == STUDIO_VERSION )
  3037. // return true;
  3038. //
  3039. // bool bResult = true;
  3040. // if (version < 46)
  3041. // {
  3042. // // some of the anim index data is incompatible
  3043. // for (int i = 0; i < pStudioHdr->numlocalanim; i++)
  3044. // {
  3045. // mstudioanimdesc_t *pAnim = (mstudioanimdesc_t *)pStudioHdr->pLocalAnimdesc( i );
  3046. //
  3047. // // old ANI files that used sections (v45 only) are not compatible
  3048. // if ( pAnim->sectionframes != 0 )
  3049. // {
  3050. // // zero most everything out
  3051. // memset( &(pAnim->numframes), 0, (byte *)(pAnim + 1) - (byte *)&(pAnim->numframes) );
  3052. //
  3053. // pAnim->numframes = 1;
  3054. // pAnim->animblock = -1; // disable animation fetching
  3055. // bResult = false;
  3056. // }
  3057. // }
  3058. // }
  3059. //
  3060. // if (version < 47)
  3061. // {
  3062. // // now used to contain zeroframe cache data, make sure it's empty
  3063. // if (pStudioHdr->unused4 != 0)
  3064. // {
  3065. // pStudioHdr->unused4 = 0;
  3066. // bResult = false;
  3067. // }
  3068. // for (int i = 0; i < pStudioHdr->numlocalanim; i++)
  3069. // {
  3070. // mstudioanimdesc_t *pAnim = (mstudioanimdesc_t *)pStudioHdr->pLocalAnimdesc( i );
  3071. // pAnim->zeroframeindex = 0;
  3072. // pAnim->zeroframespan = 0;
  3073. // }
  3074. // }
  3075. // else if (version == 47)
  3076. // {
  3077. // // clear out stale version of zeroframe cache data
  3078. // for (int i = 0; i < pStudioHdr->numlocalanim; i++)
  3079. // {
  3080. // mstudioanimdesc_t *pAnim = (mstudioanimdesc_t *)pStudioHdr->pLocalAnimdesc( i );
  3081. // if (pAnim->zeroframeindex != 0)
  3082. // {
  3083. // pAnim->zeroframeindex = 0;
  3084. // pAnim->zeroframespan = 0;
  3085. // bResult = false;
  3086. // }
  3087. // }
  3088. // }
  3089. //
  3090. // if (version < 49)
  3091. // {
  3092. // // remove any frameanim flag settings that might be stale
  3093. // for (int i = 0; i < pStudioHdr->numlocalanim; i++)
  3094. // {
  3095. // mstudioanimdesc_t *pAnim = (mstudioanimdesc_t *)pStudioHdr->pLocalAnimdesc( i );
  3096. // if (pAnim->flags & STUDIO_FRAMEANIM)
  3097. // {
  3098. // pAnim->flags &= ~STUDIO_FRAMEANIM;
  3099. // bResult = false;
  3100. // }
  3101. // }
  3102. // }
  3103. // // for now, just slam the version number since they're compatible
  3104. // pStudioHdr->version = STUDIO_VERSION;
  3105. //
  3106. // return bResult;
  3107. // }
  3108. // must be run to fixup with specified rootLOD
  3109. // inline void Studio_SetRootLOD( studiohdr_t *pStudioHdr, int rootLOD )
  3110. // {
  3111. // // honor studiohdr restriction of root lod in case requested root lod exceeds restriction.
  3112. // if ( pStudioHdr->numAllowedRootLODs > 0 &&
  3113. // rootLOD >= pStudioHdr->numAllowedRootLODs )
  3114. // {
  3115. // rootLOD = pStudioHdr->numAllowedRootLODs - 1;
  3116. // }
  3117. //
  3118. // // run the lod fixups that culls higher detail lods
  3119. // // vertexes are external, fixups ensure relative offsets and counts are cognizant of shrinking data
  3120. // // indexes are built in lodN..lod0 order so higher detail lod data can be truncated at load
  3121. // // the fixup lookup arrays are filled (or replicated) to ensure all slots valid
  3122. // int vertexindex = 0;
  3123. // int tangentsindex = 0;
  3124. // int bodyPartID;
  3125. // for ( bodyPartID = 0; bodyPartID < pStudioHdr->numbodyparts; bodyPartID++ )
  3126. // {
  3127. // mstudiobodyparts_t *pBodyPart = pStudioHdr->pBodypart( bodyPartID );
  3128. // int modelID;
  3129. // for ( modelID = 0; modelID < pBodyPart->nummodels; modelID++ )
  3130. // {
  3131. // mstudiomodel_t *pModel = pBodyPart->pModel( modelID );
  3132. // int totalMeshVertexes = 0;
  3133. // int meshID;
  3134. // for ( meshID = 0; meshID < pModel->nummeshes; meshID++ )
  3135. // {
  3136. // mstudiomesh_t *pMesh = pModel->pMesh( meshID );
  3137. //
  3138. // // get the fixup, vertexes are reduced
  3139. // pMesh->numvertices = pMesh->vertexdata.numLODVertexes[rootLOD];
  3140. // pMesh->vertexoffset = totalMeshVertexes;
  3141. // totalMeshVertexes += pMesh->numvertices;
  3142. // }
  3143. //
  3144. // // stay in sync
  3145. // pModel->numvertices = totalMeshVertexes;
  3146. // pModel->vertexindex = vertexindex;
  3147. // pModel->tangentsindex = tangentsindex;
  3148. //
  3149. // vertexindex += totalMeshVertexes*sizeof(mstudiovertex_t);
  3150. // tangentsindex += totalMeshVertexes*sizeof(Vector4D);
  3151. // }
  3152. // }
  3153. //
  3154. // // track the set desired configuration
  3155. // pStudioHdr->rootLOD = rootLOD;
  3156. // }
  3157. // Determines allocation requirements for vertexes
  3158. // inline int Studio_VertexDataSize( const vertexFileHeader_t *pVvdHdr, int rootLOD, bool bNeedsTangentS )
  3159. // {
  3160. // // the quantity of vertexes necessary for root lod and all lower detail lods
  3161. // // add one extra vertex to each section
  3162. // // the extra vertex allows prefetch hints to read ahead 1 vertex without faulting
  3163. // int numVertexes = pVvdHdr->numLODVertexes[rootLOD] + 1;
  3164. // int dataLength = pVvdHdr->vertexDataStart + numVertexes*sizeof(mstudiovertex_t);
  3165. // if (bNeedsTangentS)
  3166. // {
  3167. // dataLength += numVertexes*sizeof(Vector4D);
  3168. // #ifdef _PS3
  3169. // if ( !pVvdHdr->numFixups && ( pVvdHdr->ps3edgeDmaInputDesc & 0x80000000 ) )
  3170. // {
  3171. // // PS3 does not support root lod, so all vertexes will be used
  3172. // dataLength = pVvdHdr->GetPs3EdgeDmaInputStart() + pVvdHdr->GetPs3EdgeDmaInputLength();
  3173. // }
  3174. // #endif
  3175. // }
  3176. //
  3177. // // allocate this much
  3178. // return dataLength;
  3179. // }
  3180. // Load the minimum quantity of verts and run fixups
  3181. // inline int Studio_LoadVertexes( const vertexFileHeader_t *pTempVvdHdr, vertexFileHeader_t *pNewVvdHdr, int rootLOD, bool bNeedsTangentS )
  3182. // {
  3183. // int i;
  3184. // int target;
  3185. // int numVertexes;
  3186. // vertexFileFixup_t *pFixupTable;
  3187. //
  3188. // numVertexes = pTempVvdHdr->numLODVertexes[rootLOD];
  3189. //
  3190. // // copy all data up to start of vertexes
  3191. // memcpy((void*)pNewVvdHdr, (void*)pTempVvdHdr, pTempVvdHdr->vertexDataStart);
  3192. //
  3193. // for ( i = 0; i < rootLOD; i++)
  3194. // {
  3195. // pNewVvdHdr->numLODVertexes[i] = pNewVvdHdr->numLODVertexes[rootLOD];
  3196. // }
  3197. //
  3198. // // fixup data starts
  3199. // if (bNeedsTangentS)
  3200. // {
  3201. // // tangent data follows possibly reduced vertex data
  3202. // pNewVvdHdr->tangentDataStart = pNewVvdHdr->vertexDataStart + numVertexes*sizeof(mstudiovertex_t);
  3203. //
  3204. // #ifdef _PS3
  3205. // // PS3 does not support root LOD, so all vertices will be available
  3206. // if ( !pTempVvdHdr->numFixups && ( pTempVvdHdr->ps3edgeDmaInputDesc & 0x80000000 ) )
  3207. // {
  3208. // pNewVvdHdr->ps3edgeDmaInputDesc = pTempVvdHdr->ps3edgeDmaInputDesc;
  3209. // }
  3210. // else
  3211. // {
  3212. // pNewVvdHdr->ps3edgeDmaInputDesc = 0;
  3213. // }
  3214. // #endif
  3215. // }
  3216. // else
  3217. // {
  3218. // // no tangent data will be available, mark for identification
  3219. // pNewVvdHdr->tangentDataStart = 0;
  3220. //
  3221. // #ifdef _PS3
  3222. // pNewVvdHdr->ps3edgeDmaInputDesc = 0;
  3223. // #endif
  3224. // }
  3225. //
  3226. // if (!pNewVvdHdr->numFixups)
  3227. // {
  3228. // // fixups not required
  3229. // // transfer vertex data
  3230. // memcpy(
  3231. // (byte *)pNewVvdHdr+pNewVvdHdr->vertexDataStart,
  3232. // (byte *)pTempVvdHdr+pTempVvdHdr->vertexDataStart,
  3233. // numVertexes*sizeof(mstudiovertex_t) );
  3234. //
  3235. // if (bNeedsTangentS)
  3236. // {
  3237. // // transfer tangent data to cache memory
  3238. // memcpy(
  3239. // (byte *)pNewVvdHdr+pNewVvdHdr->tangentDataStart,
  3240. // (byte *)pTempVvdHdr+pTempVvdHdr->tangentDataStart,
  3241. // numVertexes*sizeof(Vector4D) );
  3242. //
  3243. // #ifdef _PS3
  3244. // if ( pNewVvdHdr->ps3edgeDmaInputDesc )
  3245. // {
  3246. // // transfer EDGE DMA INPUT to cache memory
  3247. // memcpy(
  3248. // const_cast< byte* >( pNewVvdHdr->GetPs3EdgeDmaInput() ),
  3249. // pTempVvdHdr->GetPs3EdgeDmaInput(),
  3250. // pTempVvdHdr->GetPs3EdgeDmaInputLength()
  3251. // );
  3252. // }
  3253. // #endif
  3254. // }
  3255. //
  3256. // return numVertexes;
  3257. // }
  3258. //
  3259. // // fixups required
  3260. // // re-establish mesh ordered vertexes into cache memory, according to table
  3261. // target = 0;
  3262. // pFixupTable = (vertexFileFixup_t *)((byte *)pTempVvdHdr + pTempVvdHdr->fixupTableStart);
  3263. // for (i=0; i<pTempVvdHdr->numFixups; i++)
  3264. // {
  3265. // if (pFixupTable[i].lod < rootLOD)
  3266. // {
  3267. // // working bottom up, skip over copying higher detail lods
  3268. // continue;
  3269. // }
  3270. //
  3271. // // copy vertexes
  3272. // memcpy(
  3273. // (mstudiovertex_t *)((byte *)pNewVvdHdr+pNewVvdHdr->vertexDataStart) + target,
  3274. // (mstudiovertex_t *)((byte *)pTempVvdHdr+pTempVvdHdr->vertexDataStart) + pFixupTable[i].sourceVertexID,
  3275. // pFixupTable[i].numVertexes*sizeof(mstudiovertex_t) );
  3276. //
  3277. // if (bNeedsTangentS)
  3278. // {
  3279. // // copy tangents
  3280. // memcpy(
  3281. // (Vector4D *)((byte *)pNewVvdHdr+pNewVvdHdr->tangentDataStart) + target,
  3282. // (Vector4D *)((byte *)pTempVvdHdr+pTempVvdHdr->tangentDataStart) + pFixupTable[i].sourceVertexID,
  3283. // pFixupTable[i].numVertexes*sizeof(Vector4D) );
  3284. // }
  3285. //
  3286. // // data is placed consecutively
  3287. // target += pFixupTable[i].numVertexes;
  3288. // }
  3289. //
  3290. // pNewVvdHdr->numFixups = 0;
  3291. // pNewVvdHdr->fixupTableStart = 0; // otherwise PS3 will be confusing it for EDGE DMA INPUT
  3292. //
  3293. // return target;
  3294. // }
  3295. #endif // STUDIO__PS3_H