Camera.enableReflection() and SceneManager.setRelativeOrigin()

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
Hrenli
Halfling
Posts: 62
Joined: Tue Jun 14, 2016 12:26 pm
x 8

Camera.enableReflection() and SceneManager.setRelativeOrigin()

Post by Hrenli » Fri Dec 07, 2018 3:10 pm

Hi guys,

I've got some really strange behavior of the two functions mentioned in the subject. I have quite big scene and (mostly for convenience reasons) I use SceneManager.setRelativeOrigin() call to keep everything "in place" (without it character eyes start to pop out of sockets when I am a few km from origin, the usual stuff). And I was playing with reflection on my water lately and got really awkward results in what is rendered into reflected camera (I've created a camera which sits on the same sceneNode as main camera and I call Camera.enableReflection() with horizontal plane).

I've tried quite a few things trying to figure out WTF is wrong until I decided to comment out SceneManager.serRelativeOrigin() call. Everything immediately starting to work as intended (apart from all the precision things caused by the distance from the origin).

So, any ideas what is wrong? Something in the Camera.enableReflection() or it's me doing something stupid? And what are viable workarounds? Thirst thing I want to try is to setup reflection camera myself (but for that I have to figure out the math behind calculating reflected orientation which I was lazy to do when started and then I found the reflection functionality in Ogre's camera). Another option would be to change my approach to the world origin and move the world around the character without the need for SceneManager.setRelativeOrigin() call... Anything else?
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3917
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 167
Contact:

Re: Camera.enableReflection() and SceneManager.setRelativeOrigin()

Post by dark_sylinc » Fri Dec 07, 2018 6:20 pm

This reminds me there is a PR pending for review at https://bitbucket.org/sinbad/ogre/pull-requests/791

Could you try it and tell me how it goes for you? If all is ok I'll just merge it.
0 x

Hrenli
Halfling
Posts: 62
Joined: Tue Jun 14, 2016 12:26 pm
x 8

Re: Camera.enableReflection() and SceneManager.setRelativeOrigin()

Post by Hrenli » Fri Dec 07, 2018 8:18 pm

Well, I am not using PlanarReflections class, I just use similar approach with one global plane without extra clipping and stuff. But I see the idea and will try it with my setup first...
0 x

Hrenli
Halfling
Posts: 62
Joined: Tue Jun 14, 2016 12:26 pm
x 8

Re: Camera.enableReflection() and SceneManager.setRelativeOrigin()

Post by Hrenli » Fri Dec 07, 2018 8:39 pm

And it actually works. I've just tried a quick fix following the same pattern as in the PR and changed this:

Code: Select all

reflectionCamera->enableReflection(Ogre::Plane(Ogre::Vector3::UNIT_Y, 0));
to this:

Code: Select all

const Ogre::Vector3 relativeOrigin = sceneManager.getRelativeOrigin();
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
reflectionCamera->enableReflection(Ogre::Plane(plane.normal, (plane.normal * -plane.d) + relativeOrigin));
Have not tried to compile PR itself though...
0 x

Hrenli
Halfling
Posts: 62
Joined: Tue Jun 14, 2016 12:26 pm
x 8

Re: Camera.enableReflection() and SceneManager.setRelativeOrigin()

Post by Hrenli » Fri Dec 07, 2018 9:06 pm

OK, I thought I'd make myself useful and compiled the PR. Actually, the author changed the sample to be a test case for this problem. It did show the problem clearly when I've updated only the sample and it works fine again after I've updated both the sample and PlanarReflections component. So I'd say it's OK to merge it.

On the other hand this extra dancing with origin point doesn't make the sample easier to read. We probably should not mix test cases with samples/tutorials. Especially without extra comments. So, maybe merge OgrePlanarReflections.cpp only?
0 x

Post Reply