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