Page 1 of 1

Access to camera matrices without touching the driver's?

Posted: Thu Jul 26, 2012 11:41 am
by hendu
In order to do some old-fashioned matrix wrangling, I have some non-active cameras.

Now, I need to set their position and target, and then get their projection and view matrices. But after calling setPosition or setTarget those matrices aren't updated; that only happens in render().


But, render also uploads those matrices to the driver, which I don't want. I'm going to pass them as a shader uniform, without disturbing the active cam's rendering.

Now, I could call thiscam->render(); activecam->render();, but that would cause unneeded state changes. So I propose a public call updateMatrices() for cameras that does everything that render does except upload matrices to the driver.

Re: Access to camera matrices without touching the driver's?

Posted: Thu Jul 26, 2012 1:49 pm
by hybrid
I don't think that the matrices should be uploaded in case the camera is not active. Actually, I doubt that they are uploaded in those cases. As this would introduce major problems in case more than one camera is part of the scene manager. After all, the render calls would traverse these cams as well. So I guess cam->render would be correct already now.

Re: Access to camera matrices without touching the driver's?

Posted: Thu Jul 26, 2012 5:26 pm
by hendu
From render():

Code: Select all

       video::IVideoDriver* driver = SceneManager->getVideoDriver();
        if ( driver)
        {
                driver->setTransform(video::ETS_PROJECTION, ViewArea.getTransform ( video::ETS_PROJECTION) );
                driver->setTransform(video::ETS_VIEW, ViewArea.getTransform ( video::ETS_VIEW) );
        }
 
After all, the render calls would traverse these cams as well. So I guess cam->render would be correct already now.
No, that's due to the children relationship.

If one calls render() on a camera, it will always upload those if a driver exists. There is no check for whether it's the active camera.

I wouldn't add such a check either, because someone may want to render with a non-active camera.

Re: Access to camera matrices without touching the driver's?

Posted: Sat Jul 28, 2012 11:48 am
by hendu
Patch posted at https://sourceforge.net/tracker/?func=d ... tid=540678

This is confirmed needed and working by the skydome demo that's been adequately publicized lately here by some weird dude ;)