GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
Scene.h
1 /*
2  * Copyright (c) 2018, Stefan Osswald
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef INCLUDE_ARTICULATION_SCENE_H_
32 #define INCLUDE_ARTICULATION_SCENE_H_
33 
34 #include <gpu_coverage/Light.h>
35 #include <gpu_coverage/Material.h>
36 #include <gpu_coverage/Mesh.h>
37 #include <gpu_coverage/Node.h>
38 #include <gpu_coverage/Animation.h>
39 #include <gpu_coverage/CameraPanorama.h>
40 #include <gpu_coverage/CameraPerspective.h>
41 #include <gpu_coverage/Image.h>
42 #include <gpu_coverage/Programs.h>
43 #include <map>
44 
45 // Forward declaration
46 struct aiScene;
47 
48 namespace gpu_coverage {
49 
50 // Forward declaration
51 struct Locations;
52 
59 class Scene {
60 public:
66  Scene(const aiScene * const aiScene, const std::string& dir);
67 
71  virtual ~Scene();
72 
82  void render(const AbstractCamera * const camera,
83  const LocationsMVP * const locationsMVP,
84  const LocationsLight * const locationsLight = NULL,
85  const LocationsMaterial * const locationsMaterial = NULL,
86  const bool hasTesselationShader = false) const;
87 
93  Node *findNode(const std::string& name) const;
94 
100  Material *findMaterial(const std::string& name) const;
101 
107  CameraPerspective *findCamera(const std::string& name) const;
108 
114  CameraPanorama *makePanoramaCamera(Node * const camera);
115 
116  typedef std::vector<CameraPerspective*> Cameras;
117  typedef std::vector<Light*> Lights;
118  typedef std::vector<Material*> Materials;
119  typedef std::vector<Mesh*> Meshes;
120  typedef std::vector<Image*> Textures;
121  typedef std::vector<Animation*> Animations;
122  typedef std::vector<CameraPanorama*> PanoramaCameras;
123  typedef std::map<std::string, Node*> NodeMap;
124  typedef std::vector<Channel*> Channels;
125  NodeMap nodeMap;
126  Meshes meshes;
127  Cameras cameras;
128  PanoramaCameras panoramaCameras;
129  Lights lights;
130  Textures textures;
131  Materials materials;
132  Animations animations;
133  Channels channels;
136 
141  inline const size_t& getNumFrames() const {
142  return numFrames;
143  }
148  inline const size_t& getStartFrame() const {
149  return startFrame;
150  }
155  inline const size_t& getEndFrame() const {
156  return endFrame;
157  }
158 
163  inline const Channels& getChannels() const {
164  return channels;
165  }
166 
171  inline Node * getRoot() const {
172  return root;
173  }
174 
179  void toDot(const char* dotFilePath) const;
180 
181 protected:
182  void collectNodes(Node * node);
183 
184  size_t numFrames;
185  size_t startFrame;
186  size_t endFrame;
187 };
188 
189 } /* namespace gpu_coverage */
190 
191 #endif /* INCLUDE_ARTICULATION_SCENE_H_ */
Textures textures
Vector of mesh textures of the scene.
Definition: Scene.h:130
std::vector< Material * > Materials
Vector of materials of the scene.
Definition: Scene.h:118
Cameras cameras
Vector of cameras of the sceene.
Definition: Scene.h:127
PanoramaCameras panoramaCameras
Vector of panorama cameras of the scene.
Definition: Scene.h:128
void toDot(const char *dotFilePath) const
Write the scene graph structure as a GraphViz Dot file for debugging.
Locations of light source shader variables.
Definition: Programs.h:125
size_t endFrame
Last animation frame, see getEndFrame().
Definition: Scene.h:186
Meshes meshes
Vector of meshes of the scene.
Definition: Scene.h:126
Scene(const aiScene *const aiScene, const std::string &dir)
Constructor.
Materials materials
Vector of materials of the scene.
Definition: Scene.h:131
std::vector< Animation * > Animations
Vector of animations of the scene.
Definition: Scene.h:121
const Channels & getChannels() const
Definition: Scene.h:163
CameraPanorama * makePanoramaCamera(Node *const camera)
Adds a new panorama camera to the scene and returns a pointer.
Scene graph corresponding to Assimp&#39;s aiScene.
Definition: Scene.h:59
Scene graph node, corresponding to Assimp&#39;s aiNode.
Definition: Node.h:52
const size_t & getStartFrame() const
Returns the start frame of the animation.
Definition: Scene.h:148
CameraPerspective * findCamera(const std::string &name) const
Finds a camera by name, returns NULL if not found.
Locations of material shader variables.
Definition: Programs.h:142
Node * root
Root node of the scene graph.
Definition: Scene.h:134
std::vector< CameraPerspective * > Cameras
Vector of cameras of the sceene.
Definition: Scene.h:116
const size_t & getEndFrame() const
Returns the last frame of the animation.
Definition: Scene.h:155
void render(const AbstractCamera *const camera, const LocationsMVP *const locationsMVP, const LocationsLight *const locationsLight=NULL, const LocationsMaterial *const locationsMaterial=NULL, const bool hasTesselationShader=false) const
Render the scene with the current shader.
Perspective projection camera.
Definition: CameraPerspective.h:45
std::vector< Light * > Lights
Vector of light sources of the scene.
Definition: Scene.h:117
Node * findNode(const std::string &name) const
Finds a node by name, returns NULL if not found.
std::vector< Mesh * > Meshes
Vector of meshes of the scene.
Definition: Scene.h:119
Locations of model, view, and projection shader variables.
Definition: Programs.h:104
std::vector< Image * > Textures
Vector of mesh textures of the scene.
Definition: Scene.h:120
virtual ~Scene()
Destructor.
Animations animations
Vector of animations of the scene.
Definition: Scene.h:132
const size_t & getNumFrames() const
Returns the number of animation frames.
Definition: Scene.h:141
Definition: AbstractCamera.h:41
Node * getRoot() const
Get the root node of the scene graph.
Definition: Scene.h:171
Abstract superclass for all cameras.
Definition: AbstractCamera.h:48
std::vector< Channel * > Channels
Vector of animation channels of the scene.
Definition: Scene.h:124
Represents a mesh material corresponding to Assimp&#39;s aiMaterial.
Definition: Material.h:43
size_t startFrame
First animation frame, see getStartFrame().
Definition: Scene.h:185
std::map< std::string, Node * > NodeMap
Map mapping node names to node pointers.
Definition: Scene.h:123
size_t numFrames
Number of animation frames, see getNumFrames().
Definition: Scene.h:184
Material * findMaterial(const std::string &name) const
Finds a material by name, returns NULL if not found.
std::vector< CameraPanorama * > PanoramaCameras
Vector of panorama cameras of the scene.
Definition: Scene.h:122
Channels channels
Vector of animation channels of the scene.
Definition: Scene.h:133
Omnidirectional panorama camera.
Definition: CameraPanorama.h:44
NodeMap nodeMap
Map mapping node names to node pointers.
Definition: Scene.h:125
gpu_coverage::Node * lampNode
Scene graph node where the first light source is attached.
Definition: Scene.h:135
Lights lights
Vector of light sources of the scene.
Definition: Scene.h:129