Re: [osg-users] Shadows: Application crashing at viewer.renderingTraversals()

2009-05-07 Thread Rodrigo Salvador
Hi, Paul

I don't know if it can help, but it's a tip. I'm trying to work with shadows 
too, without sucess yet. My project was crashing before I added the following 
line, founded in osgshadow example:

sm->setTextureSize(osg::Vec2s(1024,1024));

"sm" indicates the technique I'm using, ShadowMap. With this command, it stops 
breaking. But I still with no shadows in the scene, this may be another mistake.

Hope it helps.

Rodrigo Salvador

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





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


Re: [osg-users] Shadows: Application crashing at viewer.renderingTraversals()

2009-05-02 Thread Gordon Tomlinson
Sorry all the psychics are on vacation at this time


__
Gordon Tomlinson 

gor...@gordontomlinson.com
IM: gordon3db...@3dscenegraph.com
www.vis-sim.com www.gordontomlinson.com 

__

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Paul
Sent: Saturday, May 02, 2009 9:39 AM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] Shadows: Application crashing at
viewer.renderingTraversals()

Bump...

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





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

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


Re: [osg-users] Shadows: Application crashing at viewer.renderingTraversals()

2009-05-02 Thread Robert Osfield
On Sat, May 2, 2009 at 2:39 PM, Paul  wrote:
> Bump...

Bang.

Stack trace required.

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


Re: [osg-users] Shadows: Application crashing at viewer.renderingTraversals()

2009-05-02 Thread Paul
Bump...

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





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


[osg-users] Shadows: Application crashing at viewer.renderingTraversals()

2009-04-29 Thread Paul
Hi,

Im trying to add shadows to my scene, code taken from osgshadow example but my 
application crashes when it gets to  viewer.renderingTraversals().

If I dont set the setShadowTechnique then my application does not crash, but i 
obviously don't get shadows either. Ive tried each of the shadow techniques 
without sucess.

Heres my code, can you see any mistakes?
Thank you.
Paul.


Code:
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

static int ReceivesShadowTraversalMask = 0x1;
static int CastsShadowTraversalMask = 0x2;

int main(int argc, char **argv)
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc, argv);

// construct the viewer.
osgViewer::CompositeViewer viewer(arguments);

// Turn on FSAA, makes the lines look better.
//osg::DisplaySettings::instance()->setNumMultiSamples( 4 );

osg::ref_ptr shadowedScene = new 
osgShadow::ShadowedScene;


shadowedScene->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask);
shadowedScene->setCastsShadowTraversalMask(CastsShadowTraversalMask);

osg::ref_ptr sm = new osgShadow::ShadowMap;
shadowedScene->setShadowTechnique(sm.get());
sm->setTextureSize(osg::Vec2s(1024, 1024));

//osg::ref_ptr< osg::Group > root = new osg::Group;
osg::ref_ptr< osg::Node > scene;
scene = osgDB::readNodeFile("cow.osg");

// set up the texture of the base.
osg::StateSet* stateset = new osg::StateSet();
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
if (image)
{
osg::Texture2D* texture = new osg::Texture2D;
texture->setImage(image);
stateset->setTextureAttributeAndModes(0, texture, 
osg::StateAttribute::ON);
}

scene->setStateSet(stateset);

scene->setNodeMask(CastsShadowTraversalMask | 
ReceivesShadowTraversalMask);

osg::Vec4 lightpos;

lightpos.set(0.5f, 0.25f, 0.8f, 0.0f);

osg::ref_ptr ls = new osg::LightSource;

ls->getLight()->setPosition(lightpos);

ls->getLight()->setAmbient(osg::Vec4(0.2, 0.2, 0.2, 1.0));
ls->getLight()->setDiffuse(osg::Vec4(0.8, 0.8, 0.8, 1.0));

osg::ref_ptr sceneTransform = new 
osg::MatrixTransform();
osg::Matrix zTrans = osg::Matrix::translate(0.0f, 0.0f, 0.0f);
sceneTransform->setMatrix(zTrans);
sceneTransform->addChild(scene.get());
shadowedScene->addChild(sceneTransform);

osg::ref_ptr sceneTransform2 = new 
osg::MatrixTransform();
osg::Matrix zTrans2 = osg::Matrix::translate(1.5f, 0.0f, 1.5f);
sceneTransform2->setMatrix(zTrans2);
sceneTransform2->addChild(scene.get());
sceneTransform->addChild(sceneTransform2);

shadowedScene->addChild(ls.get());

osgGA::TrackballManipulator* manipulator;
osgGA::TrackballManipulator* manipulator2;

// Create Editor View
{
osgViewer::Viewer* view = new osgViewer::Viewer();
viewer.addView(view);
osg::Camera* camera = view->getCamera();
camera->setViewport(new osg::Viewport(0, 0, 640, 480));
GLenum buffer = GL_BACK;
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
camera->setClearColor(osg::Vec4(0.0, 0.0, 0.0, 1.0)) ;
camera->setCullingMode(camera->getCullingMode() & 
~osg::CullStack::SMALL_FEATURE_CULLING);
view->setSceneData(shadowedScene.get());
manipulator = new osgGA::TrackballManipulator;
view->setCameraManipulator(manipulator);
manipulator->setHomePosition(osg::Vec3(0, -10, 0), osg::Vec3(0, 
0, 0), osg::Vec3(0, 0, 5));
view->setUpViewInWindow(20, 20, 640, 480);
}

// Create Controls View
{
osgViewer::Viewer* view = new osgViewer::Viewer();
viewer.addView(view);
osg::Camera* camera = view->getCamera();
camera->setViewport(new osg::Viewport(0, 0, 640, 480));
GLenum buffer = GL_BACK;
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
camera->setClearColor(osg::Vec4(0.0, 0.0, 0.0, 1.0)) ;
camera->setCullingMode(camera->getCullingMode() & 
~osg::CullStack::SMALL_FEATURE_CULLING);
view->setSceneData(shadowedScene.get());
manipulator2 = new osgGA::TrackballManipulator;
view->setCameraManipulator(manipulator);
view->setUpViewInWindow(40, 40, 640, 480);
}


viewer.setThreadingModel(osgViewer::CompositeViewer::CullDrawThreadPerContext);

viewer.realize();

while (!viewer.done