Carna Version 3.3.3
Loading...
Searching...
No Matches
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
23namespace Carna
24{
25
26namespace base
27{
28
29
30
31// ----------------------------------------------------------------------------------
32// Renderable
33// ----------------------------------------------------------------------------------
34
45class CARNA_LIB Renderable
46{
47
48 struct Details;
49 const std::unique_ptr< Details > pimpl;
50
51public:
52
56 Renderable( const Geometry& geometry, const math::Matrix4f& modelViewTransform );
57
62
67
71 const Geometry& geometry() const;
72
77
82
87
95 float eyeDistance2() const;
96
101
109 template< int order >
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
162template< int order >
164{
165 return order * ( l.eyeDistance2() - r.eyeDistance2() ) > 0;
166}
167
168
169template< 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::GeometryFeature.
Represents an association.
Definition Association.h:45
Represents "components" that are aggregated by Geometry objects. Closer description is given here.
Defines scene graph leafs. Instances of this class represent visible geometry that can be rendered....
Definition Geometry.h:60
Represents a Geometry object that has been queued into a RenderQueue. The object's model-view transfo...
Definition Renderable.h:46
float eyeDistance2() const
Returns the squared distance of geometry to the eye. If it has an associated boundary volume,...
const math::Matrix4f & viewModelTransform() const
Returns the inverse modelViewTransform.
Renderable(const Geometry &geometry, const math::Matrix4f &modelViewTransform)
Associates geometry with modelViewTransform.
const Geometry & geometry() const
References the geometry node.
void setModelViewTransform(const math::Matrix4f &)
Alters the model-view transform.
Renderable(const Renderable &other)
Copies from other.
Renderable & operator=(const Renderable &other)
Assigns from other.
const math::Matrix4f & modelViewTransform() const
References the model-view transform.
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
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 Carna::base::math namespace and CARNA_FOR_VECTOR3UI.
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > Matrix4f
Defines matrix.
Definition math.h:193
Defines partial order for renderables w.r.t. to their depth in eye space.
Definition Renderable.h:111
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
Establishes partial order for renderables s.t. geometries with such GeometryFeature instances,...
Definition Renderable.h:145
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