RigsofRods
Soft-body Physics Simulation
Module.cpp
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of Hydrax.
4 Visit ---
5 
6 Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
7  <xavyiy@gmail.com>
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
12 version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along with
19 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21 http://www.gnu.org/copyleft/lesser.txt.
22 --------------------------------------------------------------------------------
23 */
24 
25 #include"Module.h"
26 
27 namespace 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 
41  Module::~Module()
42  {
43  delete mNoise;
44  }
45 
46  void Module::create()
47  {
48  mNoise->create();
49 
50  mCreated = true;
51  }
52 
53  void Module::remove()
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 }}
Hydrax::Noise::Noise::remove
virtual void remove()
Remove.
Definition: Noise.cpp:47
Hydrax::Noise::Noise::createGPUNormalMapResources
virtual bool createGPUNormalMapResources(GPUNormalMapManager *g)
Create GPUNormalMap resources.
Definition: Noise.cpp:52
Hydrax::Noise::Noise::create
virtual void create()
Create.
Definition: Noise.cpp:42
Hydrax
Definition: CfgFileManager.cpp:28
Hydrax::Noise::Noise::removeGPUNormalMapResources
virtual void removeGPUNormalMapResources(GPUNormalMapManager *g)
Remove GPUNormalMap resources.
Definition: Noise.cpp:71
Hydrax::Mesh::Options
Base Hydrax mesh options.
Definition: Mesh.h:93
Hydrax::GPUNormalMapManager
Class to manager GPU normal maps.
Definition: GPUNormalMapManager.h:45
Hydrax::Noise::Noise::getName
const Ogre::String & getName() const
Get noise name.
Definition: Noise.h:92
Hydrax::Noise::Noise
Base noise class, Override it for create different ways of create water noise.
Definition: Noise.h:42
Hydrax::MaterialManager::NormalMode
NormalMode
Normal generation mode.
Definition: MaterialManager.h:100
HydraxLOG
#define HydraxLOG(msg)
Definition: Application.h:59
Hydrax::Module::Module
Base module class, Override it for create different ways of create water noise.
Definition: Module.h:46
Hydrax::Module::Module::mCreated
bool mCreated
Is create() called?
Definition: Module.h:162
Hydrax::MaterialManager::NM_RTT
@ NM_RTT
Definition: MaterialManager.h:107
Hydrax::Noise::Noise::update
virtual void update(const Ogre::Real &timeSinceLastFrame)=0
Call it each frame.
Hydrax::Module::Module::mName
Ogre::String mName
Module name.
Definition: Module.h:154
Hydrax::Module::Module::getNormalMode
const MaterialManager::NormalMode & getNormalMode() const
Get the normal generation mode.
Definition: Module.h:125
Hydrax::Noise::Noise::isCreated
const bool & isCreated() const
Is created() called?
Definition: Noise.h:100
Module.h
Hydrax::Module::Module::mNoise
Noise::Noise * mNoise
Noise generator pointer.
Definition: Module.h:156