Cafu Engine
ModelNode.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_MODEL_NODE_HPP_INCLUDED
8 #define CAFU_MODEL_NODE_HPP_INCLUDED
9 
10 #include "Node.hpp"
11 #include "Models/AnimExpr.hpp"
12 #include "Util/Util.hpp"
13 
14 
15 class CafuModelT;
16 class ModelManagerT;
17 
18 
19 namespace cf
20 {
21  namespace SceneGraph
22  {
23  class ModelNodeT : public GenericNodeT
24  {
25  public:
26 
27  /// Constructor for creating a ModelNodeT from parameters.
28  ModelNodeT(const CafuModelT* Model, const std::string& Label, const Vector3fT& Origin, const Vector3fT& Angles, float Scale=1.0f, int SeqNumber=0, float FrameOffset=0.0f, float FrameTimeScale=1.0f, bool Animate=false);
29 
30  /// Named constructor.
31  static ModelNodeT* CreateFromFile_cw(std::istream& InFile, aux::PoolT& Pool, ModelManagerT& ModelMan);
32 
33  /// The destructor.
34  ~ModelNodeT();
35 
36  // The NodeT interface.
37  void WriteTo(std::ostream& OutFile, aux::PoolT& Pool) const;
39 
40  //void InitDrawing();
41  bool IsOpaque() const { return true; }
42  void DrawAmbientContrib(const Vector3dT& ViewerPos) const;
43  //void DrawStencilShadowVolumes(const Vector3dT& LightPos, const float LightRadius) const;
44  //void DrawLightSourceContrib(const Vector3dT& ViewerPos, const Vector3dT& LightPos) const;
45  //void DrawTranslucentContrib(const Vector3dT& ViewerPos) const;
46 
47 
48  private:
49 
50  /// The constructor.
51  ModelNodeT();
52 
53  ModelNodeT(const ModelNodeT&); ///< Use of the Copy Constructor is not allowed.
54  void operator = (const ModelNodeT&); ///< Use of the Assignment Operator is not allowed.
55 
56  const CafuModelT* m_Model;
57  std::string m_Label;
58  Vector3fT m_Origin;
59  Vector3fT m_Angles;
60  float m_Scale;
61  mutable IntrusivePtrT<AnimExprStandardT> m_AnimExpr; // FIXME: See comment below. The anim expression is updated inside the constant DrawAmbientContrib() method...
62  float m_FrameOffset;
63  float m_FrameTimeScale;
64  bool m_Animate;
65 
66  // TODO/FIXME Unfortunately a mutable timer is necessary in order to get the frame time (done via a non const method in TimerT) on each
67  // DrawAmbientContrib call (which is a const method).
68  // Further every model has its own timer object to calculate its animation frame. This "problem" occurs for the first time in the scene graph
69  // since all other scene graph objects are rendered statically and don't change over time.
70  // In general we should evaluate timer usage throughout the engine and aim for a global timer object that is shared by all classes if they
71  // have time dependent functionality (or to pass a FrameTime parameter to the scene graph draw methods).
72  mutable TimerT m_Timer;
73  };
74  }
75 }
76 
77 #endif
This class represents a native Cafu model.
Definition: Model_cmdl.hpp:45
Definition: _aux.hpp:111
static ModelNodeT * CreateFromFile_cw(std::istream &InFile, aux::PoolT &Pool, ModelManagerT &ModelMan)
Named constructor.
Definition: ModelNode.cpp:44
bool IsOpaque() const
TODO / FIXME: This method is a hot-fix for getting the render order with translucent Bezier Patches r...
Definition: ModelNode.hpp:41
void DrawAmbientContrib(const Vector3dT &ViewerPos) const
Draws the contents of this scene node.
Definition: ModelNode.cpp:101
A platform independent timer class that allows to measure the time passed since its construction or t...
Definition: Util.hpp:24
Definition: ModelNode.hpp:23
This class is used for managing model instances.
Definition: ModelManager.hpp:31
~ModelNodeT()
The destructor.
Definition: ModelNode.cpp:66
const BoundingBox3T< double > & GetBoundingBox() const
Returns the bounding box of the contents of this scene node.
Definition: ModelNode.cpp:91
Definition: Node.hpp:35