Using cameraviewport for rear mirror

Blitz3D Forums/Blitz3D Beginners Area/Using cameraviewport for rear mirror

Hi I managed to get the rear view camera working by creating it after the main camera.
Otherwise it doesnt appear.

The problem is that I need to change the viewport of the rear view mirror to fill the whole screen and have the regular camera fill the place where the rear-view mirror was.

It all works except the smaller viewport doesnt appear at all after I switch their viewport co-ords.
Im assuming its because the larger viewport is rendered over the smaller one.

I solved this problem before by creating them in a certain order but now doing this would mean destroying and creating cameras whenever the player wants a better view in the mirror.
So.. is there any other way of controlling the order in which cameras are rendered?

http://www.blitzbasic.com/Community/posts.php?topic=47663

I never got around to improving it.

Andy

Try using 'entityorder' to draw one of the one with the smaller viewport last "over everything else"

I had problems too when doing a rear view driving mirror. Doing the rear view was easy, it was flipping the thing into a mirror thing at the same time that was causing me the headache. In the end I left it alone coz it worked perfectly without the 'mirror effect' and carried on knowing it would be on my 'to do' list at a later date.

Andy, that example doesnt use cameraviewport, I need like a small 3d window inside a large 3d window, I think you are using clsmode or something.

Ah dunno about entityorder, does that effect the order in which cameras render? Ill try it out....

Puki : Did you render to texture? A straightforward way of flipping a mirror is to reverse the U texture coordinate and let the GPU worry about it!

Apply texture back-to-front sprite
Position mirror sprite
Render Rearview cam to texture buffer
Render main view

James (BlitzSupport) is your man - he donated some rear view mirror code three years ago - Mousey mad some slight changes to it and it works really well (although this type of code is a cpu hogger).

I think it exists in one form or another in the code archives.

IPete2.

Yeh, it is the one with the Smarties bouncing about in it

>Andy, that example doesnt use cameraviewport, I need like
>a small 3d window inside a large 3d window, I think you
>are using clsmode or something.

No, I am simply rendering 2 cameras and copyrecting the view from the mirror onto a texture which is then painted on to a quad using reversed u coordinates.

I would use the same approach to create a rear view mirror, and just parent the rear view mirror to the driver cam. Very simple and easy to do.


Andy

ok thanks, got it now