Hello everyone!
I am using line segment intersectors to do ray-tracing. i trace rays from the
window into the scene and then the consequent rays. This will be a no-time
answer for those fluent with scene graph, i'm sure.
i have a scene and a osgViewer::View, in which the scene is displayed. i use
the camera from the View to accept the line segment intersectors. The camera
becomes the root of the scene:
Code:
_tracer->getScene()->accept(intersectionVisitor);
where the scene is actually the camera retreived from the osgViewer::View this
way
Code:
wm->getSceneView()->getCamera()
With this setup, i'm getting pretty intersections and this part works fine.
However, i need the rendering camera to stay fixed while the View's camera
moves around.
So i tried making a copy of the View's camera when the tracer is initialized,
but i'm getting black screen computed in a fraction of the computation time
needed for the correct picture. I thought there was some problem with matrices,
but i compared them and they appear to be the same.
With this camera
Code:
wm->getSceneView()->getCamera()// this is passed to the tracer object as a
_masterCamera
I'm getting correct rendering results. It is the _masterCamera in the tracer
object. Now, I tried these 3 approaches: (this is a code snippet from the
tracer object's constructor)
Code:
// 1)
_renderCamera = dynamic_cast<osg::Camera*>
(_masterCamera->clone(osg::CopyOp::DEEP_COPY_ALL)); // this really should be
working
// 2)
_renderCamera = dynamic_cast<osg::Camera*>
(_masterCamera->clone(osg::CopyOp::SHALLOW_COPY));
// 3)
_renderCamera = new osg::Camera;
_renderCamera->addChild(_scene);
before every rendering, updateCamera() is called, it copies the matrices from
the _master camera into the _render camera
Code:
_renderCamera->setViewMatrix(_masterCamera->getViewMatrix());
_renderCamera->setProjectionMatrix(_masterCamera->getProjectionMatrix());
Doing this check for matrix equity
Code:
if(_masterCamera->getViewMatrix() == _renderCamera->getViewMatrix() &&
_masterCamera->getProjectionMatrix() == _renderCamera->getProjectionMatrix()){
std::cout << "equal matrices" << std::endl;
}
I get the string printed out every time i start rendering, meaning the matrices
should be equal.
So why am I not getting any result ? neither of the three approaches work. if
the problem was having two root cameras, why does not the DEEP copy work, at
least ? i am not concerned about memory usage for now. Is there a special way I
have to copy the scene or the camera?
also, please, anyone looking at this thread, please take a look at my posts in
thread number 10149 (http://forum.openscenegraph.org/viewtopic.php?t=10149), I
really need these issues solved this week.
I appreciate any suggestions.
Thank you very much in advance.
Cheers,
Andrey
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46844#46844
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org