3 #include <osg/Geometry>
5 #include <osg/ArrayDispatchers>
6 #include <osg/PrimitiveSet>
10 #include <osg/ClearNode>
11 #include <osgViewer/Viewer>
13 #include <osgUtil/RenderStage>
14 #include <osg/PolygonOffset>
15 #include <osg/BlendFunc>
16 #include <osg/BlendEquation>
23 namespace osgCloudyDay
36 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
38 osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*
>(nv);
39 osg::ref_ptr<osg::Geode> geometry =
dynamic_cast<osg::Geode*
> (node);
43 osg::Matrixd view(cv->getCurrentCamera()->getViewMatrix());
44 osg::Matrixd invViewMatrix = osg::Matrixd::inverse(view);
45 osg::Matrixd modelview(*cv->getModelViewMatrix());
46 osg::Matrixd model = modelview*invViewMatrix;
47 osg::Matrixd proj(cv->getCurrentCamera()->getProjectionMatrix());
49 geometry->getOrCreateStateSet()->getUniform(
"ModelMatrix")->set(model);
50 geometry->getOrCreateStateSet()->getUniform(
"ViewMatrix")->set(view);
51 geometry->getOrCreateStateSet()->getUniform(
"ProjectionMatrix")->set(proj);
76 static void CreateTexture();
77 static void CreateShader();
78 static void SetDefinitionOfTerrain(osg::Texture* definition);
79 static void SetHeightofTerrain(osg::Texture* heightmap);
81 static osg::ref_ptr<osg::Program> m_forestProg;
82 static osg::ref_ptr<osg::Texture2D> tex_tree;
83 static float* heightmap_data;
84 static osg::Vec4* definition_data;
85 static int heightmap_height;
86 static int heightmap_width;
88 osg::Geode* GetGeode();
92 void SetUniforms(osg::ref_ptr<osg::StateSet> nodess4);
94 osg::ref_ptr<osg::Geode> geode;
95 osg::ref_ptr<osg::Geometry> geometry;
96 osg::ref_ptr<osg::Vec3Array> m_vertices;
97 osg::ref_ptr<osg::UIntArray> m_indices;