How to flip the viewport (reflection camera)

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
wut
Posts: 2
Joined: Wed Oct 20, 2010 6:59 pm

How to flip the viewport (reflection camera)

Post by wut »

Hi all,

I am working on a project that requires to flip the viewport (mirror-like) and arrange with other viewports.

I have looked at ICameraSceneNode.h which have one function called setViewMatrixAffector()

/* Sets a custom view matrix affector.
The matrix passed here, will be multiplied with the view
matrix when it gets updated. This allows for custom camera
setups like, for example, a reflection camera.
param affector The affector matrix. */

virtual void setViewMatrixAffector(const core::matrix4& affector) =0;

I have tried to figure out what is the matrix affector. However, I am not sure how to accomplish this.

Would anyone have tried this function? Or Are there any other ways to manipulate the viewport? Please help. Thank you in advance.
wut
Posts: 2
Joined: Wed Oct 20, 2010 6:59 pm

Post by wut »

Some updates. I found a reflection matrix on the internet and applied it to the affector matrix. Here is the matrix:

1 0 0 0
0 -1 0 0
0 0 1 0
0 0 0 1

However, I did not get the result that I want. The scene was just flipped in Y axis. I tried to change to other axises. They did not seem to do any good.

I wonder if this is the right path to go for flipping the viewport. Would it be easier to use render to texture to get the mirror viewport?
Kalango
Posts: 157
Joined: Thu Apr 26, 2007 12:46 am

Post by Kalango »

It would be nice if you were more clear with what you're trying to do. I dont know if you want to flip the projection matrix of your view (to cause inversion of axis, like the x axis growing from ight to left or something) or if you want to rotate the camera so it can show the left/right side of a model like a modelling app. If you want to invert the axis, you should try to set the camera matrix with left/right handed systems and project one matrix that fulfill your requirements. If you want to do the second thing, you should simply move the camera and rotate it....
Either way it'll be good if you were more specific... then we can help you...
Post Reply