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.

132 lines
3.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CAMERA3D_H
  8. #define CAMERA3D_H
  9. #pragma once
  10. #include "Tool3D.h"
  11. #include "ToolInterface.h"
  12. #include "utlvector.h"
  13. #pragma warning(push, 1)
  14. #pragma warning(disable:4701 4702 4530)
  15. #include <fstream>
  16. #pragma warning(pop)
  17. class CChunkFile;
  18. class CSaveInfo;
  19. enum ChunkFileResult_t;
  20. //
  21. // Defines a camera position/look pair.
  22. //
  23. struct CAMSTRUCT
  24. {
  25. // index 0 = camera origin, 1 = pos look to
  26. Vector position[2];
  27. };
  28. class Camera3D : public Tool3D
  29. {
  30. public:
  31. Camera3D(void);
  32. enum SNCTYPE
  33. {
  34. sncNext = -1,
  35. sncFirst = 0,
  36. sncPrev = 1
  37. };
  38. int GetActiveCamera(void) { return m_iActiveCamera; }
  39. void GetCameraPos(Vector &vViewPos, Vector &vLookAt);
  40. void UpdateActiveCamera(Vector &vViewPos, Vector &vLookAt);
  41. //
  42. // Serialization.
  43. //
  44. const char *GetVMFChunkName() { return "cameras"; }
  45. ChunkFileResult_t LoadVMF(CChunkFile *pFile);
  46. ChunkFileResult_t SaveVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo);
  47. void SerializeRMF(std::fstream &file, BOOL fIsStoring);
  48. //
  49. // Tool3D implementation.
  50. //
  51. virtual bool IsEmpty(void);
  52. virtual void SetEmpty(void);
  53. virtual unsigned int GetConstraints(unsigned int nKeyFlags);
  54. //
  55. // CBaseTool implementation.
  56. //
  57. virtual ToolID_t GetToolID(void) { return TOOL_CAMERA; }
  58. virtual bool OnKeyDown2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  59. virtual bool OnLMouseDown2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  60. virtual bool OnLMouseUp2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  61. virtual bool OnMouseMove2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  62. virtual bool OnLMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  63. virtual bool OnLMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  64. virtual bool OnRMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  65. virtual bool OnRMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  66. virtual bool OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  67. virtual void RenderTool2D(CRender2D *pRender);
  68. protected:
  69. //
  70. // Tool3D implementation.
  71. //
  72. virtual int HitTest(CMapView *pView, const Vector2D &vPoint, bool bTestHandles = false);
  73. virtual bool UpdateTranslation(const Vector &vUpdate, UINT flags = 0);
  74. virtual void FinishTranslation(bool bSave);
  75. private:
  76. int GetCameraCount() { return Cameras.Count(); }
  77. void AddCamera(CAMSTRUCT &pCamPos);
  78. void SetNextCamera(SNCTYPE next);
  79. void DeleteActiveCamera(void);
  80. void OnEscape(void);
  81. void EnsureMaxCameras();
  82. static ChunkFileResult_t LoadCameraKeyCallback(const char *szKey, const char *szValue, CAMSTRUCT *pCam);
  83. static ChunkFileResult_t LoadCamerasKeyCallback(const char *szKey, const char *szValue, Camera3D *pCameras);
  84. static ChunkFileResult_t LoadCameraCallback(CChunkFile *pFile, Camera3D *pCameras);
  85. CUtlVector<CAMSTRUCT> Cameras; // The cameras that have been created.
  86. CAMSTRUCT m_MoveCamera;
  87. enum
  88. {
  89. MovePos = 0,
  90. MoveLook = 1,
  91. };
  92. int m_iActiveCamera;
  93. int m_nMovePositionIndex;
  94. Vector m_vOrgPos;
  95. };
  96. #endif // CAMERA3D_H