[osg-users] Adding ShadowedScene as a child ?

2010-09-21 Thread Saravanan Sivaprahasam
Hi,

   I'm using osgShadow::ShadowedScene to render shadows using shadowmap. The 
shadows are rendered correctly. As my scene graph gets complex i want to add 
the ShadowedScene as a child to another node as shown below 


Code:

ref_ptrGroup scene (new Group);

//Main light source 
Vec3 lightPosition(0,0,3); 
LightSource* ls = new LightSource;
ls-getLight()-setPosition(Vec4(lightPosition,1));
ls-getLight()-setAmbient(Vec4(0.2,0.2,0.2,1.0));
ls-getLight()-setDiffuse(Vec4(0.6,0.6,0.6,1.0));

//Shadow stuff!!!   
ref_ptrosgShadow::ShadowedScene shadowedScene = new 
osgShadow::ShadowedScene;
ref_ptrosgShadow::ShadowMap sm = new osgShadow::ShadowMap;
shadowedScene-setShadowTechnique(sm.get());
sm-setTextureSize(osg::Vec2s(2048, 2048));
sm-setTextureUnit(1);
sm-setLight(ls);

// Shadowed scene added as a child to scene
scene-addChild(shadowedScene.get());

// Set scene data
viewer.setSceneData(scene.get());





As shown above if i add the shadowedScene to scene and set the scene data to 
scene, the shadows are not getting rendered. If i set the sceneData to 
shadowedScene the shadows are rendered correctly. But the scene graph has some 
other elements such as ODE physics, shaders applied to some nodes etc., are 
getting disabled if i set sceneData to shadowedScene.

   Please provide some suggestions on how to get the shadow effect by by adding 
the shadowedScene as a child


Thank you!

Cheers,
Saravanan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=31885#31885





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Adding ShadowedScene as a child ?

2010-09-21 Thread Ulrich Hertlein
Hi Saravanan,

On 21/09/10 20:04 , Saravanan Sivaprahasam wrote:
 I'm using osgShadow::ShadowedScene to render shadows using shadowmap. The 
 shadows are
 rendered correctly. As my scene graph gets complex i want to add the 
 ShadowedScene as a
 child to another node as shown below
... 
 As shown above if i add the shadowedScene to scene and set the scene data to 
 scene, the
 shadows are not getting rendered. If i set the sceneData to shadowedScene the 
 shadows
 are rendered correctly. But the scene graph has some other elements such as 
 ODE
 physics, shaders applied to some nodes etc., are getting disabled if i set 
 sceneData to
 shadowedScene.

Are you setting your shadow casting/receiving objects to be children of the 
ShadowedScene
node?  Apart from that it shouldn't matter if the ShadowedScene is set as scene 
data
directly or through one or more intermediate children.  (Which can be useful if 
you want
to have objects that are not affected by shadows, such as skydomes, HUDs, etc).

Cheers,
/ulrich
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org