OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 #include "../WExportWGE.h"
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 WGE_EXPORT WGEShaderAnimationCallback: public osg::Uniform::Callback
40 {
41 public:
42 
43  /**
44  * Default constructor. Creates a new instance and sets the precision
45  *
46  * \param ticksPerSecond the uniform will increase by 1 every hundredth second if =100, every 10th second if =10 and every second if =1.
47  */
48  explicit WGEShaderAnimationCallback( int ticksPerSecond = 100 );
49 
50  /**
51  * Destructor.
52  */
53  virtual ~WGEShaderAnimationCallback();
54 
55  /**
56  * Operator called on uniform update.
57  *
58  * \param uniform the uniform to update
59  * \param nv the visitor.
60  */
61  virtual void operator() ( osg::Uniform* uniform, osg::NodeVisitor* nv );
62 
63 protected:
64 
65  /**
66  * Timer that stops the time hopefully OS independent
67  */
68  boost::posix_time::ptime m_start;
69 
70  /**
71  * Number of ticks to count per second.
72  */
74 
75  /**
76  * Ratio between milliseconds and m_ticksPerSec
77  */
79 
80 private:
81 };
82 
83 #endif // WGESHADERANIMATIONCALLBACK_H
84