OpenWalnut
1.2.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
core
graphicsEngine
callbacks
WGEPropertyTransformationCallback.h
1
//---------------------------------------------------------------------------
2
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
7
//
8
// This file is part of OpenWalnut.
9
//
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22
//
23
//---------------------------------------------------------------------------
24
25
#ifndef WGEPROPERTYTRANSFORMATIONCALLBACK_H
26
#define WGEPROPERTYTRANSFORMATIONCALLBACK_H
27
28
#include <osg/Node>
29
#include <osg/TexMat>
30
#include <osg/StateAttribute>
31
#include <osg/MatrixTransform>
32
33
#include "WGECallbackTraits.h"
34
#include "../../common/WProperties.h"
35
#include "../WExportWGE.h"
36
37
/**
38
* TODO(ebaum): write.
39
*/
40
template
<
typename
ParentType = osg::Node,
typename
TargetType = osg::MatrixTransform >
41
class
WGEPropertyTransformationCallback
:
public
WGECallbackTraits
< ParentType >
::CallbackType
42
{
43
public
:
44
45
/**
46
* Default constructor.
47
*
48
* \param prop the property holding the matrix to use.
49
*/
50
explicit
WGEPropertyTransformationCallback
( WPropMatrix4X4 prop );
51
52
/**
53
* Destructor.
54
*/
55
virtual
~WGEPropertyTransformationCallback
();
56
57
/**
58
* This operator gets called by OSG every update cycle. It calls the specified functor.
59
*
60
* \param handled the osg node, stateset or whatever
61
* \param nv the node visitor
62
*/
63
virtual
void
operator()
(
typename
WGECallbackTraits< ParentType >::HandledType
* handled, osg::NodeVisitor* nv );
64
65
protected
:
66
67
private
:
68
69
/**
70
* The property controlling the callback
71
*/
72
WPropMatrix4X4
m_prop
;
73
};
74
75
template
<
typename
ParentType,
typename
TargetType >
76
WGEPropertyTransformationCallback< ParentType, TargetType >::WGEPropertyTransformationCallback
( WPropMatrix4X4 prop ):
77
WGECallbackTraits
< ParentType >::
CallbackType
(),
78
m_prop( prop )
79
{
80
// initialize members
81
}
82
83
template
<
typename
ParentType,
typename
TargetType >
84
WGEPropertyTransformationCallback< ParentType, TargetType >::~WGEPropertyTransformationCallback
()
85
{
86
// cleanup
87
}
88
89
template
<
typename
ParentType,
typename
TargetType >
90
void
WGEPropertyTransformationCallback< ParentType, TargetType >::operator()
(
typename
WGECallbackTraits< ParentType >::HandledType
* handled,
91
osg::NodeVisitor* nv )
92
{
93
TargetType* m =
dynamic_cast<
TargetType*
>
( handled );
94
if
( m )
95
{
96
m->setMatrix( m_prop->get() );
97
}
98
99
WGECallbackTraits< ParentType >::traverse
(
this
, handled, nv );
100
}
101
102
#endif // WGEPROPERTYTRANSFORMATIONCALLBACK_H
103
Generated by
1.8.1.2