00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef WGEPROPERTYTRANSFORMATIONCALLBACK_H
00026 #define WGEPROPERTYTRANSFORMATIONCALLBACK_H
00027
00028 #include <osg/Node>
00029 #include <osg/TexMat>
00030 #include <osg/StateAttribute>
00031 #include <osg/MatrixTransform>
00032
00033 #include "WGECallbackTraits.h"
00034 #include "../../common/WProperties.h"
00035 #include "../WExportWGE.h"
00036
00037
00038
00039
00040 template < typename ParentType = osg::Node, typename TargetType = osg::MatrixTransform >
00041 class WGEPropertyTransformationCallback: public WGECallbackTraits< ParentType >::CallbackType
00042 {
00043 public:
00044
00045
00046
00047
00048
00049
00050 explicit WGEPropertyTransformationCallback( WPropMatrix4X4 prop );
00051
00052
00053
00054
00055 virtual ~WGEPropertyTransformationCallback();
00056
00057
00058
00059
00060
00061
00062
00063 virtual void operator()( typename WGECallbackTraits< ParentType >::HandledType* handled, osg::NodeVisitor* nv );
00064
00065 protected:
00066
00067 private:
00068
00069
00070
00071
00072 WPropMatrix4X4 m_prop;
00073 };
00074
00075 template < typename ParentType, typename TargetType >
00076 WGEPropertyTransformationCallback< ParentType, TargetType >::WGEPropertyTransformationCallback( WPropMatrix4X4 prop ):
00077 WGECallbackTraits< ParentType >::CallbackType(),
00078 m_prop( prop )
00079 {
00080
00081 }
00082
00083 template < typename ParentType, typename TargetType >
00084 WGEPropertyTransformationCallback< ParentType, TargetType >::~WGEPropertyTransformationCallback()
00085 {
00086
00087 }
00088
00089 template < typename ParentType, typename TargetType >
00090 void WGEPropertyTransformationCallback< ParentType, TargetType >::operator()( typename WGECallbackTraits< ParentType >::HandledType* handled,
00091 osg::NodeVisitor* nv )
00092 {
00093 TargetType* m = dynamic_cast< TargetType* >( handled );
00094 if( m )
00095 {
00096 m->setMatrix( m_prop->get() );
00097 }
00098
00099 WGECallbackTraits< ParentType >::traverse( this, handled, nv );
00100 }
00101
00102 #endif // WGEPROPERTYTRANSFORMATIONCALLBACK_H
00103