vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MTMatrixTransform.h
Go to the documentation of this file.
1 #ifndef MTMATRIXTRANSFORM_H
2 #define MTMATRIXTRANSFORM_H
3 
4 
5 // MTMatrixTransform = Multi-threaded Matrix Transform
6 // This ability stores a copy of the transformation matrix that is present
7 // in every EnvironmentObject. The copy of matrix present in the ability
8 // is possible to update from any thread and as often as necessary (hundreds/thousands
9 // timer per frame).
10 // The changes are automatically transferred to the main matrix once per frame.
11 
12 
13 #include <vrecko/Ability.h>
14 #include <vrecko/MTLock.h>
15 #include <vrecko/IOPins.h>
16 #include <osg/Group>
17 
18 
19 using namespace vrecko;
20 
21 
22 namespace base
23 {
24 
25 #ifdef AP_BASE_EXPORTS
26  #define MTMATRIXTRANSFORM_IMP_EXP __declspec(dllexport)
27 #else
28  #define MTMATRIXTRANSFORM_IMP_EXP __declspec(dllimport)
29 #endif
30 
31 
33  {
34  public:
36  virtual ~MTMatrixTransform();
37 
38  virtual void preInitialize();
39  virtual void update();
40  // Runs once per frame (LATE in the frame) and synchronizes main object transformation
41  // with the local matrix copy.
42 
43  bool getMatrix(osg::Matrix *pMatrix);
44  void setMatrix(osg::Matrix *newMatrix);
45 
46  bool getWorldTransformation(osg::Matrix *pMatrix);
47  // calculates the world transformation using the stored matrix (instead of the object main transformation)
48 
49  protected:
51  osg::Matrix matrix;
52  bool bRetrieved; // matrix already retrieved from the owner object?
53  bool bUpdated; // a call to local setMatrix() occured, so we should update
54  // the main object transformation at the end of the frame?
55 
57 
60  };
61 }
62 
63 #endif
64