Hi all

I render my scene into a frame buffer object which is attached to the main 
camera. Then I add a post render camera  that renders the scene on a quad. So 
far so good, all is well, the quad fills a quarter of my screen as expected.

Now I wanted to add a Dragger (TabPlaneDragger) to my quad in order to resize 
it with the mouse dynamically. There I'm stuck. I followed the osgManipulator 
example. I have the following issues:

-          When using the TabPlaneDragger, it shows only a horizontal line over 
the rendered quad

-          When using the TabBoxDragger, it shows some dragger handles but they 
don't react.

Is it possible that Draggers cannot handle nested cameras? Is there something 
wrong with my postRenderCamera projection matrix so it cannot map mouse coords?

Hope anybody can help. I attached my code below.

Regards
Daniel


  osg::ref_ptr<osg::Camera> l_RootCamera = a_viewer->getCamera();

  // Create the texture; we'll use this as our color buffer.
  // Note it has no image data; not required.
  osg::Texture2D* tex = new osg::Texture2D;
  tex->setTextureWidth( winW );
  tex->setTextureHeight( winH );
  tex->setInternalFormat( GL_RGBA );
  tex->setBorderWidth( 0 );
  tex->setFilter( osg::Texture::MIN_FILTER, osg::Texture::NEAREST );
  tex->setFilter( osg::Texture::MAG_FILTER, osg::Texture::NEAREST );

  // Attach the texture to the camera. Tell it to use multisampling.
  // Internally, OSG allocates a multisampled renderbuffer, renders to it,
  // and at the end of the frame performs a BlitFramebuffer into our texture.
  l_RootCamera->attach( osg::Camera::COLOR_BUFFER0, tex, 0, 0, false, 8, 8 );
  l_RootCamera->setRenderTargetImplementation( 
osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::FRAME_BUFFER );

  // Configure postRenderCamera to draw fullscreen textured quad
  osg::ref_ptr< osg::Camera > postRenderCamera( new osg::Camera );
  postRenderCamera->setClearColor( osg::Vec4( 0., 1., 0., 1. ) ); // should 
never see this.
  postRenderCamera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER, 
osg::Camera::FRAME_BUFFER );

  postRenderCamera->setReferenceFrame( osg::Camera::ABSOLUTE_RF );
  postRenderCamera->setRenderOrder( osg::Camera::POST_RENDER );
  postRenderCamera->setViewMatrix( osg::Matrixd::identity() );
  postRenderCamera->setProjectionMatrix( osg::Matrixd::identity() );

  // create the quad filling the lower left quarter of the screen
  osg::Geode* geode( new osg::Geode );
  geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3( -1,-1,0 ), 
osg::Vec3( 1,0,0 ), osg::Vec3( 0,1,0 ) ) );
  geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, tex, 
osg::StateAttribute::ON );
  geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF 
);
  geode->setName("Grid");

// the following code is more or less copied from the osgManipulator example
  geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);

  osg::MatrixTransform* selection = new osg::MatrixTransform;
  selection->addChild(geode);

  osgManipulator::TabPlaneDragger* dragger = new 
osgManipulator::TabPlaneDragger();
  dragger->setupDefaultGeometry();

  float scale = geode->getBound().radius() * 1.6;
  dragger->setMatrix(osg::Matrix::scale(scale, scale, scale) *
                     osg::Matrix::translate(geode->getBound().center()));

  dragger->addTransformUpdating(selection);
  dragger->setHandleEvents(true);

//  dragger->setActivationModKeyMask(osgGA::GUIEventAdapter::MODKEY_CTRL);
//  dragger->setActivationKeyEvent('a');

  osg::Group* root = new osg::Group;
  root->addChild(selection);
  root->addChild(dragger);

  postRenderCamera->addChild(root);

  a_viewer->getSceneData()->asGroup()->addChild(postRenderCamera.get());
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to