Hello, OpenSG friends,

as i wrote a couple of days ago, I am working on a cave application that
needs tracking of the head position.

Some of the first answers pointed me in the direction of the
ProjectionCameraDecorator so I gave a look at the threads concerning the use
of this decorator. I've made an hasty integration of the
ProjectionCameraDecorator in my code, but I must be missing something as the
head isn't tracked at all (although at least the cave viewports and cameras
are working :) ).

Here is how I set up the decorators:


For (every cave face)
{

        osg::Pnt3f screenUpperRight;
        osg::Pnt3f screenUpperLeft;
        osg::Pnt3f screenLowerLeft;
        osg::Pnt3f screenLowerRight;

... some code setting up the screen dimensions

... some more code setting up the cave face main camera

        If (face==FRONT_CAVE_FACE)
        {
              m_pUserBeaconNode = osg::Node::create ();
            osg::TransformPtr tran = osg::Transform::create ();

            beginEditCP (m_pUserBeaconNode, osg::Node::CoreFieldMask);
                m_pUserBeaconNode->setCore (tran);
            endEditCP (m_pUserBeaconNode, osg::Node::CoreFieldMask);

                beginEditCP(main_beacon,osg::Node::ChildrenFieldMask);
                        main_beacon->addChild (m_pUserBeaconNode);
                endEditCP(main_beacon,osg::Node::ChildrenFieldMask);
        }

        // stereo camera decorators creation
        osg::ProjectionCameraDecoratorPtr leftCamera=
osg::ProjectionCameraDecorator::create();
        addRefCP (leftCamera) ;
        beginEditCP(leftCamera);
        {
                leftCamera->setDecoratee(camera);
                leftCamera->setEyeSeparation(0.5);
                //leftCamera->setZeroParallaxDistance(15);
            leftCamera->getSurface ().push_back (screenUpperRight);
            leftCamera->getSurface ().push_back (screenUpperLeft);
            leftCamera->getSurface ().push_back (screenLowerLeft);
            leftCamera->getSurface ().push_back (screenLowerRight);
                leftCamera->setLeftEye(true);
            leftCamera->setUser (m_pUserBeaconNode);
        }
        endEditCP(leftCamera);

        //right
        osg::ProjectionCameraDecoratorPtr rightCamera =
osg::ProjectionCameraDecorator::create();
        addRefCP( rightCamera );
        beginEditCP(rightCamera);
        {
                rightCamera->setDecoratee(camera);
                rightCamera->setEyeSeparation(0.5);
                //rightCamera->setZeroParallaxDistance(15);
            rightCamera->getSurface ().push_back (screenUpperRight);
            rightCamera->getSurface ().push_back (screenUpperLeft);
            rightCamera->getSurface ().push_back (screenLowerLeft);
            rightCamera->getSurface ().push_back (screenLowerRight);
                
                rightCamera->setLeftEye(false);
            rightCamera->setUser (m_pUserBeaconNode);
        }
        endEditCP(rightCamera);

}

And this is all for the setup. As for the tracking, I am just doing some
tests, so I just pass to the user node some simple transformations:

void updateUserTransform ()
{
    osg::Matrix m;
    m.setTranslate (m_fPosX, m_fPosY, m_fPosZ);

    beginEditCP (m_pUserTransformCore, osg::Transform::MatrixFieldMask);
        m_pUserTransformCore->setMatrix (m);
    endEditCP (m_pUserTransformCore, osg::Transform::MatrixFieldMask);
  
    drawFrame ();
}


The problem is that when I call drawFrame, the camera does not change at
all. Probably I am missing something important, 
But even looking at the doxigen files I can't figure it out what it could be

Thanks for any hint,
E.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to