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
Module.cpp
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#include"Module.h"
26
27namespace Hydrax{namespace Module
28{
29 Module::Module(const Ogre::String &Name,
30 Noise::Noise *n,
31 const Mesh::Options &MeshOptions,
32 const MaterialManager::NormalMode &NormalMode)
33 : mName(Name)
34 , mNoise(n)
35 , mMeshOptions(MeshOptions)
36 , mNormalMode(NormalMode)
37 , mCreated(false)
38 {
39 }
40
42 {
43 delete mNoise;
44 }
45
47 {
48 mNoise->create();
49
50 mCreated = true;
51 }
52
54 {
55 mNoise->remove();
56
57 mCreated = false;
58 }
59
60 void Module::setNoise(Noise::Noise* Noise, GPUNormalMapManager* g, const bool& DeleteOldNoise)
61 {
62 if (DeleteOldNoise)
63 {
64 delete mNoise;
65 }
66
67 mNoise = Noise;
68
69 if (mCreated)
70 {
71 if (!mNoise->isCreated())
72 {
73 mNoise->create();
74 }
75
77 {
79 {
80 HydraxLOG(mNoise->getName() + " doesn't support GPU Normal map generation");
81 }
82 }
83 else
84 {
86 }
87 }
88 else
89 {
91 }
92 }
93
94 void Module::update(const Ogre::Real &timeSinceLastFrame)
95 {
96 mNoise->update(timeSinceLastFrame);
97 }
98
99 void Module::saveCfg(Ogre::String &Data)
100 {
101 Data += "#Module options\n";
102 Data += "Module="+mName+"\n\n";
103 }
104
105 bool Module::loadCfg(Ogre::ConfigFile &CfgFile)
106 {
107 if (CfgFile.getSetting("Module") == mName)
108 {
109 HydraxLOG(mName + " options entry found.");
110 return true;
111 }
112
113 HydraxLOG("Error (Module::loadCfg):\t" + mName + " options entry can not be found.");
114 return false;
115 }
116
117 float Module::getHeigth(const Ogre::Vector2 &Position)
118 {
119 return -1;
120 }
121}}
#define HydraxLOG(msg)
Definition Application.h:60
Class to manager GPU normal maps.
NormalMode
Normal generation mode.
Base module class, Override it for create different ways of create water noise.
Definition Module.h:47
virtual ~Module()
Destructor.
Definition Module.cpp:41
virtual void update(const Ogre::Real &timeSinceLastFrame)
Call it each frame.
Definition Module.cpp:94
virtual void remove()
Remove.
Definition Module.cpp:53
bool mCreated
Is create() called?
Definition Module.h:162
virtual void create()
Create.
Definition Module.cpp:46
Noise::Noise * mNoise
Noise generator pointer.
Definition Module.h:156
virtual void saveCfg(Ogre::String &Data)
Save config.
Definition Module.cpp:99
Ogre::String mName
Module name.
Definition Module.h:154
const MaterialManager::NormalMode & getNormalMode() const
Get the normal generation mode.
Definition Module.h:125
virtual bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
Definition Module.cpp:105
virtual float getHeigth(const Ogre::Vector2 &Position)
Get the current heigth at a especified world-space point.
Definition Module.cpp:117
void setNoise(Noise::Noise *Noise, GPUNormalMapManager *g=0, const bool &DeleteOldNoise=true)
Set noise.
Definition Module.cpp:60
Base noise class, Override it for create different ways of create water noise.
Definition Noise.h:43
virtual void remove()
Remove.
Definition Noise.cpp:47
const Ogre::String & getName() const
Get noise name.
Definition Noise.h:92
virtual bool createGPUNormalMapResources(GPUNormalMapManager *g)
Create GPUNormalMap resources.
Definition Noise.cpp:52
virtual void update(const Ogre::Real &timeSinceLastFrame)=0
Call it each frame.
virtual void removeGPUNormalMapResources(GPUNormalMapManager *g)
Remove GPUNormalMap resources.
Definition Noise.cpp:71
virtual void create()
Create.
Definition Noise.cpp:42
const bool & isCreated() const
Is created() called?
Definition Noise.h:100
Base Hydrax mesh options.
Definition Mesh.h:94