Pioneer
Loading...
Searching...
No Matches
Frustum.h
Go to the documentation of this file.
1// Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef _FRUSTUM_H
5#define _FRUSTUM_H
6
7#include "Plane.h"
8#include "libs.h"
9#include "vector3.h"
10
11namespace Graphics {
12
13 // Frustum can be used for projecting points (3D to 2D) and testing
14 // if a point lies inside the visible area
15 // Its' internal projection matrix should, but does not have to, match
16 // the one used for rendering
17 class Frustum {
18 public:
19 // create for specified values
20 Frustum(float width, float height, float fovAng, float nearClip, float farClip);
21 Frustum(const matrix4x4d &modelview, const matrix4x4d &projection);
22
23 // test if point (sphere) is in the frustum
24 bool TestPoint(const vector3d &p, double radius) const;
25 // test if point (sphere) is in the frustum, ignoring the far plane
26 bool TestPointInfinite(const vector3d &p, double radius) const;
27
28 // project a point onto the near plane (typically the screen)
29 bool ProjectPoint(const vector3d &in, vector3d &out) const;
30
31 // translate the given point outside the frustum to a point inside
32 // returns scale factor to make object at that point appear correctly
33 void TranslatePoint(const vector3d &in, vector3d &out) const;
34
35 private:
36 // create from current gl state
37 Frustum();
38
39 void InitFromMatrix(const matrix4x4d &m);
40
41 matrix4x4d m_projMatrix;
42 matrix4x4d m_modelMatrix;
43 SPlane m_planes[6];
44 double m_translateThresholdSqr;
45 };
46
47} // namespace Graphics
48
49#endif
Definition Frustum.h:17
bool TestPoint(const vector3d &p, double radius) const
Definition Frustum.cpp:78
bool TestPointInfinite(const vector3d &p, double radius) const
Definition Frustum.cpp:86
bool ProjectPoint(const vector3d &in, vector3d &out) const
Definition Frustum.cpp:96
void TranslatePoint(const vector3d &in, vector3d &out) const
Definition Frustum.cpp:130
Definition Background.h:14
Definition Plane.h:13