ComputerGraphik TU WIEN
|
Encapsulates the Rendering Engine, holds a complete scene and it's assets. More...
#include <scene.hpp>
Public Types | |
enum | { SentinelPre = 0, SentinelDraw = 1000, SentinelDrawPickable = 1500, SentinelPost = 2000, SentinelUnordered = 3000 } |
typedef std::map< std::size_t, std::shared_ptr< SceneObject > >::const_iterator | ConstIterator |
Public Member Functions | |
Scene (GLFWwindow *window) | |
~Scene () | |
void | init (const std::string &scenePath) |
void | clearRender () |
void | remRender (std::shared_ptr< SceneObject > &object) |
void | getRender (size_t idx, std::shared_ptr< SceneObject > &object) const |
size_t | pushRender (std::shared_ptr< SceneObject > &object, size_t idx=SentinelUnordered) |
size_t | insertRender (std::shared_ptr< SceneObject > &object, size_t idx=SentinelUnordered) |
Shader * | getShader (const std::string &name) const |
void | addShader (const std::string &name, std::unique_ptr< Shader > &shader) |
void | changeRenderShader (const std::string &from, const std::string &to) |
GLFWwindow * | getWindow () const |
std::shared_ptr< Light > | getLight () const |
std::shared_ptr< Camera > | getCamera () const |
std::shared_ptr< SceneObject > | getRootNode () const |
std::shared_ptr< CubeMapObject > | getCubeMapObject () const |
std::shared_ptr< LightCamera > | getLightCam () const |
std::shared_ptr< SunVolumetric > | getSunVolumetric () const |
std::shared_ptr< MouseSemantics > | getMouseSemantics () const |
std::shared_ptr< SelectorBase > | getActiveSelector () const |
std::shared_ptr< Legend > | getLegend () const |
std::shared_ptr< BubbleCursor > | getBubbleCursor () const |
bool | getObject (const std::string &name, std::shared_ptr< SceneObject > &object, size_t pos=1) const |
void | setWindow (GLFWwindow *val) |
void | setLight (std::shared_ptr< Light > val) |
void | setCamera (std::shared_ptr< Camera > val) |
void | setRootNode (std::shared_ptr< SceneObject > root) |
void | setCubeMapObject (std::shared_ptr< CubeMapObject > val) |
void | setLightCam (std::shared_ptr< LightCamera > val) |
void | setSunVolumetric (std::shared_ptr< SunVolumetric > val) |
void | setMouseSemantics (std::shared_ptr< MouseSemantics > val) |
void | setActiveSelector (std::shared_ptr< SelectorBase > val) |
void | setLegend (std::shared_ptr< Legend > val) |
void | setBubbleCursor (std::shared_ptr< BubbleCursor > val) |
ConstIterator | end () const |
ConstIterator | begin () const |
ConstIterator | end (size_t idx) const |
ConstIterator | begin (size_t idx) const |
Static Public Member Functions | |
static std::shared_ptr< SceneObject > | get (const ConstIterator &it) |
Private Member Functions | |
bool | getObjectRecursive (const std::string &name, std::shared_ptr< SceneObject > &object, size_t &pos) const |
Private Attributes | |
GLFWwindow * | window |
std::shared_ptr< Light > | light |
std::shared_ptr< Camera > | camera |
std::shared_ptr< CubeMapObject > | cmObject |
std::shared_ptr< LightCamera > | lightCam |
std::shared_ptr< SunVolumetric > | sunVolumetric |
std::shared_ptr< MouseSemantics > | mouseSemantics |
std::shared_ptr< SelectorBase > | activeSelector |
std::shared_ptr< Legend > | legend |
std::shared_ptr< BubbleCursor > | bubbleCursor |
std::shared_ptr< SceneObject > | rootNode |
std::map< std::string, std::unique_ptr< Model > > | models |
std::map< std::string, std::unique_ptr< Shader > > | shaders |
std::map< std::string, std::unique_ptr< Texture > > | textures |
std::map< std::size_t, std::shared_ptr< SceneObject > > | renderList |
Friends | |
class | Debug |
class | AssimpLoader |
Encapsulates the Rendering Engine, holds a complete scene and it's assets.
The rendering engine has the same hierarchy as the Assimp aiScene class. The Assimp Scene Structure can be seen on the following image.
The rendering engine is designed in parent-child relation. Each SceneObject holds it's local model matrix. In order to compute the global model matrix of an object, the parents must be traversed until the root. This way the camera is also the part of the scene, therefore camera animation can be handled. Also animated objects like the tank can be displayed.
Each SceneObject (Assimp:aiNode) has a corresponding aiNodeAnim, which is accessible through the name. For convenience, the number of Quaternion, Position and Scaling and their time at the same index must be the same. The time is a measurement since the start of the global scene animation. The local model matrices are computed using the equation M = T * R * S, where the Quaternions, Position and Scalings are interpolated values between two T, R, S from aiNodeAnim. The SceneObject class has a virtual animate() function, which takes the time since start as an argument. This function takes the $i^{th}$ local model matrix from the animation, where $M_i.time < time <= M_{i+1}.time$ and sets it as the current local model matrix. The animate() function was chosen to be virtual, because special objects might need special calls, for example the camera class needs to compute the view matrix on every model matrix change.
The models are also loaded using the Assimp library. The material information is stored in the model object. Images are loaded using the OpenCV library and stored in a texture object. Multiple SceneObjects can use the same model or texture objects. Shader loading is redesigned to be able to link together arbitrary number of shaders of different types.
typedef std::map<std::size_t, std::shared_ptr<SceneObject> >::const_iterator Scene::ConstIterator |
anonymous enum |
Scene::Scene | ( | GLFWwindow * | window | ) |
Scene::~Scene | ( | ) |
void Scene::addShader | ( | const std::string & | name, |
std::unique_ptr< Shader > & | shader | ||
) |
|
inline |
|
inline |
void Scene::changeRenderShader | ( | const std::string & | from, |
const std::string & | to | ||
) |
void Scene::clearRender | ( | ) |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool Scene::getObject | ( | const std::string & | name, |
std::shared_ptr< SceneObject > & | object, | ||
size_t | pos = 1 |
||
) | const |
|
private |
void Scene::getRender | ( | size_t | idx, |
std::shared_ptr< SceneObject > & | object | ||
) | const |
|
inline |
Shader * Scene::getShader | ( | const std::string & | name | ) | const |
|
inline |
|
inline |
void Scene::init | ( | const std::string & | scenePath | ) |
size_t Scene::insertRender | ( | std::shared_ptr< SceneObject > & | object, |
size_t | idx = SentinelUnordered |
||
) |
size_t Scene::pushRender | ( | std::shared_ptr< SceneObject > & | object, |
size_t | idx = SentinelUnordered |
||
) |
void Scene::remRender | ( | std::shared_ptr< SceneObject > & | object | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |