LibCarna Version 3.4.0
Loading...
Searching...
No Matches
Renderable.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 - 2016 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 *
11 * Copyright (C) 2021 - 2025 Leonid Kostrykin
12 *
13 */
14
15#ifndef RENDERABLE_H_6014714286
16#define RENDERABLE_H_6014714286
17
18#include <LibCarna/LibCarna.hpp>
21
27namespace LibCarna
28{
29
30namespace base
31{
32
33
34
35// ----------------------------------------------------------------------------------
36// Renderable
37// ----------------------------------------------------------------------------------
38
48class LIBCARNA Renderable
49{
50
51 struct Details;
52 const std::unique_ptr< Details > pimpl;
53
54public:
55
59 Renderable( const Geometry& geometry, const math::Matrix4f& modelViewTransform );
60
65
70
74 const Geometry& geometry() const;
75
80
85
90
98 float eyeDistance2() const;
99
104
112 template< int order >
114 {
119 const static bool isViewDependent = true;
120
125 bool operator()( const Renderable& l, const Renderable& r ) const;
126 };
127
133
138 typedef DepthOrder< -1 > FrontToBack;
139
146 template< unsigned int role >
148 {
153 const static bool isViewDependent = false;
154
159 bool operator()( const Renderable& l, const Renderable& r ) const;
160 };
161
162}; // Renderable
163
164
165template< int order >
167{
168 return order * ( l.eyeDistance2() - r.eyeDistance2() ) > 0;
169}
170
171
172template< unsigned int role >
174{
175 const GeometryFeature& gfl = l.geometry().feature( role );
176 const GeometryFeature& gfr = r.geometry().feature( role );
177 if( gfl.controlsSameVideoResource( gfr ) )
178 {
179 return false;
180 }
181 else
182 {
183 return &gfl < &gfr;
184 }
185}
186
187
188
189} // namespace LibCarna :: base
190
191} // namespace LibCarna
192
193#endif // RENDERABLE_H_6014714286
Defines LibCarna::base::GeometryFeature.
Contains forward-declarations.
Represents an association.
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.hpp:63
Represents a Geometry object that has been queued into a RenderQueue. The object's model-view transfo...
Renderable(const Geometry &geometry, const math::Matrix4f &modelViewTransform)
Associates geometry with modelViewTransform.
DepthOrder< -1 > FrontToBack
Defines partial order for renderables w.r.t. to their depth in eye space s.t. closer renderables come...
Renderable(const Renderable &other)
Copies from other.
DepthOrder<+1 > BackToFront
Defines partial order for renderables w.r.t. to their depth in eye space s.t. distant renderables com...
const math::Matrix4f & viewModelTransform() const
Returns the inverse modelViewTransform.
void setModelViewTransform(const math::Matrix4f &)
Alters the model-view transform.
const Geometry & geometry() const
References the geometry node.
const math::Matrix4f & modelViewTransform() const
References the model-view transform.
Renderable & operator=(const Renderable &other)
Assigns from other.
float eyeDistance2() const
Returns the squared distance of geometry to the eye. If it has an associated boundary volume,...
Defines LibCarna::base::math namespace and LIBCARNA_FOR_VECTOR3UI.
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > Matrix4f
Defines matrix.
Definition math.hpp:197
Defines partial order for renderables w.r.t. to their depth in eye space.
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.
Establishes partial order for renderables s.t. geometries with such GeometryFeature instances,...
bool operator()(const Renderable &l, const Renderable &r) const
Returns the result of GeometryFeature::controlsSameVideoResource for the geometry features with role ...