Hello Johannes,

On 05/23/2011 07:52 AM, Johannes Brunen wrote:
> I have a scene which I render into a viewport with a perspective camera.
> Now I would like to render the same scene from another view point into a
> different viewport but using an orthographic projection. I have tried to
> use the MatrixCameraDecoratror class but I'm unable to get it
> functioning.
>
> What is the best way to solve such a problem?

hmm, I have a feeling there's something missing in your problem 
description, because from what you've written the two views you want to 
render only share the scene and for that you can simply set up a 
viewport with the perspective camera and another one with a orthographic 
camera...

> I have used the MatrixCameraDecorator to render the scene into another
> viewport in perspective view with some translation and rotation
> modification from the decoratee camera.

ah, so the second (ortho) camera is at a fixed offset from the first? 
You could make the ortho camera's beacon a child of the first and give 
it a Transform core to hold the fixed offset.

> That does work fine. Then I
> thought that I could setup an orthographic projection matrix and modify
> the decorator projection with the functions setPreProjection and
> setPostProjection:
>
> Camera* camera = _view->getCamera();
>
> Matrix ortho;
> Real32 vs = _view->getPort()->getPixelWidth() / 2;
> Real32 hs = _view->getPort()->getPixelHeight() / 2;
>
> bool ret = MatrixOrthogonal(ortho, -hs, hs, -vs, vs, camera->getNear(),
> camera->getFar());
>
> Matrix projection, inv_proj;
> camera->getProjection(projection, _view->getPort()->getPixelWidth(),
> _view->getPort()->getPixelHeight());
> ret = inv_proj.invertFrom(projection);
>
> MatrixCameraDecoratorUnrecPtr decorator =
> MatrixCameraDecorator::create();
> decorator->setDecoratee(camera);
>
> decorator->setPreProjection(inv_proj);
> decorator->setPostProjection(ortho);
>
> This does not work...

this looks ok to me and offhand I have no idea what might be going wrong.

        Cheers,
                Carsten

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to