SuperTuxKart
Loading...
Searching...
No Matches
shadow_matrices.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2014-2015 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19#ifndef HEADER_SHADOW_MATRICES_HPP
20#define HEADER_SHADOW_MATRICES_HPP
21
22#include "graphics/gl_headers.hpp"
23
24#include <matrix4.h>
25#include <tuple>
26#include <vector>
27#include <vector3d.h>
28
29namespace irr
30{
31 namespace scene { class ICameraSceneNode; }
32}
33
34using namespace irr;
35
36class FrameBuffer;
37class PostProcessing;
38
40{
41public:
42 static float m_shadow_split[5];
43
44private:
45 std::vector<core::matrix4> m_sun_ortho_matrices;
46 scene::ICameraSceneNode *m_sun_cam;
47 scene::ICameraSceneNode *m_shadow_cam_nodes[4];
48 std::pair<float, float> m_shadow_scales[4];
49 core::matrix4 m_rsm_matrix;
50 bool m_rsm_matrix_initialized;
51 float m_shadows_cam[4][24];
52 bool m_rsm_map_available;
53 float m_mat_ubo[16 * 9 + 2];
54
55 core::matrix4 getTighestFitOrthoProj(const core::matrix4 &transform,
56 const std::vector<core::vector3df> &pointsInside,
57 std::pair<float, float> &size);
58 void renderWireFrameFrustrum(float *tmp, unsigned i);
59public:
60
63
64 void computeMatrixesAndCameras(scene::ICameraSceneNode *const camnode,
65 unsigned int width, unsigned int height);
66 void addLight(const core::vector3df &pos);
67 void updateSunOrthoMatrices();
68 void renderShadowsDebug(const FrameBuffer* shadow_framebuffer,
69 const PostProcessing *post_processing);
70
71 // ------------------------------------------------------------------------
72 void resetShadowCamNodes();
73 // ------------------------------------------------------------------------
74 scene::ICameraSceneNode** getShadowCamNodes()
75 {
76 return m_shadow_cam_nodes;
77 } // getShadowCamNodes
78 // ------------------------------------------------------------------------
79 scene::ICameraSceneNode* getSunCam() { return m_sun_cam; }
80 // ------------------------------------------------------------------------
81 std::vector<core::matrix4>& getSunOrthoMatrices()
82 {
83 return m_sun_ortho_matrices;
84 }
85 // ------------------------------------------------------------------------
86 const std::pair<float, float>* getShadowScales() const
87 {
88 return m_shadow_scales;
89 }
90 // ------------------------------------------------------------------------
91 const float* getMatricesData() const { return m_mat_ubo; }
92
93}; // class ShadowMatrices
94
95#endif
Definition: frame_buffer.hpp:33
Handles post processing, eg motion blur.
Definition: post_processing.hpp:42
Definition: shadow_matrices.hpp:40
core::matrix4 getTighestFitOrthoProj(const core::matrix4 &transform, const std::vector< core::vector3df > &pointsInside, std::pair< float, float > &size)
Given a matrix transform and a set of points returns an orthogonal projection matrix that maps coordi...
Definition: shadow_matrices.cpp:147
void computeMatrixesAndCameras(scene::ICameraSceneNode *const camnode, unsigned int width, unsigned int height)
Generate View, Projection, Inverse View, Inverse Projection, ViewProjection and InverseProjection mat...
Definition: shadow_matrices.cpp:196