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.

200 lines
5.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef MORPH3D_H
  8. #define MORPH3D_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "MapClass.h" // dvs: For CMapObjectList
  13. #include "Box3D.h"
  14. #include "SSolid.h"
  15. #include "Resource.h"
  16. #include "ScaleVerticesDlg.h"
  17. #include "ToolInterface.h"
  18. #include "mathlib/vector.h"
  19. class IMesh;
  20. class Morph3D;
  21. class CRender2D;
  22. class CRender3D;
  23. const SSHANDLE SSH_SCALEORIGIN = 0xffff0L;
  24. typedef struct
  25. {
  26. CMapSolid *pMapSolid;
  27. CSSolid *pStrucSolid;
  28. SSHANDLE ssh;
  29. } MORPHHANDLE;
  30. class Morph3D : public Box3D
  31. {
  32. public:
  33. Morph3D();
  34. virtual ~Morph3D();
  35. BOOL IsMorphing(CMapSolid *pSolid, CSSolid **pStrucSolidRvl = NULL);
  36. bool SplitFace();
  37. bool CanSplitFace();
  38. void SelectHandle(MORPHHANDLE *pInfo, UINT cmd = scSelect);
  39. void SelectHandle2D( CMapView2D *pView, MORPHHANDLE *pInfo, UINT cmd = scSelect);
  40. void DeselectHandle(MORPHHANDLE *pInfo);
  41. void MoveSelectedHandles(const Vector &Delta);
  42. int GetSelectedHandleCount(void) { return m_SelectedHandles.Count(); }
  43. void GetSelectedCenter(Vector& pt);
  44. SSHANDLETYPE GetSelectedType() { return m_SelectedType; }
  45. bool IsSelected(MORPHHANDLE &mh);
  46. void SelectObject(CMapSolid *pSolid, UINT cmd = scSelect);
  47. bool SelectAt( CMapView *pView, UINT nFlags, const Vector2D &vPoint );
  48. void GetMorphBounds(Vector &mins, Vector &maxs, bool bReset);
  49. // Toggle mode - vertex & edge, vertex, edge.
  50. void ToggleMode();
  51. void OnScaleCmd(BOOL bReInit = FALSE);
  52. void UpdateScale();
  53. BOOL IsScaling() { return m_bScaling; }
  54. void GetMorphingObjects(CUtlVector<CMapClass *> &List);
  55. inline int GetObjectCount(void);
  56. inline CSSolid *GetObject(int pos);
  57. //
  58. // Tool3D implementation.
  59. //
  60. virtual bool IsEmpty() { return !m_StrucSolids.Count() && !m_bBoxSelecting; }
  61. virtual void SetEmpty();
  62. virtual void FinishTranslation(bool bSave);
  63. virtual unsigned int GetConstraints(unsigned int nKeyFlags);
  64. //
  65. // CBaseTool implementation.
  66. //
  67. virtual void OnActivate();
  68. virtual void OnDeactivate();
  69. virtual ToolID_t GetToolID(void) { return TOOL_MORPH; }
  70. virtual bool CanDeactivate( void );
  71. virtual bool OnKeyDown2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  72. virtual bool OnChar2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  73. virtual bool OnLMouseDown2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  74. virtual bool OnLMouseUp2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  75. virtual bool OnMouseMove2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  76. virtual bool OnLMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  77. virtual bool OnLMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  78. virtual bool OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  79. virtual bool OnMouseMove3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  80. virtual void RenderTool2D(CRender2D *pRender);
  81. virtual void RenderTool3D(CRender3D *pRender);
  82. private:
  83. void OnEscape(void);
  84. bool NudgeHandles(CMapView *pView, UINT nChar, bool bSnap);
  85. bool MorphHitTest(CMapView *pView, const Vector2D &vPoint, MORPHHANDLE *pInfo);
  86. void GetHandlePos(MORPHHANDLE *pInfo, Vector& pt);
  87. SSHANDLE Get2DMatches(CMapView2D *pView, CSSolid *pStrucSolid, SSHANDLEINFO &hi, CUtlVector<SSHANDLE>*pSimilarList = NULL);
  88. void StartTranslation(CMapView *pView, const Vector2D &vPoint, MORPHHANDLE *pInfo );
  89. void RenderSolid3D(CRender3D *pRender, CSSolid *pSolid);
  90. //
  91. // Tool3D implementations.
  92. //
  93. int HitTest(CMapView *pView, const Vector2D &ptClient, bool bTestHandles = false);
  94. virtual bool UpdateTranslation( const Vector &pos, UINT uFlags );
  95. bool StartBoxSelection( CMapView *pView, const Vector2D &vPoint, const Vector &vStart);
  96. void SelectInBox();
  97. void EndBoxSelection();
  98. bool IsBoxSelecting() { return m_bBoxSelecting; }
  99. bool CanDeselectList( void );
  100. // list of active Structured Solids:
  101. CUtlVector<CSSolid*> m_StrucSolids;
  102. // list of selected nodes:
  103. CUtlVector<MORPHHANDLE> m_SelectedHandles;
  104. // type of selected handles:
  105. SSHANDLETYPE m_SelectedType;
  106. // main morph handle:
  107. MORPHHANDLE m_MorphHandle;
  108. Vector m_OrigHandlePos;
  109. // morph bounds:
  110. BoundBox m_MorphBounds;
  111. // handle mode:
  112. enum
  113. {
  114. hmBoth = 0x01 | 0x02,
  115. hmVertex = 0x01,
  116. hmEdge = 0x02
  117. };
  118. bool m_bLButtonDownControlState;
  119. Vector2D m_vLastMouseMovement;
  120. bool m_bHit;
  121. MORPHHANDLE m_DragHandle; // The morph handle that we are dragging.
  122. bool m_bMorphing;
  123. bool m_bMovingSelected; // not moving them yet - might just select this
  124. int m_HandleMode;
  125. bool m_bBoxSelecting;
  126. bool m_bScaling;
  127. bool m_bUpdateOrg;
  128. CScaleVerticesDlg m_ScaleDlg;
  129. Vector *m_pOrigPosList;
  130. Vector m_ScaleOrg;
  131. };
  132. //-----------------------------------------------------------------------------
  133. // Purpose: Returns the number of solids selected for morphing.
  134. //-----------------------------------------------------------------------------
  135. inline int Morph3D::GetObjectCount(void)
  136. {
  137. return(m_StrucSolids.Count());
  138. }
  139. //-----------------------------------------------------------------------------
  140. // Purpose: Iterates the selected solids.
  141. //-----------------------------------------------------------------------------
  142. inline CSSolid *Morph3D::GetObject(int pos)
  143. {
  144. return(m_StrucSolids.Element(pos));
  145. }
  146. #endif // MORPH3D_H