SuperTuxKart
lod_node.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2011-2015 Marianne Gagnon
3 // based on code Copyright 2002-2010 Nikolaus Gebhardt
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_LOD_NODE_HPP
20 #define HEADER_LOD_NODE_HPP
21 
22 #include <aabbox3d.h>
23 #include <matrix4.h>
24 #include <ISceneNode.h>
25 #include <vector>
26 #include <string>
27 
28 namespace irr
29 {
30  namespace scene { class ISceneManager; class ISceneNode; }
31 }
32 using namespace irr;
33 
34 #include <set>
35 
36 namespace irr
37 {
38  namespace scene
39  {
40  const int ESNT_LOD_NODE = MAKE_IRR_ID('l','o','d','n');
41  }
42 }
43 
48 class LODNode : public scene::ISceneNode
49 {
50 private:
51  core::matrix4 RelativeTransformationMatrix;
52  core::aabbox3d<f32> Box;
53 
54  std::vector<int> m_detail;
55  std::vector<irr::scene::ISceneNode*> m_nodes;
56 
57  std::set<scene::ISceneNode*> m_nodes_set;
58 
59  std::string m_group_name;
60 
64 
65  enum PreviousVisibility
66  {
67  FIRST_PASS,
68  WAS_SHOWN,
69  WAS_HIDDEN
70  };
71 
72  PreviousVisibility m_previous_visibility;
73 
74  u32 m_last_tick;
75 
76 public:
77 
78  LODNode(std::string group_name, scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id=-1);
79  virtual ~LODNode();
80 
82  virtual const core::aabbox3d<f32>& getBoundingBox() const { return Box; }
83 
84  int getLevel();
85 
86  void updateVisibility(bool* shown = NULL);
87 
88  /*
92  virtual core::matrix4& getRelativeTransformationMatrix() { return RelativeTransformationMatrix; }
93 
95  virtual core::matrix4 getRelativeTransformation() const { return RelativeTransformationMatrix; }
96  */
97 
105  void add(int level, scene::ISceneNode* node, bool reparent);
106 
107  void forceLevelOfDetail(int n);
108 
110  scene::ISceneNode* getFirstNode()
111  {
112  if (m_nodes.size() > 0) return m_nodes[0];
113  else return NULL;
114  }
115 
116  std::vector<scene::ISceneNode*>& getAllNodes() { return m_nodes; }
117 
119 
121  virtual void OnAnimate(u32 timeMs);
122 
123  virtual void OnRegisterSceneNode();
124  virtual void render();
125 
126  virtual scene::ESCENE_NODE_TYPE getType() const { return (scene::ESCENE_NODE_TYPE)scene::ESNT_LOD_NODE; }
127 
128  const std::string& getGroupName() const { return m_group_name; }
129 };
130 
131 #endif
int m_forced_lod
The normal level of detail can be overwritten.
Definition: lod_node.hpp:63
manages level-of-detail
Definition: lod_node.hpp:48
virtual const core::aabbox3d< f32 > & getBoundingBox() const
returns the axis aligned bounding box of this node
Definition: lod_node.hpp:82
scene::ISceneNode * getFirstNode()
Get the highest level of detail node.
Definition: lod_node.hpp:110
void render(float elapsed_time, bool is_loading)
called on every frame to trigger the rendering of the GUI.
Definition: engine.cpp:1190