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.
Access to camera matrices without touching the driver's?
-
- 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?
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?
From render():
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.
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) );
}
No, that's due to the children relationship.After all, the render calls would traverse these cams as well. So I guess cam->render would be correct already now.
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?
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
This is confirmed needed and working by the skydome demo that's been adequately publicized lately here by some weird dude