OpenWalnut  1.4.0
WGEShaderAnimationCallback.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 WGESHADERANIMATIONCALLBACK_H
26 #define WGESHADERANIMATIONCALLBACK_H
27 
28 #include "stdint.h"
29 
30 #ifndef Q_MOC_RUN
31 #include "boost/date_time/posix_time/posix_time.hpp"
32 #endif
33 
34 #include <osg/Uniform>
35 
36 /**
37  * This is a uniform callback setting the uniform to the current time in milliseconds, hundredth of a second or tenth of a second.
38  */
39 class WGEShaderAnimationCallback: public osg::Uniform::Callback
40 {
41 public:
42  /**
43  * Default constructor. Creates a new instance and sets the precision
44  *
45  * \param ticksPerSecond the uniform will increase by 1 every hundredth second if =100, every 10th second if =10 and every second if =1.
46  */
47  explicit WGEShaderAnimationCallback( int ticksPerSecond = 100 );
48 
49  /**
50  * Destructor.
51  */
53 
54  /**
55  * Operator called on uniform update.
56  *
57  * \param uniform the uniform to update
58  * \param nv the visitor.
59  */
60  virtual void operator() ( osg::Uniform* uniform, osg::NodeVisitor* nv );
61 
62 protected:
63  /**
64  * Timer that stops the time hopefully OS independent
65  */
66  boost::posix_time::ptime m_start;
67 
68  /**
69  * Number of ticks to count per second.
70  */
72 
73  /**
74  * Ratio between milliseconds and m_ticksPerSec
75  */
77 
78 private:
79 };
80 
81 #endif // WGESHADERANIMATIONCALLBACK_H
82 
double m_tickMillisecRatio
Ratio between milliseconds and m_ticksPerSec.
virtual void operator()(osg::Uniform *uniform, osg::NodeVisitor *nv)
Operator called on uniform update.
virtual ~WGEShaderAnimationCallback()
Destructor.
boost::posix_time::ptime m_start
Timer that stops the time hopefully OS independent.
WGEShaderAnimationCallback(int ticksPerSecond=100)
Default constructor.
This is a uniform callback setting the uniform to the current time in milliseconds, hundredth of a second or tenth of a second.
int m_ticksPerSec
Number of ticks to count per second.