Last change
on this file since 230 was
230,
checked in by epyon, 11 years ago
|
- animated_mesh, scene_node, camera and transform classes added
- order in mesh hierarchies
- simplified and generified animation class hierarchy
|
File size:
1.6 KB
|
Rev | Line | |
---|
[230] | 1 | // Copyright (C) 2014 ChaosForge / Kornel Kisielewicz
|
---|
| 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
| 4 | // This file is part of NV Libraries.
|
---|
| 5 | // For conditions of distribution and use, see copyright notice in nv.hh
|
---|
| 6 | /**
|
---|
| 7 | * @file scene_node.hh
|
---|
| 8 | * @author Kornel Kisielewicz epyon@chaosforge.org
|
---|
| 9 | * @brief Scene node class
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | #ifndef NV_SCENE_NODE_HH
|
---|
| 13 | #define NV_SCENE_NODE_HH
|
---|
| 14 |
|
---|
| 15 | #include <nv/common.hh>
|
---|
| 16 | #include <vector>
|
---|
| 17 | #include <nv/transform.hh>
|
---|
| 18 | #include <nv/math.hh>
|
---|
| 19 | #include <nv/interface/render_state.hh>
|
---|
| 20 |
|
---|
| 21 | namespace nv
|
---|
| 22 | {
|
---|
| 23 |
|
---|
| 24 | class scene_node
|
---|
| 25 | {
|
---|
| 26 | public:
|
---|
| 27 | typedef std::vector< scene_node* > list;
|
---|
| 28 |
|
---|
| 29 | scene_node() {}
|
---|
| 30 |
|
---|
| 31 | virtual void update( uint32 ms )
|
---|
| 32 | {
|
---|
| 33 | for ( auto& child : m_children )
|
---|
| 34 | {
|
---|
| 35 | child->update( ms );
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | virtual void attach( scene_node* child )
|
---|
| 40 | {
|
---|
| 41 | m_children.push_back( child );
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | virtual void set_transform( const transform& t )
|
---|
| 45 | {
|
---|
| 46 | m_transform = t;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | virtual const transform& get_transform() const
|
---|
| 50 | {
|
---|
| 51 | return m_transform;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | virtual mat4 extract_transform_matrix() const
|
---|
| 55 | {
|
---|
| 56 | return get_transform().extract();
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | const vec3& get_position() const
|
---|
| 60 | {
|
---|
| 61 | return m_transform.get_position();
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | const quat& get_orientation() const
|
---|
| 65 | {
|
---|
| 66 | return m_transform.get_orientation();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | list::const_iterator begin() { return m_children.cbegin(); }
|
---|
| 71 | list::const_iterator end() { return m_children.cend(); }
|
---|
| 72 |
|
---|
| 73 | virtual ~scene_node()
|
---|
| 74 | {
|
---|
| 75 | for ( auto& child : m_children ) delete child;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | protected:
|
---|
| 79 | transform m_transform;
|
---|
| 80 | list m_children;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | #endif // NV_SCENE_NODE_HH
|
---|
Note: See
TracBrowser
for help on using the repository browser.