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

479 lines
13 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. //
  9. // Half-Life Model Viewer (c) 1999 by Mete Ciragan
  10. //
  11. // file: ControlPanel.h
  12. // last modified: May 29 programs and associated files contained in this
  13. // distribution were developed by Mete Ciragan. The programs
  14. // are not in the public domain, but they are freely
  15. // distributable without licensing fees. These programs are
  16. // provided without guarantee or warrantee expressed or
  17. // implied.
  18. //
  19. // version: 1.2
  20. //
  21. // email: [email protected]
  22. // web: http://www.swissquake.ch/chumbalum-soft/
  23. //
  24. #ifndef INCLUDED_CONTROLPANEL
  25. #define INCLUDED_CONTROLPANEL
  26. #ifndef INCLUDED_MXWINDOW
  27. #include <mxtk/mxWindow.h>
  28. #endif
  29. #define IDC_TAB 1901
  30. #define IDC_RENDERMODE 2001
  31. #define IDC_GROUND 2003
  32. #define IDC_MOVEMENT 2004
  33. #define IDC_BACKGROUND 2005
  34. #define IDC_HITBOXES 2006
  35. #define IDC_BONES 2007
  36. #define IDC_ATTACHMENTS 2008
  37. #define IDC_PHYSICSMODEL 2009
  38. #define IDC_PHYSICSHIGHLIGHT 2010
  39. #define IDC_LODCHOICE 2011
  40. #define IDC_AUTOLOD 2012
  41. #define IDC_LODSWITCH 2013
  42. #define IDC_SOFTWARESKIN 2014
  43. #define IDC_OVERBRIGHT2 2015
  44. #define IDC_RENDER_FOV 2016
  45. #define IDC_SEQUENCEBOXES 2017
  46. #define IDC_RUNIK 2018
  47. #define IDC_HEADTURN 2019
  48. #define IDC_NORMALS 2020
  49. #define IDC_TANGENTFRAME 2021
  50. #define IDC_NORMALMAP 2022
  51. #define IDC_SPECULAR 2023
  52. #define IDC_SHADOW 2024
  53. #define IDC_ILLUMPOSITION 2025
  54. #define IDC_OVERLAY_WIREFRAME 2026
  55. #define IDC_PLAYSOUNDS 2027
  56. #define IDC_MESSAGES 2028
  57. #define IDC_SHADERS 2029
  58. //#define IDC_PARALLAXMAP 2030
  59. #define IDC_SHOWORIGINAXIS 2029
  60. #define IDC_ORIGINAXISLENGTH 2030
  61. #define MAX_SEQUENCES 5
  62. #define IDC_SEQUENCE0 3000
  63. #define IDC_SEQUENCE1 3001
  64. #define IDC_SEQUENCE2 3002
  65. #define IDC_SEQUENCE3 3003
  66. #define IDC_SEQUENCE4 3004
  67. #define IDC_SEQUENCESCALE0 3005
  68. #define IDC_SEQUENCESCALE1 3006
  69. #define IDC_SEQUENCESCALE2 3007
  70. #define IDC_SEQUENCESCALE3 3008
  71. #define IDC_SEQUENCESCALE4 3009
  72. #define IDC_FRAMESELECTION0 3010
  73. #define IDC_FRAMESELECTION1 3011
  74. #define IDC_FRAMESELECTION2 3012
  75. #define IDC_FRAMESELECTION3 3013
  76. #define IDC_FRAMESELECTION4 3014
  77. #define NUM_POSEPARAMETERS 8
  78. #define IDC_POSEPARAMETER_SCALE 3100
  79. #define IDC_POSEPARAMETER 3120
  80. #define IDC_POSEPARAMETER_VALUE 3140
  81. #define IDC_SPEEDSCALE 3201
  82. #define IDC_FORCEFRAME 3202
  83. #define IDC_BLENDSEQUENCECHANGES 3203
  84. #define IDC_BLENDNOW 3204
  85. #define IDC_BLENDTIME 3205
  86. #define IDC_ACTIVITY_MODIFIERS 3206
  87. #define IDC_ANIMATEWEAPONS 3207
  88. #define IDC_BODYPART 4001
  89. #define IDC_SUBMODEL 4002
  90. #define IDC_CONTROLLER 4003
  91. #define IDC_CONTROLLERVALUE 4004
  92. #define IDC_SKINS 4005
  93. #define IDC_MATERIALS 4006
  94. #define IDC_BONE_BONELIST 5000
  95. #define IDC_BONE_GENERATEQC 5001
  96. #define IDC_BONE_HIGHLIGHT_BONE 5002
  97. #define IDC_BONE_HITBOXLIST 5003
  98. #define IDC_BONE_SURFACEPROP 5004
  99. #define IDC_BONE_HIGHLIGHT_HITBOX 5005
  100. #define IDC_BONE_ADD_HITBOX 5006
  101. #define IDC_BONE_DELETE_HITBOX 5007
  102. #define IDC_BONE_APPLY_TO_CHILDREN 5008
  103. #define IDC_BONE_SHOW_DEFAULT_POSE 5009
  104. #define IDC_BONE_HITBOX_ORIGINX 5010
  105. #define IDC_BONE_HITBOX_ORIGINY 5011
  106. #define IDC_BONE_HITBOX_ORIGINZ 5012
  107. #define IDC_BONE_HITBOX_SIZEX 5013
  108. #define IDC_BONE_HITBOX_SIZEY 5014
  109. #define IDC_BONE_HITBOX_SIZEZ 5015
  110. #define IDC_BONE_HITBOX_GROUP 5016
  111. #define IDC_BONE_UPDATE_HITBOX 5017
  112. #define IDC_BONE_USE_AUTOGENERATED_HITBOXES 5018
  113. #define IDC_BONE_HITBOXSET 5019
  114. #define IDC_BONE_HITBOXADDSET 5020
  115. #define IDC_BONE_HITBOXDELETESET 5021
  116. #define IDC_BONE_HITBOXSETNAME 5022
  117. #define IDC_BONE_HITBOXSETNAME_EDIT 5023
  118. // This range is reserved for the attachment window.
  119. #define IDC_ATTACHMENT_WINDOW_FIRST 5024
  120. #define IDC_ATTACHMENT_WINDOW_LAST 5100
  121. #define IDC_BONE_HITBOX_NAME 5101
  122. #define IDC_BONE_SAVE_HITBOXES 5102
  123. #define IDC_BONE_LOAD_HITBOXES 5103
  124. #define IDC_FLEX 7001
  125. #define IDC_FLEXDEFAULTS 7002
  126. #define IDC_FLEXRANDOM 7003
  127. #define IDC_FLEXZERO 7004
  128. #define IDC_FLEXONE 7005
  129. #define IDC_FLEXSCALE 7101
  130. #define NUM_FLEX_SLIDERS 48
  131. #define IDC_PHYS_FIRST 7501
  132. #define IDC_PHYS_BONE 7501
  133. #define IDC_PHYS_CON_LINK_LIMITS 7502
  134. #define IDC_PHYS_MATERIAL 7503
  135. #define IDC_PHYS_CON_MIN 7504
  136. #define IDC_PHYS_CON_MAX 7505
  137. #define IDC_PHYS_CON_TEST 7506
  138. #define IDC_PHYS_P_MASSBIAS 7507
  139. #define IDC_PHYS_CON_FRICTION 7508
  140. //#define IDC_PHYS_P_ELASTICITY 7509
  141. #define IDC_PHYS_P_INERTIA 7510
  142. #define IDC_PHYS_P_DAMPING 7511
  143. #define IDC_PHYS_P_ROT_DAMPING 7512
  144. #define IDC_PHYS_MASS 7513
  145. #define IDC_PHYS_QCFILE 7514
  146. #define IDC_PHYS_CON_AXIS_X 7515
  147. #define IDC_PHYS_CON_AXIS_Y 7516
  148. #define IDC_PHYS_CON_AXIS_Z 7517
  149. #define IDC_PHYS_CON_TYPE_FREE 7518
  150. #define IDC_PHYS_CON_TYPE_FIXED 7519
  151. #define IDC_PHYS_CON_TYPE_LIMIT 7520
  152. #define IDC_PHYS_LAST 7599
  153. #define MAX_ANIMS 4
  154. #define IDC_ANIMX 8020 // through 8023 ( MAX_ANIMS )
  155. #define IDC_ANIMY 8030 // through 8033 ( MAX_ANIMS )
  156. #define IDC_IKRULE_CHAIN 9000
  157. #define IDC_IKRULE_CHOICE 9001
  158. #define IDC_IKRULE_TOUCH 9002
  159. #define IDC_IKRULE_ATTACHMENT 9003
  160. #define IDC_IKRULE_RANGE_TOGGLE 9004
  161. #define IDC_IKRULE_RANGE_START 9005
  162. #define IDC_IKRULE_RANGE_PEAK 9006
  163. #define IDC_IKRULE_RANGE_TAIL 9007
  164. #define IDC_IKRULE_RANGE_END 9008
  165. #define IDC_IKRULE_RANGE_START_NOW 9009
  166. #define IDC_IKRULE_RANGE_PEAK_NOW 9010
  167. #define IDC_IKRULE_RANGE_TAIL_NOW 9011
  168. #define IDC_IKRULE_RANGE_END_NOW 9012
  169. #define IDC_IKRULE_CONTACT_TOGGLE 9013
  170. #define IDC_IKRULE_CONTACT_FRAME_NOW 9014
  171. #define IDC_IKRULE_CONTACT_FRAME 9015
  172. #define IDC_IKRULE_USING 9016
  173. #define IDC_IKRULE_QC_STRING 9017
  174. #define IDC_EVENT_SOUND_FRAME_NOW 6000
  175. #define IDC_EVENT_SOUND_FRAME 6001
  176. #define IDC_EVENT_SOUND_NAME 6002
  177. #define IDC_EVENT_QC_STRING 6003
  178. class mxTab;
  179. class mxChoice;
  180. class mxCheckBox;
  181. class mxSlider;
  182. class mxLineEdit;
  183. class mxLineEdit2;
  184. class mxLabel;
  185. class mxListBox;
  186. class mxButton;
  187. class mxRadioButton;
  188. class MatSysWindow;
  189. class TextureWindow;
  190. class CBoneControlWindow;
  191. class CAttachmentsWindow;
  192. class CStudioHdr;
  193. // Return codes from loadModel.
  194. enum LoadModelResult_t
  195. {
  196. LoadModel_Success = 0,
  197. LoadModel_LoadFail,
  198. LoadModel_NoModel,
  199. LoadModel_PostLoadFail,
  200. };
  201. class ControlPanel : public mxWindow
  202. {
  203. mxWindow *wRender;
  204. mxTab *tab;
  205. mxChoice *cRenderMode;
  206. mxChoice *cHighlightBone;
  207. mxCheckBox *cbGround;
  208. mxCheckBox *cbHitBoxes;
  209. mxCheckBox *cbSequenceBoxes;
  210. mxCheckBox *cbShadow;
  211. mxCheckBox *cbMovement;
  212. mxCheckBox *cbBackground;
  213. mxCheckBox *cbSoftwareSkin;
  214. mxCheckBox *cbOverbright2;
  215. mxCheckBox *cbAttachments;
  216. mxCheckBox *cbBones;
  217. mxCheckBox *cbNormals;
  218. mxCheckBox *cbNormalMap;
  219. // mxCheckBox *cbParallaxMap;
  220. mxCheckBox *cbTangentFrame;
  221. mxCheckBox *cbOverlayWireframe;
  222. mxCheckBox *cbSpecular;
  223. mxCheckBox *cbRunIK;
  224. mxCheckBox *cbEnableHead;
  225. mxCheckBox *cbIllumPosition;
  226. mxCheckBox *cbPlaySounds;
  227. mxCheckBox *cbShowOriginAxis;
  228. mxSlider *leOriginAxisLength;
  229. mxChoice *cLODChoice;
  230. mxCheckBox *cbAutoLOD;
  231. mxLineEdit *leLODSwitch;
  232. mxLabel *lLODMetric;
  233. mxChoice *cSequence[MAX_SEQUENCES];
  234. mxSlider *slSequence[MAX_SEQUENCES];
  235. int *iSelectionToSequence; // selection to sequence
  236. int *iSequenceToSelection; // sequence to selection
  237. mxLabel *laGroundSpeed;
  238. mxSlider *slSpeedScale;
  239. mxLabel *laFPS;
  240. mxLabel *laBlendAmount;
  241. mxChoice *cPoseParameter[NUM_POSEPARAMETERS];
  242. mxSlider *slPoseParameter[NUM_POSEPARAMETERS];
  243. mxLineEdit *lePoseParameter[NUM_POSEPARAMETERS];
  244. mxLineEdit *leFOV;
  245. mxSlider *slBlendTime;
  246. mxLabel *laBlendTime;
  247. mxChoice *cActivityModifiers;
  248. mxSlider *slForceFrame;
  249. mxLabel *lForcedFrame;
  250. mxRadioButton *rbFrameSelection[MAX_SEQUENCES];
  251. mxChoice *cBodypart, *cController, *cSubmodel;
  252. mxSlider *slController;
  253. mxChoice *cSkin;
  254. mxChoice *cMaterials;
  255. mxLabel *lModelInfo1, *lModelInfo2, *lModelInfo3, *lModelInfo4, *lModelInfo5;
  256. //mxChoice *cTextures;
  257. //mxCheckBox *cbChrome;
  258. //mxLabel *lTexSize;
  259. //mxLineEdit *leWidth, *leHeight;
  260. mxLineEdit *leMeshScale, *leBoneScale;
  261. MatSysWindow *d_MatSysWindow;
  262. TextureWindow *d_textureWindow;
  263. mxChoice *cFlex[NUM_FLEX_SLIDERS];
  264. mxSlider *slFlexScale[NUM_FLEX_SLIDERS];
  265. mxChoice *cPhysicsBone;
  266. mxRadioButton *rbConstraintAxis[3];
  267. mxSlider *slPhysicsFriction;
  268. mxLabel *lPhysicsFriction;
  269. mxSlider *slPhysicsConMin;
  270. mxLabel *lPhysicsConMin;
  271. mxCheckBox *cbLinked; // links min/max sliders
  272. mxSlider *slPhysicsConMax;
  273. mxLabel *lPhysicsConMax;
  274. mxSlider *slPhysicsConTest;
  275. mxLineEdit *leMass;
  276. mxSlider *slPhysicsParamMassBias;
  277. mxLabel *lPhysicsParamMassBias;
  278. mxSlider *slPhysicsParamFriction;
  279. mxLabel *lPhysicsParamFriction;
  280. mxSlider *slPhysicsParamElasticity;
  281. mxLabel *lPhysicsParamElasticity;
  282. mxSlider *slPhysicsParamInertia;
  283. mxLabel *lPhysicsParamInertia;
  284. mxSlider *slPhysicsParamDamping;
  285. mxLabel *lPhysicsParamDamping;
  286. mxSlider *slPhysicsParamRotDamping;
  287. mxLabel *lPhysicsParamRotDamping;
  288. mxLabel *lPhysicsMaterial;
  289. mxChoice *cIKChain;
  290. mxChoice *cIKType;
  291. mxLabel *lIKTouch;
  292. mxChoice *cIKTouch;
  293. mxLabel *lIKAttachment;
  294. mxLineEdit *leIKAttachment;
  295. mxCheckBox *cbIKRangeToggle;
  296. mxLineEdit2 *leIKRangeStart;
  297. mxLineEdit2 *leIKRangePeak;
  298. mxLineEdit2 *leIKRangeTail;
  299. mxLineEdit2 *leIKRangeEnd;
  300. mxCheckBox *cbIKContactToggle;
  301. mxLineEdit2 *leIKContactFrame;
  302. mxChoice *cIKUsing;
  303. mxLineEdit2 *leIKQCString;
  304. mxLineEdit2 *leEventSoundFrame;
  305. mxListBox *lbEventSoundName;
  306. mxLineEdit2 *leEventQCString;
  307. CBoneControlWindow* m_pBoneWindow;
  308. CAttachmentsWindow* m_pAttachmentsWindow;
  309. mxListBox *cMessageList;
  310. mxListBox *cShaderUsed;
  311. public:
  312. // CREATORS
  313. ControlPanel (mxWindow *parent);
  314. virtual ~ControlPanel ();
  315. virtual void OnDelete();
  316. // MANIPULATORS
  317. int handleEvent (mxEvent *event);
  318. int handlePhysicsEvent( mxEvent *event );
  319. void UpdateConstraintSliders( int clamp );
  320. void setupPhysics( void );
  321. void setupPhysicsBone( int boneIndex );
  322. void setupPhysicsAxis( int boneIndex, int axis );
  323. int getPhysicsAxis( void );
  324. void setPhysicsAxis( int axisIndex );
  325. void writePhysicsData( void );
  326. void handlePhysicsKey( mxEvent *event );
  327. // void readPhysicsMaterials( mxChoice *pList );
  328. void dumpModelInfo ();
  329. LoadModelResult_t loadModel(const char *filename);
  330. LoadModelResult_t loadModel(const char *filename, int slot );
  331. void OnLoadModel( void );
  332. void resetControlPanel( void );
  333. void setRenderMode (int mode);
  334. void setShowGround (bool b);
  335. void setShowMovement (bool b);
  336. void setShowBackground (bool b);
  337. void setShowNormals (bool b);
  338. void setShowTangentFrame (bool b);
  339. void setOverlayWireframe (bool b);
  340. void setShowShadow (bool b);
  341. void setShowHitBoxes (bool b);
  342. void setShowBones (bool b);
  343. void setShowAttachments (bool b);
  344. void setHighlightBone( int index );
  345. void setLOD( int index, bool setLODchoice, bool force );
  346. void setAutoLOD( bool b );
  347. void setSoftwareSkin( bool b );
  348. void setOverbright( bool b );
  349. void setLODMetric( float metric );
  350. void setPolycount( int polycount );
  351. void setModelInfo( int nVertCount, int nIndexCount, int nTriCount );
  352. void setTransparent( bool isTransparent );
  353. void updatePoseParameters( void );
  354. void setFOV( float fov );
  355. void setPlaySounds( bool b );
  356. void setShowOriginAxis( bool b );
  357. void setOriginAxisLength( float originAxisLength );
  358. void initSequenceChoices();
  359. void setSequence( int index );
  360. void showActivityModifiers( int sequence );
  361. void updateGroundSpeed( void );
  362. void setOverlaySequence(int num, int index, float weight);
  363. void updateTransitionAmount();
  364. void startBlending( void );
  365. void setSpeedScale ( float scale );
  366. void updateSpeedScale( void );
  367. void setBlend(int index, float value );
  368. int getFrameSelection( void );
  369. void setFrame( float frame );
  370. void updateFrameSelection( void );
  371. void updateFrameSlider( void );
  372. void initBodypartChoices();
  373. void setBodypart (int index);
  374. void setSubmodel (int index);
  375. void initBoneControllers ();
  376. void setBoneController (int index);
  377. void setBoneControllerValue (int index, float value);
  378. void initSkinChoices();
  379. void initMaterialChoices();
  380. void setModelInfo ();
  381. void initPhysicsBones();
  382. void initLODs();
  383. void centerView ();
  384. void UpdateMaterialList ();
  385. void viewmodelView();
  386. void fullscreen ();
  387. void setMatSysWindow (MatSysWindow *window) { d_MatSysWindow = window; }
  388. void ConvertFlexData();
  389. void initFlexes ();
  390. void connectFlexes( CStudioHdr* hdr );
  391. int GetCurrentHitboxSet( void );
  392. void BuildIKRuleQCString();
  393. void UpdateIKRuleWindow();
  394. void BuildEventQCString();
  395. void CreateSortedSequenceList( CStudioHdr* hdr, int *pSequence );
  396. void SetFrameSlider( float flFrame );
  397. void UnloadAllMergedModels();
  398. public:
  399. // Sets up the main tabs
  400. void SetupRenderWindow( mxTab* pTab );
  401. void SetupSequenceWindow( mxTab* pTab );
  402. void SetupBoneControlWindow( mxTab* pTab );
  403. void SetupBodyWindow( mxTab* pTab );
  404. void SetupFlexWindow( mxTab* pTab );
  405. void SetupPhysicsWindow( mxTab* pTab );
  406. void SetupAttachmentsWindow( mxTab *pTab );
  407. void SetupIKRuleWindow( mxTab *pTab );
  408. void SetupEventWindow( mxTab *pTab );
  409. bool m_bVMTInfoLoaded;
  410. };
  411. extern ControlPanel *g_ControlPanel;
  412. #endif // INCLUDED_CONTROLPANEL