ScummVM API documentation
Camera3D.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * Copyright (C) 2006-2010 - Frictional Games
24 *
25 * This file is part of HPL1 Engine.
26 */
27
28#ifndef HPL_CAMERA3D_H
29#define HPL_CAMERA3D_H
30
31#include "hpl1/engine/math/Frustum.h"
32#include "hpl1/engine/math/MathTypes.h"
33#include "hpl1/engine/scene/Camera.h"
34#include "hpl1/engine/scene/Node3D.h"
35
36namespace hpl {
37
38enum eCameraMoveMode {
39 eCameraMoveMode_Walk,
40 eCameraMoveMode_Fly,
41 eCameraMoveMode_LastEnum
42};
43
44enum eCameraRotateMode {
45 eCameraRotateMode_EulerAngles,
46 eCameraRotateMode_Matrix,
47 eCameraRotateMode_LastEnum
48};
49
50class iLowLevelGraphics;
51class iEntity3D;
52
53class cCamera3D : public iCamera {
54public:
55 cCamera3D();
56 virtual ~cCamera3D();
57
58 const cVector3f &GetPosition() const { return mvPosition; }
59 void SetPosition(const cVector3f &avPos);
60
65 void MoveForward(float afDist);
70 void MoveRight(float afDist);
75 void MoveUp(float afDist);
76
77 void SetFOV(float afAngle) {
78 mfFOV = afAngle;
79 mbProjectionUpdated = true;
80 }
81 float GetFOV() { return mfFOV; }
82
83 void SetAspect(float afAngle) {
84 mfAspect = afAngle;
85 mbProjectionUpdated = true;
86 }
87 float GetAspect() { return mfAspect; }
88
89 void SetFarClipPlane(float afX) {
90 mfFarClipPlane = afX;
91 mbProjectionUpdated = true;
92 }
93 float GetFarClipPlane() { return mfFarClipPlane; }
94
95 void SetNearClipPlane(float afX) {
96 mfNearClipPlane = afX;
97 mbProjectionUpdated = true;
98 }
99 float GetNearClipPlane() { return mfNearClipPlane; }
100
106 void SetInifintiveFarPlane(bool abX) {
107 mbInfFarPlane = abX;
108 mbProjectionUpdated = true;
109 }
110 bool GetInifintiveFarPlane() { return mbInfFarPlane; }
111
112 cFrustum *GetFrustum();
113
114 eCameraRotateMode GetRotateMode() { return mRotateMode; }
115
116 eCameraMoveMode GetMoveMode() { return mMoveMode; }
122 void SetRotateMode(eCameraRotateMode aMode);
128 void SetMoveMode(eCameraMoveMode aMode);
129
134
138 cVector3f UnProject(const cVector2f &avScreenPos, iLowLevelGraphics *apLowLevel);
139
140 void AttachEntity(iEntity3D *apEntity);
141 void RemoveEntity(iEntity3D *apEntity);
142 cNode3D *GetAttachmentNode() { return &mNode; }
143 void ClearAttachedEntities();
144
148
149 void SetPitch(float afAngle);
150 void SetYaw(float afAngle);
151 void SetRoll(float afAngle);
152
153 void AddPitch(float afAngle);
154 void AddYaw(float afAngle);
155 void AddRoll(float afAngle);
156
157 float GetPitch() const { return mfPitch; }
158 float GetYaw() const { return mfYaw; }
159 float GetRoll() const { return mfRoll; }
160
165 void SetPitchLimits(cVector2f avLimits) { mvPitchLimits = avLimits; }
166 const cVector2f &GetPitchLimits() { return mvPitchLimits; }
171 void SetYawLimits(cVector2f avLimits) { mvYawLimits = avLimits; }
172 const cVector2f &GetYawLimits() { return mvYawLimits; }
173
177
178 const cMatrixf &GetViewMatrix();
179 const cMatrixf &GetProjectionMatrix();
180
181 const cMatrixf &GetMoveMatrix();
182
183 // iCamera stuff:
184 void SetModelViewMatrix(iLowLevelGraphics *apLowLevel);
185 void SetProjectionMatrix(iLowLevelGraphics *apLowLevel);
186 cVector3f GetEyePosition();
187
188 eCameraType GetType() { return eCameraType_3D; }
189
190 cVector3f GetForward();
191 cVector3f GetRight();
192 cVector3f GetUp();
193
197
198 void SetPrevView(const cMatrixf &a_mtxA) { m_mtxPrevView = a_mtxA; }
199 void SetPrevProjection(const cMatrixf &a_mtxA) { m_mtxPrevProjection = a_mtxA; }
200
201 cMatrixf &GetPrevView() { return m_mtxPrevView; }
202 cMatrixf &GetPrevProjection() { return m_mtxPrevProjection; }
203
204private:
205 void UpdateMoveMatrix();
206
207 cVector3f mvPosition;
208
209 float mfFOV;
210 float mfAspect;
211 float mfFarClipPlane;
212 float mfNearClipPlane;
213
214 float mfPitch;
215 float mfYaw;
216 float mfRoll;
217 cVector2f mvPitchLimits;
218 cVector2f mvYawLimits;
219
220 eCameraRotateMode mRotateMode;
221 eCameraMoveMode mMoveMode;
222
223 cMatrixf m_mtxView;
224 cMatrixf m_mtxProjection;
225 cMatrixf m_mtxMove;
226
227 cMatrixf m_mtxPrevView;
228 cMatrixf m_mtxPrevProjection;
229
230 cNode3D mNode;
231
232 cFrustum mFrustum;
233
234 bool mbInfFarPlane;
235
236 bool mbViewUpdated;
237 bool mbProjectionUpdated;
238 bool mbMoveUpdated;
239};
240
241} // namespace hpl
242
243#endif // HPL_CAMERA3D_H
Definition: Camera3D.h:53
void SetPitchLimits(cVector2f avLimits)
Definition: Camera3D.h:165
void SetYawLimits(cVector2f avLimits)
Definition: Camera3D.h:171
cVector3f UnProject(const cVector2f &avScreenPos, iLowLevelGraphics *apLowLevel)
void MoveForward(float afDist)
void ResetRotation()
void SetMoveMode(eCameraMoveMode aMode)
void MoveRight(float afDist)
void SetInifintiveFarPlane(bool abX)
Definition: Camera3D.h:106
void MoveUp(float afDist)
void SetRotateMode(eCameraRotateMode aMode)
Definition: Node3D.h:52
Definition: Camera.h:43
Definition: Entity3D.h:81
Definition: LowLevelGraphics.h:200