vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OSGCloudWrap.h
Go to the documentation of this file.
1 
9 #ifndef _VRECKO_CLOUDS_OSGCLOUDWRAP_H
10 #define _VRECKO_CLOUDS_OSGCLOUDWRAP_H
11 
12 //#include <osg/Drawable>
13 
14 #include "CloudsManager.h"
15 
20 class CloudDataType : public osg::Referenced
21 {
22  private:
23  // Attributes storing information from the osg::Camera
24  osg::Vec3f cameraPos, cameraView, cameraUp;
25  public:
26 
34  void setCameraData(const osg::Vec3f& cameraPos, const osg::Vec3f& cameraView, const osg::Vec3f& cameraUp)
35  {
36  this->cameraPos = cameraPos;
37  this->cameraView = cameraView;
38  this->cameraUp = cameraUp;
39  }
40 
45  osg::Vec3f getCameraPos(void) { return osg::Vec3f(cameraPos.x(), cameraPos.y(), cameraPos.z()); }
50  osg::Vec3f getCameraView(void) { return osg::Vec3f(cameraView.x(), cameraView.y(), cameraView.z()); }
55  osg::Vec3f getCameraUp(void) { return osg::Vec3f(cameraUp.x(), cameraUp.y(), cameraUp.z()); }
56 };
57 
63 struct AllCloudsUpdateCallBack : public osg::Camera::DrawCallback
64 {
65  // Attributes
66  osg::ref_ptr<CloudDataType> cloudData;
67 
68  // Methods
70  AllCloudsUpdateCallBack(osg::ref_ptr<CloudDataType> data) : cloudData(data) {}
71  AllCloudsUpdateCallBack(const AllCloudsUpdateCallBack&, const osg::CopyOp&) {}
72 
74 
75  virtual void operator() (const osg::Camera& camera) const
76  {
77  if(!cloudData.get())
78  {
79  std::cout << "AllCloudsUpdateCallback dynamic_cast error" << std::endl;
80  //exit(2);
81  return;
82  }
83 
84  // Pass the current view matrix to the clouds
85  Cloud::SetViewMatrix(camera.getViewMatrix());
86 
87  // Call cloud manager update
88  g_Clouds.Update(cloudData->getCameraPos(), cloudData->getCameraView(), cloudData->getCameraUp());
89  }
90 };
91 
92 #endif