Access to camera matrices without touching the driver's?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Access to camera matrices without touching the driver's?

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

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

Post 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.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

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

Post 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.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

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

Post 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 ;)
Post Reply