Hi Robert

I do all my matrix calculations in the cull, which is renderTraversal. I don't 
understand why the camera matrices shouldn't be correct at this time...



Code:

void EfxTracksPrerenderer::ViewData::cull(osgUtil::CullVisitor* a_cv)
{
  osg::NodePath l_NodePath = a_cv->getNodePath();
  osg::Node* l_Root = l_NodePath.front();

  osg::StateSet* l_StateSet = l_Root->getStateSet();

  osg::Camera* l_MainCamera = a_cv->getCurrentCamera();

  osg::Matrixd l_MainViewMatrix  = 
(*a_cv->getModelViewMatrix());//l_MainCamera->getViewMatrix();
  osg::Matrixd l_MainProjMatrix  = 
(*a_cv->getProjectionMatrix());//l_MainCamera->getProjectionMatrix();


  osg::Matrix l_ViewMatrix;
  osg::Matrix l_ProjMatrix;

  osg::Vec3d eyePos, centerPos, upPos;
  l_MainViewMatrix.getLookAt(eyePos, centerPos, upPos);

  // calculate the eye dir vector
  osg::Vec3 eyeDir = centerPos - eyePos;
  eyeDir.normalize();

  // do post perpspective setup of view and projection matrices
  // here... 

  m_Camera->setProjectionMatrix(l_ProjMatrix);
  m_Camera->setViewMatrix(l_ViewMatrix);

  // compute the matrix which takes a vertex from local coords into tex coords
  // will use this later to specify osg::TexGen..
  osg::Matrix MVP = m_Camera->getViewMatrix() *
                    m_Camera->getProjectionMatrix();

  osg::Matrix MVPT = l_MainCamera->getInverseViewMatrix() *
                     MVP *
                     osg::Matrix::translate(1.0,1.0,1.0) *
                     osg::Matrix::scale(0.5,0.5,0.5);

  m_TextureMatrix = MVPT;

  m_Camera->accept(*a_cv);

}




As you see above, I tried with getCurrentCamera and also getting the matrices 
from the CullVisitior, which gives identical results.

So I kind of don't understand the issue between updateTraversal and 
renderTraversal. I'm probably missing something... I do all my calc in Cull. 
The only potential problem I could imagine is because I have a cull thread and 
a parallel draw thread, and the matrices are not correctly used? I out of 
ideas...[/quote]

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





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

Reply via email to