ScummVM API documentation
te_camera.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#ifndef TETRAEDGE_TE_TE_CAMERA_H
23#define TETRAEDGE_TE_TE_CAMERA_H
24
25#include "common/path.h"
26#include "common/str.h"
27#include "math/ray.h"
28
29#include "tetraedge/te/te_3d_object2.h"
30#include "tetraedge/te/te_matrix4x4.h"
31#include "tetraedge/te/te_references_counter.h"
32#include "tetraedge/te/te_vector2s32.h"
33#include "tetraedge/te/te_vector2f32.h"
34#include "tetraedge/te/te_vector3f32.h"
35
36namespace Tetraedge {
37
39public:
40 TeCamera();
41
42 void apply();
43 void applyProjection();
44 void applyTransformations();
45 void buildOrthoMatrix();
46 void buildPerspectiveMatrix();
47 void buildPerspectiveMatrix2();
48 void buildPerspectiveMatrix3();
49 void draw() override;
50
51 Math::Ray getRay(const TeVector2s32 &pxloc);
52
53 // Syberia 2 redefines loadBin to actually load XML.
54 // We just have a separate function.
55 void loadXml(const Common::Path &path);
56
57 void orthogonalParams(float f1, float f2, float f3, float f4);
58 TeMatrix4x4 projectionMatrix();
59
60 TeVector2f32 projectPoint(const TeVector3f32 &pt);
61 TeVector3f32 projectPoint3f32(const TeVector3f32 &pt);
62
63 static void restore();
64 TeMatrix4x4 transformationMatrix();
65 TeVector3f32 transformCoord(const TeVector3f32 &pt);
66 TeVector3f32 transformPoint2Dto3D(const TeVector3f32 &pt);
67
68 void viewport(int x, int y, uint width, uint height);
69 TeVector2f32 viewportSize() const { return TeVector2f32(_viewportW, _viewportH); }
70
71 TeSignal0Param &onViewportChangedSignal() { return _onViewportChangedSignal; }
72
73 void setFov(float fov) { _fov = fov; }
74 void setOrthoPlanes(float near, float far) {
75 _orthFarVal = far;
76 _orthNearVal = near;
77 }
78 void setProjMatrixType(int matrixType) { _projectionMatrixType = matrixType; }
79 int projMatrixType() const { return _projectionMatrixType; }
80 void setAspectRatio(float val) { _aspectRatio = val; }
81 float orthoNearPlane() const { return _orthNearVal; }
82 float orthoFarPlane() const { return _orthFarVal; }
83 void setOrthoNear(float f) { _orthNearVal = f; }
84 void setOrthoFar(float f) { _orthFarVal = f; }
85 float getViewportHeight() const { return _viewportH; }
86 float getViewportWidth() const { return _viewportW; }
87
88private:
89 void updateProjectionMatrix();
90
91 int _projectionMatrixType; // TODO: Should be an enum.
92 float _orthNearVal;
93 float _orthFarVal;
94 float _fov;
95 float _aspectRatio;
96
97 int _viewportX;
98 int _viewportY;
99 uint _viewportW;
100 uint _viewportH;
101
102 int _transformA;
103
104 float _orthogonalParamL;
105 float _orthogonalParamR;
106 float _orthogonalParamT;
107 float _orthogonalParamB;
108
109 TeMatrix4x4 _projectionMatrix;
110
111 TeSignal0Param _onViewportChangedSignal;
112};
113
114} // end namespace Tetraedge
115
116#endif // TETRAEDGE_TE_TE_CAMERA_H
Definition: path.h:52
Definition: te_3d_object2.h:36
Definition: te_camera.h:38
Definition: te_matrix4x4.h:37
Definition: te_references_counter.h:27
Definition: te_signal.h:40
Definition: te_vector2f32.h:32
Definition: te_vector2s32.h:31
Definition: te_vector3f32.h:33