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