Carna  Version 3.3.2
Renderable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 - 2015 Leonid Kostrykin
3  *
4  * Chair of Medical Engineering (mediTEC)
5  * RWTH Aachen University
6  * Pauwelsstr. 20
7  * 52074 Aachen
8  * Germany
9  *
10  */
11 
12 #ifndef RENDERABLE_H_6014714286
13 #define RENDERABLE_H_6014714286
14 
15 #include <Carna/Carna.h>
17 #include <Carna/base/math.h>
18 
23 namespace Carna
24 {
25 
26 namespace base
27 {
28 
29 
30 
31 // ----------------------------------------------------------------------------------
32 // Renderable
33 // ----------------------------------------------------------------------------------
34 
45 class CARNA_LIB Renderable
46 {
47 
48  struct Details;
49  const std::unique_ptr< Details > pimpl;
50 
51 public:
52 
56  Renderable( const Geometry& geometry, const math::Matrix4f& modelViewTransform );
57 
61  Renderable( const Renderable& other );
62 
66  ~Renderable();
67 
71  const Geometry& geometry() const;
72 
76  const math::Matrix4f& modelViewTransform() const;
77 
81  void setModelViewTransform( const math::Matrix4f& );
82 
86  const math::Matrix4f& viewModelTransform() const;
87 
95  float eyeDistance2() const;
96 
100  Renderable& operator=( const Renderable& other );
101 
109  template< int order >
110  struct DepthOrder
111  {
116  const static bool isViewDependent = true;
117 
122  bool operator()( const Renderable& l, const Renderable& r ) const;
123  };
124 
130 
135  typedef DepthOrder< -1 > FrontToBack;
136 
143  template< unsigned int role >
145  {
150  const static bool isViewDependent = false;
151 
156  bool operator()( const Renderable& l, const Renderable& r ) const;
157  };
158 
159 }; // Renderable
160 
161 
162 template< int order >
164 {
165  return order * ( l.eyeDistance2() - r.eyeDistance2() ) > 0;
166 }
167 
168 
169 template< unsigned int role >
171 {
172  const GeometryFeature& gfl = l.geometry().feature( role );
173  const GeometryFeature& gfr = r.geometry().feature( role );
174  if( gfl.controlsSameVideoResource( gfr ) )
175  {
176  return false;
177  }
178  else
179  {
180  return &gfl < &gfr;
181  }
182 }
183 
184 
185 
186 } // namespace Carna :: base
187 
188 } // namespace Carna
189 
190 #endif // RENDERABLE_H_6014714286
Defines Carna::base::math namespace and CARNA_FOR_VECTOR3UI.
DepthOrder< -1 > FrontToBack
Defines partial order for renderables w.r.t. to their depth in eye space s.t. closer renderables come...
Definition: Renderable.h:135
Defines scene graph leafs. Instances of this class represent visible geometry that can be rendered...
Definition: Geometry.h:59
Defines Carna::base::GeometryFeature.
bool operator()(const Renderable &l, const Renderable &r) const
Returns the result of GeometryFeature::controlsSameVideoResource for the geometry features with role ...
Definition: Renderable.h:170
GeometryFeature & feature(unsigned int role) const
References the feature with role attached to this node in .
Establishes partial order for renderables s.t. geometries with such GeometryFeature instances...
Definition: Renderable.h:144
Represents "components" that are aggregated by Geometry objects. Closer description is given here...
float eyeDistance2() const
Returns the squared distance of geometry to the eye. If it has an associated boundary volume...
bool operator()(const Renderable &l, const Renderable &r) const
Tells whether l is further away than r for order>0 or closer for order<0 respectively.
Definition: Renderable.h:163
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > Matrix4f
Defines matrix.
Definition: math.h:193
const Geometry & geometry() const
References the geometry node.
Defines partial order for renderables w.r.t. to their depth in eye space.
Definition: Renderable.h:110
virtual bool controlsSameVideoResource(const GeometryFeature &other) const =0
Tells whether this instance maintains the same video resources like other.
Represents a Geometry object that has been queued into a RenderQueue. The object&#39;s model-view transfo...
Definition: Renderable.h:45
DepthOrder<+1 > BackToFront
Defines partial order for renderables w.r.t. to their depth in eye space s.t. distant renderables com...
Definition: Renderable.h:129