Rigs of Rods 2023.09
Soft-body Physics Simulation
Loading...
Searching...
No Matches
GodRaysManager.h
Go to the documentation of this file.
1/*
2--------------------------------------------------------------------------------
3This source file is part of Hydrax.
4Visit ---
5
6Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
7 <xavyiy@gmail.com>
8
9This program is free software; you can redistribute it and/or modify it under
10the terms of the GNU Lesser General Public License as published by the Free Software
11Foundation; either version 2 of the License, or (at your option) any later
12version.
13
14This program is distributed in the hope that it will be useful, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public License along with
19this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21http://www.gnu.org/copyleft/lesser.txt.
22--------------------------------------------------------------------------------
23*/
24
25#ifndef _Hydrax_GodRaysManager_H_
26#define _Hydrax_GodRaysManager_H_
27
28#include "Prerequisites.h"
29#include "Perlin.h"
30
31#include "Enums.h"
32
35
38
39namespace Hydrax
40{
41 class Hydrax;
42
47 {
48 public:
52 {
53 // Material used for god rays
55 // Used for depth mat(for objects intersections)
56 MAT_DEPTH = 1
57 };
58
63
67
71 void create(const HydraxComponent& HC);
72
75 void remove();
76
80 void update(const Ogre::Real& timeSinceLastFrame);
81
85 inline const bool& isCreated() const
86 {
87 return mCreated;
88 }
89
99 void addDepthTechnique(Ogre::Technique *Technique, const bool& AutoUpdate = true);
100
104 inline void SetSimulationSpeed(const Ogre::Real& Speed)
105 {
106 mSimulationSpeed = Speed;
107 }
108
112 inline const Ogre::Real& getSimulationSpeed() const
113 {
114 return mSimulationSpeed;
115 }
116
120 void setNumberOfRays(const int& NumberOfRays);
121
125 inline const int& getNumberOfRays() const
126 {
127 return mNumberOfRays;
128 }
129
133 inline void setRaysSize(const Ogre::Real& Size)
134 {
135 mRaysSize = Size;
136 }
137
141 inline const Ogre::Real& getRaysSize() const
142 {
143 return mRaysSize;
144 }
145
150 {
151 return mPerlin;
152 }
153
157 inline Ogre::SceneNode* getSceneNode()
158 {
159 return mProjectorSN;
160 }
161
165 inline void setVisible(const bool& Visible)
166 {
167 if (mCreated)
168 {
169 mManualGodRays->setVisible(Visible);
170 }
171 }
172
176 inline const bool isVisible() const
177 {
178 if (!mCreated)
179 {
180 return false;
181 }
182
183 return mManualGodRays->isVisible();
184 }
185
189 void setObjectIntersectionsEnabled(const bool& Enable);
190
194 inline const bool& areObjectsIntersectionsEnabled() const
195 {
197 }
198
206 inline const Ogre::Vector4 getNoiseParameters() const
207 {
208 return Ogre::Vector4(mNoiseDerivation,
212 }
213
220 inline void setNoiseParameters(Ogre::Vector4 Params)
221 {
222 mNoiseDerivation = Params.x;
223 mNoisePositionMultiplier = Params.y;
224 mNoiseYNormalMultiplier = Params.z;
225 mNoiseNormalMultiplier = Params.w;
226 }
227
228 private:
231 class DepthMapListener : public Ogre::RenderTargetListener
232 {
233 public:
236
238 std::queue<std::string> mMaterials;
239
244 void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
245
250 void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
251 };
252
257 Ogre::Vector2 _calculateRayPosition(const int& RayNumber);
258
261 void _createGodRays();
262
266 void _createMaterials(const HydraxComponent& HC);
267
270 void _updateRays();
271
275
278 void _updateProjector();
279
282 void _createDepthRTT();
283
289 bool _isComponent(const HydraxComponent &List, const HydraxComponent &ToCheck) const;
290
293
295 Ogre::ManualObject* mManualGodRays;
297 Ogre::Camera *mProjectorCamera;
299 Ogre::SceneNode *mProjectorSN;
300
303
314
317 Ogre::MaterialPtr mMaterials[2];
319 std::vector<Ogre::Technique*> mDepthTechniques;
320
326 Ogre::Real mRaysSize;
329
332 Ogre::TexturePtr mProjectorRTT;
335
338 };
339};
340
343
344#endif
GodRaysManager::DepthMapListener class.
void postRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)
Funtion that is called after the Rtt will render.
std::queue< std::string > mMaterials
std::string to store entity's original materials name
void preRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)
Funtion that is called before the Rtt will render.
GodRaysManager * mGodRaysManager
God rays manager pointer.
Underwater god rays manager class God rays.
void setVisible(const bool &Visible)
Set visible.
bool mObjectsIntersections
Are god rays objects intersections active?
const bool & areObjectsIntersectionsEnabled() const
Are rays objects intersections enabled?
Ogre::ManualObject * mManualGodRays
Manual object to create god rays.
Noise::Perlin * getPerlin()
Get perlin noise module.
void setObjectIntersectionsEnabled(const bool &Enable)
Set objects intersections enabled.
void SetSimulationSpeed(const Ogre::Real &Speed)
Set god rays simulation speed.
bool mCreated
Has been create() already called?
Ogre::Vector2 _calculateRayPosition(const int &RayNumber)
Calculate the current position of a ray.
void _updateRays()
Update god rays.
void _updateProjector()
Update projector.
void _updateMaterialsParameters()
Update materials parameters.
const Ogre::Real & getSimulationSpeed() const
Get god rays simulation speed.
Ogre::MaterialPtr mMaterials[2]
God rays materials 0-God rays, 1-Depth.
Ogre::Real mRaysSize
God rays size.
bool _isComponent(const HydraxComponent &List, const HydraxComponent &ToCheck) const
Is component in the given list?
void setNoiseParameters(Ogre::Vector4 Params)
Set noise params.
Noise::Perlin * mPerlin
Our Perlin noise module.
Ogre::SceneNode * mProjectorSN
Projector scene node.
DepthMapListener mDepthMapListener
Depth RTT listener.
Ogre::Real mSimulationSpeed
God rays simulation speed.
MaterialType
God rays material enumeration.
const int & getNumberOfRays() const
Get number of god rays.
void update(const Ogre::Real &timeSinceLastFrame)
Call each frame.
Ogre::Real mNoiseDerivation
Noise parameters (Used in _calculateRayPosition(...))
void setRaysSize(const Ogre::Real &Size)
Set god rays size.
Ogre::Real mNoiseNormalMultiplier
Normal multiplier.
const Ogre::Real & getRaysSize() const
Get god rays size.
Ogre::TexturePtr mProjectorRTT
For rays intersection with objects we use a depth map based technique Depth RTT texture.
Ogre::Real mNoisePositionMultiplier
PositionMultiplier value.
Ogre::Real mNoiseYNormalMultiplier
Y normal component multiplier.
const bool isVisible() const
Is visible?
void _createGodRays()
Create god rays manual object.
std::vector< Ogre::Technique * > mDepthTechniques
Technique vector for addDepthTechnique(...)
void addDepthTechnique(Ogre::Technique *Technique, const bool &AutoUpdate=true)
Add god rays depth technique to an especified material.
Ogre::SceneNode * getSceneNode()
Get good rays scene node.
Hydrax * mHydrax
Hydrax parent pointer.
Ogre::Camera * mProjectorCamera
Camera used to project rays.
void create(const HydraxComponent &HC)
Create.
void _createMaterials(const HydraxComponent &HC)
Create materials that we need(God rays depth too if it's needed)
const Ogre::Vector4 getNoiseParameters() const
Get noise params.
void _createDepthRTT()
Create depth RTT.
void setNumberOfRays(const int &NumberOfRays)
Set the number of god rays.
int mNumberOfRays
Number of rays.
const bool & isCreated() const
Has been create() already called?
Perlin noise module class.
Definition Perlin.h:74
HydraxComponent
Hydrax flags to select components wich we want to use.
Definition Enums.h:58
Struct wich contains an especific width and height value.
Definition Help.h:41