2 #include "CloudGeometry.h"
3 #include "CloudLayerUpdate.h"
8 #include "CloudLayerUpdate.h"
9 #include "CloudLayerState.h"
11 #define SHADOW_MAPPING
13 namespace osgCloudyDay
18 class project :
public osg::Uniform::Callback
149 CT_StratoCumulusGenerator,
153 CT_AltCumulusGenerator,
167 WCU_DirectionalColor,
189 osg::ref_ptr<osg::Geometry>
InsertCloud(WangCloud* cloud,
int layerID);
196 void AddCloud(WangCloud* cloud,
int layerID);
209 void AddLayer(
int layerID,
int layer);
232 CloudLayerUpdate* cloud_layer_update;
263 static void SetStates(CloudLayerState* state);
293 static float timeOfDay;
296 static osg::Vec3 ambientLight_h0;
297 static osg::Vec3 ambientLight_h1;
298 static osg::Vec3 ambientLight_t0;
299 static osg::Vec3 ambientLight_t1;
300 static osg::Matrix3 directionalColors;
302 static osg::Vec3 sunLightColor;
304 static osg::ref_ptr<osg::Program> cloudShadowMapProg;
305 static osg::ref_ptr<osg::Program> cloudBlurHoriProg;
306 static osg::ref_ptr<osg::Program> cloudBlurVertProg;
307 static osg::ref_ptr<osg::Program> cloudBlurLinearHoriProg;
308 static osg::ref_ptr<osg::Program> cloudBlurLinearVertProg;
309 static osg::ref_ptr<osg::Program> cloudProg;
310 static osg::ref_ptr<osg::Program> cloudShadowProg;
311 static osg::ref_ptr<osg::Texture2D> tex_clouds;
313 static osg::FrameBufferObject* fbo_viewer;
314 static osg::FrameBufferObject* fbo_light;
317 osg::ref_ptr<osg::Uniform> project_lightuniform;
318 osg::ref_ptr<osg::Uniform> modelViewMatrix_lightuniform;
319 osg::ref_ptr<osg::Uniform> viewMatrix_lightuniform;
320 osg::ref_ptr<osg::Uniform> viewMatrixInv_lightuniform;
321 osg::ref_ptr<osg::Uniform> projectuniform;
322 osg::ref_ptr<osg::Uniform> modelViewMatrixuniform;
323 osg::ref_ptr<osg::Uniform> viewMatrixuniform;
324 osg::ref_ptr<osg::Uniform> viewMatrixInvuniform;
326 osg::ref_ptr<osg::Geode> quadBillBoard;
327 osg::ref_ptr<osg::StateSet> nodess4;
329 osg::ref_ptr<osg::Vec3Array> m_cloudcenter;
331 osg::ref_ptr<osg::IntArray> m_start_indices;
333 bool setup_attribute;
334 osg::ref_ptr<osg::Geode> geode;
336 #ifdef SHADOW_MAPPING
337 osg::ref_ptr<osgCloudyDay::CloudGeometry> geometry;
339 osg::ref_ptr<osg::Geometry> geometry;
363 osg::Geometry*
createSphere(osg::Vec3 middlePoint,
float radius,
int vpr);
371 std::vector<WangCloud*> m_clouds;
379 static bool m_backtofront;
380 static bool m_backtofront_old;
396 static osg::ref_ptr<osg::Texture2D> fbo_light_texture;
397 static osg::ref_ptr<osg::Texture2D> fbo_cloud_texture;
399 static osg::FrameBufferObject* fbo_cloud_viewer;
400 static osg::FrameBufferObject* fbo_shadow;
401 static osg::FrameBufferObject* fbo_vert_linear_blur;
402 static osg::FrameBufferObject* fbo_hori_linear_blur;
403 static osg::FrameBufferObject* fbo_vert_blur;
404 static osg::FrameBufferObject* fbo_hori_blur;
405 static osg::FrameBufferObject* fbo_hori_blur2;
410 static osg::ref_ptr<osg::Camera> m_lightCloudCamera;
418 void AddDrawElementsPoint(std::vector<unsigned int> index,
unsigned int start,
unsigned int count,
int k);
428 inline float frand();
441 osg::Vec2 m_numOfClouds;
442 std::vector<int> sequence;
444 unsigned int m_num_indices;
446 std::vector<unsigned int> m_layerToNumberCloud;
447 std::vector<unsigned int> m_layerToCloudType;
448 std::vector<unsigned int> m_layerToCloudLayerID;
449 osg::ref_ptr<osg::IntArray> m_startLayerIndex;
451 osg::ref_ptr<osg::Vec3Array> m_vertices;
452 osg::ref_ptr<osg::Vec3Array> m_bb_min;
453 osg::ref_ptr<osg::Vec3Array> m_bb_max;
454 osg::ref_ptr<osg::Vec4Array> m_rotation;
455 osg::ref_ptr<osg::Vec4Array> m_center;
456 osg::ref_ptr<osg::Vec4Array> m_ids;
457 osg::ref_ptr<osg::Vec4Array> m_box_centers;
458 osg::ref_ptr<osg::Vec4Array> m_color;
460 osg::ref_ptr<osg::IntArray> m_numPrimitiveArrays;
462 std::map<int, std::string> m_uniforms;
464 osg::ref_ptr<osg::Vec3Array> m_ambientlight_h;
465 osg::ref_ptr<osg::Vec3Array> m_ambientlight_t;
466 osg::ref_ptr<osg::Vec3Array> m_diffuselight;
468 static CloudLayerState* m_CloudLayerState;