<div dir="ltr">Thanks for reply,<br><br>I have converted terrain model to osg and opened it with text editor. osg file format like below;<br><br>------------------------------------------------------------------------------------------------------<br>
Group {<br> name "db"<br> nodeMask 0xffffffff<br> cullingActive TRUE<br> num_children 1<br> Geode {<br> DataVariance STATIC<br> name "p1_437"<br> nodeMask 0xffffffff<br> cullingActive TRUE<br>
StateSet {<br> UniqueID StateSet_0<br> DataVariance STATIC<br> rendering_hint DEFAULT_BIN<br> renderBinMode INHERIT<br> GL_CULL_FACE ON<br> GL_LIGHTING OFF<br> Material {<br> ColorMode OFF<br>
ambientColor 0.722 0.722 0.729 1<br> diffuseColor 0.918 0.918 0.918 1<br> specularColor 0.137 0.137 0.137 1<br> emissionColor 0 0 0 1<br> shininess 10<br> }<br> CullFace {<br>
UniqueID CullFace_1<br> mode BACK<br> }<br> textureUnit 0 {<br> GL_TEXTURE_2D ON<br> Texture2D {<br> file "Cell 23.rgb"<br> wrap_s REPEAT<br> wrap_t REPEAT<br>
wrap_r CLAMP<br> min_filter LINEAR<br> mag_filter LINEAR<br> maxAnisotropy 1<br> borderColor 0 0 0 0<br> borderWidth 0<br> useHardwareMipMapGeneration TRUE<br>
unRefImageDataAfterApply TRUE<br> internalFormatMode USE_IMAGE_DATA_FORMAT<br> resizeNonPowerOfTwo TRUE<br> }<br> TexEnv {<br> mode MODULATE<br> }<br> }<br> }<br>
num_drawables 1<br> Geometry {<br> DataVariance STATIC<br> useDisplayList TRUE<br> useVertexBufferObjects FALSE<br> PrimitiveSets 1<br> {<br> DrawArrays QUADS 0 1600<br> }<br> ......<br>
.....<br> ......<br> etc.<br>------------------------------------------------------------------------------------------------------<br><br>The TexEnv configuration have MODULATE mode. And I have changed it to GL_MODULATE and GL_LIGHTING OFF to ON but there is no light effect on terrain too. Then I deleted the TexEnv code block from the osg file format then lighting not effect too.<br>
<br>Peter, I added "lightSS->setMode(GL_LIGHTING,osg::StateAttribute::ON);" pattern to my code but there is no change on the state of terrain too.<br><br>Jean, if I write a node visitor for TexEnv, I thing there won't be any change too, because of I have removed the TexEnv pattern from osg file format but there wasn't any change on terrain.<br>
<br>Any idea for lightiing the terrain like other components.<br><br>Thanks for all advices.<br>Best Regards.<br><br>Ümit UZUN<br><br><div class="gmail_quote">2008/7/19 Peter Wraae Marino <<a href="mailto:osghelp@gmail.com">osghelp@gmail.com</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><div>Hi,</div>
<div> </div>
<div>isnt there missing a </div>
<div><b><font color="#000000">setMode</font></b><font color="#990000">(</font> GL_LIGHT1<font color="#990000">,</font> osg<font color="#990000">::</font>StateAttribute<font color="#990000">::</font>ON <font color="#990000">);</font></div>
<div><font color="#990000"></font> </div>
<div><font color="#990000">for your terrain group? (or did I miss something?)</font></div>
<div><font color="#990000"></font> </div>
<div><font color="#990000">Peter</font></div>
<div><font color="#990000"><a href="http://osghelp.com/" target="_blank">http://osghelp.com</a></font></div>
<div><br><br><br></div>
<div class="gmail_quote"><div><div></div><div class="Wj3C7c">On Sat, Jul 19, 2008 at 12:39 AM, Ümit Uzun <<a href="mailto:umituzun84@gmail.com" target="_blank">umituzun84@gmail.com</a>> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
<div dir="ltr">Hi All,<br><br>I have an simple question about light the terrain model problem. I have added two sphere(osg::Sphere) and one terrain(JoeDirt.flt) to the scene. I am trying to effect the components of scene with green light. Although green light could effected two of sphere, couldn't get<span style="background-color: rgb(255, 0, 0);"></span> success on the terrain model. What can I do to effect the terrain with green light? I have tried this code block;<br>
<br>--------------------------------------------------------------------------------------------------------------------------------------------------<br><b>int main()<br>{<br> osgViewer::Viewer viewer;<br> osg::ref_ptr<osg::Group> root (new osg::Group);<br>
<br> osg::ref_ptr<osg::MatrixTransform> terrainScaleMAT (new osg::MatrixTransform);<br> osg::Matrix terrainScaleMatrix;<br> terrainScaleMatrix.makeScale(0.05f,0.05f,0.03f);<br> <br> //Lighting code<br>
osg::ref_ptr<osg::Group> lightGroup (new osg::Group);<br> osg::ref_ptr<osg::StateSet> lightSS (root->getOrCreateStateSet());<br> osg::ref_ptr<osg::LightSource> lightSource1 = new osg::LightSource;<br>
<br> // create a local light.<br> osg::Vec4f lightPosition (osg::Vec4f(0.0,0.0,3.0,1.0f));<br> osg::ref_ptr<osg::Light> myLight = new osg::Light;<br> myLight->setLightNum(1);<br> myLight->setPosition(lightPosition);<br>
myLight->setAmbient(osg::Vec4(0.2f,0.2f,0.2f,1.0f));<br> myLight->setDiffuse(osg::Vec4(0.1f,0.4f,0.1f,1.0f));<br> myLight->setConstantAttenuation(1.0f);<br> lightSource1->setLight(myLight.get());<br>
<br> lightSource1->setLocalStateSetModes(osg::StateAttribute::ON); <br> lightSource1->setStateSetModes(*lightSS,osg::StateAttribute::ON); <br> <br> lightGroup->addChild(lightSource1.get());<br> <br>
//Light markers: small spheres<br> osg::ref_ptr<osg::Geode> lightMarkerGeode (new osg::Geode);<br> lightMarkerGeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3f(-5.0f,-2.0f,3.0f),0.5f)));<br>
<br> //lightMarkerGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);<br> <br> //Second light marker<br> lightMarkerGeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3f(2.0f,-1.0f,3.0f),0.5f)));<br>
<br> //Loading the terrain node<br> osg::ref_ptr<osg::Node> terrainnode (osgDB::readNodeFile("JoeDirt.flt"));<br> terrainScaleMAT->addChild(terrainnode.get());<br> terrainScaleMAT->setMatrix(terrainScaleMatrix);<br>
<br> //adding the terrain node to the root node<br> root->addChild(terrainScaleMAT.get());<br> <br> //lighting code<br> root->addChild(lightGroup.get());<br> //Adding the light marker geode<br>
root->addChild(lightMarkerGeode.get());<br><br> // add the state manipulator<br> viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );<br> <br> viewer.setSceneData( root.get() );<br>
<br> return (viewer.run());<br>}</b><br>--------------------------------------------------------------------------------------------------------------------------------------------------<br></div><br></div></div><div class="Ih2E3d">
_______________________________________________<br>
osg-users mailing list<br><a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br><a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
<br></div></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>Regards,<br>Peter Wraae Marino<br><br><a href="http://www.osghelp.com" target="_blank">www.osghelp.com</a> - OpenSceneGraph support site </font></div>
<br>_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
<br></blockquote></div><br></div>