HI ??? Could you please sign with your name so we know who to address.<br><br>Try moving the light source to under the ShadowedScene node.<br><br>Robert.<br><br><div class="gmail_quote">2009/3/17  <span dir="ltr"><<a href="mailto:tuandoviet@gmail.com">tuandoviet@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">










<div bgcolor="white" background="?ui=2&ik=65bdd505df&view=att&th=1201628b3f696663&attid=0.0.1&disp=emb&zw" link="blue" vlink="purple" style="margin-left: 37.5pt;" lang="EN-US">
<img style="width: 0pt; height: 0pt;" height="0" width="0">

<div>

<p><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">Iím trying to use osgShadow, I read examples on osg
website and try to run this code</span></p>

<p><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">But the shadow appears strangely like this picture:</span></p>

<p><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;"><a href="http://i475.photobucket.com/albums/rr113/tek3D/shadow.jpg" target="_blank">http://i475.photobucket.com/albums/rr113/tek3D/shadow.jpg</a></span></p>


<p><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">Here is the code I tested:</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">int main()</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">{</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† osgViewer::Viewer
viewer;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† osg::ref_ptr<osg::Group>
root = new osg::Group;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†† ††††††† // create
light source.</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† osg::LightSource*
lightsource = new osg::LightSource;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† osg::Light*
light = new osg::Light;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† lightsource->setLight(light);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† light->setDirection(osg::Vec3(0,10,0));</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† light->setPosition(osg::Vec4(0,0,90,1.0f));</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† light->setAmbient(osg::Vec4(0.00f,0.00f,0.08f,1.0f));</span></p>


<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† light->setDiffuse(osg::Vec4(1.0f,1.0f,1.0f,1.0f));</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† root->addChild(lightsource);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† //shadow</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">††† †††††† const int
ReceivesShadowTraversalMask = 0x1;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">††† †††††† const int
CastsShadowTraversalMask = 0x2;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
osg::ref_ptr<osgShadow::ShadowedScene> shadowedScene = new
osgShadow::ShadowedScene;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
shadowedScene->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">††† shadowedScene->setCastsShadowTraversalMask(CastsShadowTraversalMask);</span></p>


<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
shadowedScene->setShadowTechnique(sm.get());</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">††† int mapres = 1024;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
sm->setTextureSize(osg::Vec2s(mapres,mapres));</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† sm->setLight(light);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">††† osg::Node* cessna1
= osgDB::readNodeFile("car68/car68.3DS");</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
cessna1->setNodeMask(CastsShadowTraversalMask);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">††† osg::Node* cessna2
= osgDB::readNodeFile("lai.flt");</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
cessna2->setNodeMask(ReceivesShadowTraversalMask);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
osg::MatrixTransform* positioned = new osg::MatrixTransform;</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† osg::Matrix
mat = osg::Matrix::rotate(2.7, osg::Vec3(0,0,1));</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† positioned->setMatrix(mat*positioned->getMatrix()*osg::Matrix::translate(10,40,2));</span></p>


<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††
positioned->addChild(cessna1);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† </span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† shadowedScene->addChild(positioned);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† shadowedScene->addChild(cessna2);†††
</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† root->addChild(shadowedScene);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† viewer.setSceneData(root);</span></p>

<p style="margin-left: 37.5pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†††††††††† return
viewer.run();</span></p>

<p><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">}</span></p>

<p><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">†</span></p>

<p><span style="font-size: 11pt; font-family: "Times New Roman","serif"; color: windowtext;">Could anyone help me with this problem? Thanks in advance!</span></p>

</div>

</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>