4 #include <osg/Geometry>
6 #include <osg/ArrayDispatchers>
7 #include <osg/PrimitiveSet>
11 #include <osg/ClearNode>
12 #include <osgViewer/Viewer>
14 #include <osgUtil/RenderStage>
15 #include <osg/PolygonOffset>
16 #include <osg/BlendFunc>
17 #include <osg/BlendEquation>
24 namespace osgCloudyDay
37 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
39 osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*
>(nv);
40 osg::ref_ptr<osg::Geode> geometry =
dynamic_cast<osg::Geode*
> (node);
44 osg::Matrixd view(cv->getCurrentCamera()->getViewMatrix());
45 osg::Matrixd invViewMatrix = osg::Matrixd::inverse(view);
46 osg::Matrixd modelview(*cv->getModelViewMatrix());
47 osg::Matrixd model = modelview*invViewMatrix;
48 osg::Matrixd proj(cv->getCurrentCamera()->getProjectionMatrix());
50 geometry->getOrCreateStateSet()->getUniform(
"ModelMatrix")->set(model);
51 geometry->getOrCreateStateSet()->getUniform(
"ViewMatrix")->set(view);
52 geometry->getOrCreateStateSet()->getUniform(
"ProjectionMatrix")->set(proj);
77 static void CreateTexture();
78 static void CreateShader();
79 static void SetDefinitionOfTerrain(osg::Texture* definition);
80 static void SetHeightofTerrain(osg::Texture* heightmap);
82 static osg::ref_ptr<osg::Program> m_grassProg;
83 static osg::ref_ptr<osg::Texture2D> tex_tree;
84 static float* heightmap_data;
85 static osg::Vec4* definition_data;
86 static int heightmap_height;
87 static int heightmap_width;
89 osg::MatrixTransform* GetGeode();
93 void SetUniforms(osg::ref_ptr<osg::StateSet> nodess4);
95 osg::ref_ptr<osg::Geode> geode;
96 osg::ref_ptr<osg::Geometry> geometry;
97 osg::ref_ptr<osg::Vec3Array> m_vertices;
98 osg::ref_ptr<osg::UIntArray> m_indices;
100 osg::ref_ptr<osg::MatrixTransform> trans;