Tinman  1.0
scene.h
Go to the documentation of this file.
1 // Tinman author: Isaac Lacoba Molina
2 // Copyright (C) 2014 ISAAC LACOBA MOLINA
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (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, see <http://www.gnu.org/licenses/>.
16 //
17 #ifndef SCENE_H
18 #define SCENE_H
19 #include <OgreRoot.h>
20 #include <OgreLogManager.h>
21 #include <OgreRenderWindow.h>
22 #include <OgreWindowEventUtilities.h>
23 #include <OgreCamera.h>
24 #include <OgreSceneManager.h>
25 #include <OgreResourceGroupManager.h>
26 #include <OgreConfigFile.h>
27 #include <OgreManualObject.h>
28 #include <OgreEntity.h>
29 #include <OgreMeshManager.h>
30 #include <OgreParticleSystem.h>
31 
32 #include <LinearMath/btVector3.h>
33 
34 #include <memory>
35 
36 class Scene {
37  const std::string window_title = "Tinman Project";
38 
39  Ogre::Root* root_;
40  Ogre::SceneManager* scene_manager_;
41 
42  public:
43  typedef std::shared_ptr<Scene> shared;
44 
45  Ogre::RenderWindow* window_;
46  Ogre::Camera* camera_;
47  Ogre::RaySceneQuery* ray_query_;
48 
49  Scene();
50  void render_one_frame(void);
51  Ogre::Ray set_ray_query(float x, float y);
52  void create_light(void);
53  void set_light_range( Ogre::Light *light, Ogre::Real range);
54 
55  void create_camera(Ogre::RenderWindow* window);
56 
57  Ogre::SceneNode* get_node(std::string node);
58  void attach(Ogre::SceneNode* node, Ogre::Entity* entity);
59 
60  Ogre::SceneNode* create_graphic_element(Ogre::Vector3 position,
61  std::string name,
62  std::string mesh);
63  Ogre::SceneNode* create_graphic_element(std::string entity,
64  std::string mesh, std::string parent, std::string name);
65  Ogre::SceneNode* create_graphic_element(Ogre::Entity* entity,
66  std::string parent, std::string name);
67 
68  Ogre::SceneNode* create_plane(std::string axis, std::string name, std::string mesh,
69  std::string parent, std::string material);
70 
71  Ogre::SceneNode* get_child_node(std::string parent, std::string name);
72  Ogre::SceneNode* get_child_node(Ogre::SceneNode* parent, std::string name);
73 
74  Ogre::Entity* create_entity(std::string name, std::string mesh, bool cast_shadows);
75 
76  void move_node(std::string node_name, Ogre::Vector3 increment);
77 
78  Ogre::ParticleSystem* get_particle(std::string name, std::string particle_system);
79  Ogre::ParticleSystem* get_particle(Ogre::SceneNode* node, std::string name, std::string particle_system);
80  Ogre::ParticleSystem* get_particle(std::string name, std::string particle_system, Ogre::Vector3 position);
81 
82  void add_child(Ogre::SceneNode* parent, Ogre::SceneNode* child);
83  void destroy_node(std::string);
84  void destroy_node(Ogre::SceneNode* child);
85  void destroy_entity(Ogre::Entity* entity);
86 
87  void remove_child(std::string parent, std::string child);
88  void remove_child(std::string parent, Ogre::SceneNode* child);
89  void remove_child(Ogre::SceneNode* parent, std::string child);
90  void remove_child(Ogre::SceneNode* parent, Ogre::SceneNode* child);
91 
92  void destroy_scene();
93  void destroy_all_attached_movable_objects(Ogre::SceneNode* node);
94 
95  Ogre::Vector3 convert_btvector3_to_vector3(btVector3 position);
96 
97  private:
98  void load_resources();
99  Ogre::SceneNode* create_node(std::string name);
100  Ogre::SceneNode* create_child_node(Ogre::SceneNode* parent, std::string name);
101 
102  Ogre::Vector3 get_axis(std::string axis);
103  Ogre::Vector3 get_normal(std::string axis);
104 };
105 #endif
Ogre::Entity * create_entity(std::string name, std::string mesh, bool cast_shadows)
Definition: scene.cpp:195
void render_one_frame(void)
Definition: scene.cpp:65
void destroy_all_attached_movable_objects(Ogre::SceneNode *node)
Definition: scene.cpp:285
std::shared_ptr< Scene > shared
Definition: scene.h:43
Ogre::Camera * camera_
Definition: scene.h:46
Ogre::SceneNode * create_plane(std::string axis, std::string name, std::string mesh, std::string parent, std::string material)
Definition: scene.cpp:156
Ogre::ParticleSystem * get_particle(std::string name, std::string particle_system)
Definition: scene.cpp:216
Ogre::SceneNode * get_child_node(std::string parent, std::string name)
Definition: scene.cpp:182
Ogre::SceneManager * scene_manager_
Definition: scene.h:40
Ogre::Vector3 get_axis(std::string axis)
Definition: scene.cpp:299
Scene()
Definition: scene.cpp:21
Ogre::SceneNode * create_child_node(Ogre::SceneNode *parent, std::string name)
Definition: scene.cpp:187
void remove_child(std::string parent, std::string child)
Definition: scene.cpp:259
Ogre::Root * root_
Definition: scene.h:39
void attach(Ogre::SceneNode *node, Ogre::Entity *entity)
Definition: scene.cpp:130
void destroy_entity(Ogre::Entity *entity)
Definition: scene.cpp:253
void add_child(Ogre::SceneNode *parent, Ogre::SceneNode *child)
Definition: scene.cpp:202
const std::string window_title
Definition: scene.h:37
Ogre::Vector3 get_normal(std::string axis)
Definition: scene.cpp:313
Ogre::Vector3 convert_btvector3_to_vector3(btVector3 position)
Definition: scene.cpp:294
Ogre::SceneNode * create_graphic_element(Ogre::Vector3 position, std::string name, std::string mesh)
Definition: scene.cpp:135
void load_resources()
Definition: scene.cpp:41
Ogre::RaySceneQuery * ray_query_
Definition: scene.h:47
void destroy_node(std::string)
Definition: scene.cpp:241
void set_light_range(Ogre::Light *light, Ogre::Real range)
Definition: scene.h:36
Ogre::RenderWindow * window_
Definition: scene.h:45
Ogre::SceneNode * get_node(std::string node)
Definition: scene.cpp:119
void destroy_scene()
Definition: scene.cpp:279
void create_camera(Ogre::RenderWindow *window)
Definition: scene.cpp:97
void move_node(std::string node_name, Ogre::Vector3 increment)
Definition: scene.cpp:207
void create_light(void)
Definition: scene.cpp:81
Ogre::Ray set_ray_query(float x, float y)
Definition: scene.cpp:71
Ogre::SceneNode * create_node(std::string name)
Definition: scene.cpp:114