Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Hydrax.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_Hydrax_H_
26#define _Hydrax_Hydrax_H_
27
28#include "Prerequisites.h"
29#include "Application.h"
30
31#include "Enums.h"
32#include "Help.h"
33#include "Mesh.h"
34#include "Image.h"
35#include "MaterialManager.h"
36#include "RttManager.h"
37#include "TextureManager.h"
38#include "GodRaysManager.h"
39#include "DecalsManager.h"
40#include "GPUNormalMapManager.h"
41#include "CfgFileManager.h"
42#include "Module.h"
43
46
49
50namespace Hydrax
51{
56 class Hydrax
57 {
58 public:
64 Hydrax(Ogre::SceneManager *sm, Ogre::Camera *c, Ogre::Viewport *v);
65
68 ~Hydrax();
69
74 void create();
75
79 void remove();
80
84 void update(const Ogre::Real &timeSinceLastFrame);
85
89 bool isComponent(const HydraxComponent &Component);
90
95 void setComponents(const HydraxComponent &Components);
96
102 void setModule(Module::Module* Module, const bool& DeleteOldModule = true);
103
107 void setPolygonMode(const Ogre::PolygonMode& PM);
108
112 void setShaderMode(const MaterialManager::ShaderMode &ShaderMode);
113
117 void setPosition(const Ogre::Vector3 &Position);
118
122 void rotate(const Ogre::Quaternion &q);
123
130 inline const bool saveCfg(const Ogre::String &File, const Ogre::String& Path = "") const
131 {
132 return mCfgFileManager->save(File, Path);
133 }
134
142 inline const bool loadCfg(const Ogre::String &File) const
143 {
144 return mCfgFileManager->load(File);
145 }
146
150 void setPlanesError(const Ogre::Real &PlanesError);
151
155 void _setStrength(const Ogre::Real &Strength);
156
160 void setFullReflectionDistance(const Ogre::Real &FullReflectionDistance);
161
162 void setGlobalTransparency(const Ogre::Real &GlobalTransparencyDistance);
163
164 void setWaterColor(const Ogre::Vector3 &WaterColor);
165
169 void setNormalDistortion(const Ogre::Real &NormalDistortion);
170
174 void setSunPosition(const Ogre::Vector3 &SunPosition);
175
179 void setSunStrength(const Ogre::Real &SunStrength);
180
184 void setSunArea(const Ogre::Real &SunArea);
185
189 void setSunColor(const Ogre::Vector3 &SunColor);
190
194 void setFoamMaxDistance(const Ogre::Real &FoamMaxDistance);
195
199 void setFoamScale(const Ogre::Real &FoamScale);
200
204 void setFoamStart(const Ogre::Real &FoamStart);
205
209 void setFoamTransparency(const Ogre::Real &FoamTransparency);
210
214 void setDepthLimit(const Ogre::Real &DepthLimit);
215
219 void setDistLimit(const Ogre::Real &DistLimit);
220
225 void setSmoothPower(const Ogre::Real &SmoothPower);
226
230 void setCausticsScale(const Ogre::Real &CausticsScale);
231
235 void setCausticsPower(const Ogre::Real &CausticsPower);
236
240 void setCausticsEnd(const Ogre::Real &CausticsEnd);
241
245 void setGodRaysExposure(const Ogre::Vector3 &GodRaysExposure)
246 {
247 mGodRaysExposure = GodRaysExposure;
248 }
249
253 void setGodRaysIntensity(const Ogre::Real &GodRaysIntensity)
254 {
255 mGodRaysIntensity = GodRaysIntensity;
256 }
257
262 inline void setUnderwaterCameraSwitchDelta(const Ogre::Real& UnderwaterCameraSwitchDelta)
263 {
264 mUnderwaterCameraSwitchDelta = UnderwaterCameraSwitchDelta;
265 }
266
270 inline const bool& isCreated() const
271 {
272 return mCreated;
273 }
274
280 void setVisible(const bool& Visible);
281
285 inline const bool& isVisible() const
286 {
287 return mVisible;
288 }
289
293 inline Ogre::Camera* getCamera()
294 {
295 return mCamera;
296 }
297
301 inline Ogre::Viewport* getViewport()
302 {
303 return mViewport;
304 }
305
309 inline Ogre::SceneManager* getSceneManager()
310 {
311 return mSceneManager;
312 }
313
317 inline Mesh* getMesh()
318 {
319 return mMesh;
320 }
321
326 {
327 return mMaterialManager;
328 }
329
334 {
335 return mRttManager;
336 }
337
342 {
343 return mTextureManager;
344 }
345
350 {
351 return mGodRaysManager;
352 }
353
358 {
359 return mDecalsManager;
360 }
361
366 {
367 return mGPUNormalMapManager;
368 }
369
374 {
375 return mCfgFileManager;
376 }
377
382 {
383 return mModule;
384 }
385
389 inline const HydraxComponent& getComponents() const
390 {
391 return mComponents;
392 }
393
397 inline const Ogre::PolygonMode& getPolygonMode() const
398 {
399 return mPolygonMode;
400 }
401
406 {
407 return mShaderMode;
408 }
409
413 inline const Ogre::Vector3& getPosition() const
414 {
415 return mPosition;
416 }
417
421 inline const Ogre::Real& getPlanesError() const
422 {
423 return mPlanesError;
424 }
425
430 inline float getHeigth(const Ogre::Vector2 &Position)
431 {
432 if (mModule)
433 {
434 return mModule->getHeigth(Position);
435 }
436
437 return -1;
438 }
439
444 inline float getHeigth(const Ogre::Vector3 &Position)
445 {
446 return getHeigth(Ogre::Vector2(Position.x, Position.z));
447 }
448
452 inline const Ogre::Real& getFullReflectionDistance() const
453 {
454 return mFullReflectionDistance;
455 }
456
460 inline const Ogre::Real& getGlobalTransparency() const
461 {
462 return mGlobalTransparency;
463 }
464
468 inline const Ogre::Vector3& getSunPosition() const
469 {
470 return mSunPosition;
471 }
472
476 inline const Ogre::Vector3& getWaterColor() const
477 {
478 return mWaterColor;
479 }
480
484 inline const Ogre::Real& getNormalDistortion() const
485 {
486 return mNormalDistortion;
487 }
488
492 inline const Ogre::Real& getSunStrength() const
493 {
494 return mSunStrength;
495 }
496
500 inline const Ogre::Real& getSunArea() const
501 {
502 return mSunArea;
503 }
504
508 inline const Ogre::Vector3& getSunColor() const
509 {
510 return mSunColor;
511 }
512
516 inline const Ogre::Real& getFoamMaxDistance() const
517 {
518 return mFoamMaxDistance;
519 }
520
524 inline const Ogre::Real& getFoamScale() const
525 {
526 return mFoamScale;
527 }
528
532 inline const Ogre::Real& getFoamStart() const
533 {
534 return mFoamStart;
535 }
536
540 inline const Ogre::Real& getFoamTransparency() const
541 {
542 return mFoamTransparency;
543 }
544
548 inline const Ogre::Real& getDepthLimit() const
549 {
550 return mDepthLimit;
551 }
552
556 inline const Ogre::Real& getDistLimit() const
557 {
558 return mDistLimit;
559 }
560
564 inline const Ogre::Real& getSmoothPower() const
565 {
566 return mSmoothPower;
567 }
568
572 inline const Ogre::Real& getCausticsScale() const
573 {
574 return mCausticsScale;
575 }
576
580 inline const Ogre::Real& getCausticsPower() const
581 {
582 return mCausticsPower;
583 }
584
588 inline const Ogre::Real& getCausticsEnd() const
589 {
590 return mCausticsEnd;
591 }
592
596 inline const Ogre::Vector3& getGodRaysExposure() const
597 {
598 return mGodRaysExposure;
599 }
600
604 inline const Ogre::Real& getGodRaysIntensity() const
605 {
606 return mGodRaysIntensity;
607 }
608
613 inline const Ogre::Real& getUnderwaterCameraSwitchDelta() const
614 {
615 return mUnderwaterCameraSwitchDelta;
616 }
617
621 inline const bool& _isCurrentFrameUnderwater() const
622 {
623 return mCurrentFrameUnderwater;
624 }
625
626 private:
627
630 class DeviceListener : public Ogre::RenderSystem::Listener
631 {
632 public:
635
640 void eventOccurred(const Ogre::String& eventName, const Ogre::NameValuePairList *parameters);
641 };
642
645 void _updateNM();
646
649 void _checkVisible();
650
654 void _checkUnderwater(const Ogre::Real& timeSinceLastFrame);
655
658
661
666
669
671 Ogre::PolygonMode mPolygonMode;
673 Ogre::Vector3 mPosition;
675 Ogre::Real mPlanesError;
676
682 Ogre::Vector3 mWaterColor;
685
687 Ogre::Vector3 mSunPosition;
689 Ogre::Real mSunStrength;
691 Ogre::Real mSunArea;
693 Ogre::Vector3 mSunColor;
694
698 Ogre::Real mFoamScale;
700 Ogre::Real mFoamStart;
703
705 Ogre::Real mDepthLimit;
707 Ogre::Real mDistLimit;
708
710 Ogre::Real mSmoothPower;
711
713 Ogre::Real mCausticsScale;
715 Ogre::Real mCausticsPower;
717 Ogre::Real mCausticsEnd;
718
720 Ogre::Vector3 mGodRaysExposure;
723
724 // Delta-displacement in Y-AXIS before changing to underwater mode
726
729
748
750 Ogre::SceneManager *mSceneManager;
752 Ogre::Camera *mCamera;
754 Ogre::Viewport *mViewport;
755 };
756}
757
760
761#endif
Central state/object manager and communications hub.
Class to load/save all Hydrax options from/to a config file.
Decals manager class.
Class to manager GPU normal maps.
Underwater god rays manager class God rays.
Hydrax * mHydrax
Hydrax manager pointer.
Definition Hydrax.h:634
void _updateNM()
Update normal map textures.
const Ogre::Real & getGlobalTransparency() const
Get global transparency.
Definition Hydrax.h:460
Ogre::Real mFoamStart
Foam start param.
Definition Hydrax.h:700
RttManager * getRttManager()
Get Hydrax::RttManager.
Definition Hydrax.h:333
Mesh * getMesh()
Get Hydrax::Mesh.
Definition Hydrax.h:317
Ogre::Vector3 mPosition
Water position.
Definition Hydrax.h:673
const Ogre::Real & getSunArea() const
Get sun area.
Definition Hydrax.h:500
const bool loadCfg(const Ogre::String &File) const
Load config from file.
Definition Hydrax.h:142
const Ogre::Real & getFoamStart() const
Get foam start.
Definition Hydrax.h:532
Module::Module * mModule
Our Hydrax::Module::Module pointer.
Definition Hydrax.h:747
Ogre::Real mNormalDistortion
Normal distortion param.
Definition Hydrax.h:684
GodRaysManager * getGodRaysManager()
Get Hydrax::GodRaysManager.
Definition Hydrax.h:349
Ogre::Vector3 mSunPosition
Sun position.
Definition Hydrax.h:687
bool mCurrentFrameUnderwater
Is current frame underwater?
Definition Hydrax.h:728
float getHeigth(const Ogre::Vector3 &Position)
Get the current heigth at a especified world-space point.
Definition Hydrax.h:444
const Ogre::Real & getSmoothPower() const
Get smooth power.
Definition Hydrax.h:564
void setUnderwaterCameraSwitchDelta(const Ogre::Real &UnderwaterCameraSwitchDelta)
Set the y-displacement under the water needed to change between underwater and overwater mode.
Definition Hydrax.h:262
GPUNormalMapManager * mGPUNormalMapManager
Our Hydrax::GPUNormalMapManager pointer.
Definition Hydrax.h:743
bool mCreated
Has create() already called?
Definition Hydrax.h:657
const Ogre::PolygonMode & getPolygonMode() const
Get current polygon mode.
Definition Hydrax.h:397
Ogre::Real mGodRaysIntensity
God rays intensity.
Definition Hydrax.h:722
void setGodRaysExposure(const Ogre::Vector3 &GodRaysExposure)
Set god rays exposure.
Definition Hydrax.h:245
Ogre::Real mFoamScale
Foam scale param.
Definition Hydrax.h:698
const HydraxComponent & getComponents() const
Get hydrax components selected.
Definition Hydrax.h:389
Mesh * mMesh
Our Hydrax::Mesh pointer.
Definition Hydrax.h:731
const Ogre::Real & getNormalDistortion() const
Get normal distortion.
Definition Hydrax.h:484
DeviceListener mDeviceListener
Device listener.
Definition Hydrax.h:668
Ogre::Real mFullReflectionDistance
Full reflection distance param.
Definition Hydrax.h:678
const Ogre::Vector3 & getSunPosition() const
Get sun position.
Definition Hydrax.h:468
Ogre::Camera * getCamera()
Get rendering camera.
Definition Hydrax.h:293
Ogre::Real mFoamMaxDistance
Foam max distance param.
Definition Hydrax.h:696
Ogre::Camera * mCamera
Pointer to Ogre::Camera.
Definition Hydrax.h:752
const Ogre::Real & getFullReflectionDistance() const
Get full reflection distance.
Definition Hydrax.h:452
const Ogre::Real & getCausticsPower() const
Get caustics power.
Definition Hydrax.h:580
const bool saveCfg(const Ogre::String &File, const Ogre::String &Path="") const
Save hydrax config to file.
Definition Hydrax.h:130
bool mVisible
Is hydrax water visible?
Definition Hydrax.h:660
Ogre::Real mUnderwaterCameraSwitchDelta
Definition Hydrax.h:725
const Ogre::Real & getSunStrength() const
Get water strength.
Definition Hydrax.h:492
const Ogre::Vector3 & getPosition() const
Get water position.
Definition Hydrax.h:413
Ogre::Real mCausticsScale
Caustics scale param.
Definition Hydrax.h:713
const bool & isCreated() const
Has create() already called?
Definition Hydrax.h:270
const bool & isVisible() const
Is hydrax water visible?
Definition Hydrax.h:285
HydraxComponent mComponents
Hydrax components.
Definition Hydrax.h:663
const Ogre::Real & getDistLimit() const
Get distance limit (viewable underwater)
Definition Hydrax.h:556
MaterialManager::ShaderMode mShaderMode
Current shader mode.
Definition Hydrax.h:665
const Ogre::Real & getFoamScale() const
Get foam scale.
Definition Hydrax.h:524
Ogre::Real mPlanesError
Planes error, y axis clipplanes displacement.
Definition Hydrax.h:675
const Ogre::Vector3 & getWaterColor() const
Get water color.
Definition Hydrax.h:476
const Ogre::Real & getFoamTransparency() const
Get foam transparency.
Definition Hydrax.h:540
const MaterialManager::ShaderMode & getShaderMode() const
Get current shader mode.
Definition Hydrax.h:405
Ogre::Vector3 mSunColor
Sun color.
Definition Hydrax.h:693
const Ogre::Real & getPlanesError() const
Get current clip planes error.
Definition Hydrax.h:421
Ogre::Real mGlobalTransparency
Global transparency param.
Definition Hydrax.h:680
const Ogre::Vector3 & getGodRaysExposure() const
Get God rays exposure factors.
Definition Hydrax.h:596
Ogre::Real mDepthLimit
Depth limit param.
Definition Hydrax.h:705
Ogre::SceneManager * mSceneManager
Pointer to Ogre::SceneManager.
Definition Hydrax.h:750
CfgFileManager * getCfgFileManager()
Get Hydrax::CfgFileManager.
Definition Hydrax.h:373
const Ogre::Vector3 & getSunColor() const
Get sun color.
Definition Hydrax.h:508
Ogre::PolygonMode mPolygonMode
Polygon mode (Solid, Wireframe, Points)
Definition Hydrax.h:671
GodRaysManager * mGodRaysManager
Our Hydrax::GodRaysManager pointer.
Definition Hydrax.h:739
const Ogre::Real & getCausticsScale() const
Get caustics scale.
Definition Hydrax.h:572
Ogre::Real mSunStrength
Sun strength param.
Definition Hydrax.h:689
float getHeigth(const Ogre::Vector2 &Position)
Get the current heigth at a especified world-space point.
Definition Hydrax.h:430
MaterialManager * mMaterialManager
Our Hydrax::MaterialManager.
Definition Hydrax.h:733
Ogre::Vector3 mWaterColor
Water color param.
Definition Hydrax.h:682
const Ogre::Real & getGodRaysIntensity() const
Get God rays intensity.
Definition Hydrax.h:604
const Ogre::Real & getFoamMaxDistance() const
Get foam max distance.
Definition Hydrax.h:516
const Ogre::Real & getDepthLimit() const
Get depth limit.
Definition Hydrax.h:548
Ogre::Real mDistLimit
Distance limit param (viewable underwater)
Definition Hydrax.h:707
MaterialManager * getMaterialManager()
Get Hydrax::MaterialManager.
Definition Hydrax.h:325
const Ogre::Real & getCausticsEnd() const
Get caustics end.
Definition Hydrax.h:588
Ogre::Viewport * mViewport
Pointer to main window viewport.
Definition Hydrax.h:754
TextureManager * getTextureManager()
Get Hydrax::TextureManager.
Definition Hydrax.h:341
Ogre::Viewport * getViewport()
Get main window viewport.
Definition Hydrax.h:301
Ogre::Real mCausticsPower
Caustics power.
Definition Hydrax.h:715
GPUNormalMapManager * getGPUNormalMapManager()
Get Hydrax::GPUNormalMapManager.
Definition Hydrax.h:365
Module::Module * getModule()
Get our Hydrax::Module::Module.
Definition Hydrax.h:381
TextureManager * mTextureManager
Our Hydrax::TextureManager pointer.
Definition Hydrax.h:737
Ogre::Real mFoamTransparency
Foam transparency param.
Definition Hydrax.h:702
Ogre::Real mCausticsEnd
Caustics end.
Definition Hydrax.h:717
Ogre::SceneManager * getSceneManager()
Get scene manager.
Definition Hydrax.h:309
const Ogre::Real & getUnderwaterCameraSwitchDelta() const
Get the y-displacement under the water needed to change between underwater and overwater mode.
Definition Hydrax.h:613
Ogre::Real mSunArea
Sun area.
Definition Hydrax.h:691
RttManager * mRttManager
Our Hydrax::RttManager.
Definition Hydrax.h:735
DecalsManager * mDecalsManager
Our Hydrax::DecalsManager pointer.
Definition Hydrax.h:741
Ogre::Vector3 mGodRaysExposure
God rays exposure factors.
Definition Hydrax.h:720
DecalsManager * getDecalsManager()
Get Hydrax::DecalsManager.
Definition Hydrax.h:357
void setGodRaysIntensity(const Ogre::Real &GodRaysIntensity)
Set god rays intensity.
Definition Hydrax.h:253
Ogre::Real mSmoothPower
Smooth power param.
Definition Hydrax.h:710
CfgFileManager * mCfgFileManager
Our Hydrax::CfgFileManager pointer.
Definition Hydrax.h:745
const bool & _isCurrentFrameUnderwater() const
Is current frame underwater?
Definition Hydrax.h:621
Material/Shader manager class.
Class wich contains all funtions/variables related to Hydrax water mesh.
Definition Mesh.h:47
Base module class, Override it for create different ways of create water noise.
Definition Module.h:47
Rtt's manager class.
Definition RttManager.h:46
Class for manager Normal maps.
HydraxComponent
Hydrax flags to select components wich we want to use.
Definition Enums.h:58