Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Mirror effect mystery?!?

Author
Message
047
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 27th Jan 2007 17:53
I'm trying to create a rearview mirror for my racing game.
The way I'm doing it is I created a slightly convex shaped object for the mirror and mirrored it itself to get a reversed reflection image effect. I positioned it on the screen and then locked it on so it wouldn't move with the rest the road scenery. Then I turned the camera 180 degrees and used `get image` to capture the screen of what's behind the car. Then I textured the mirror object with the image. Of course I turn the camera 180 degrees again to look forward.
The problem is that no matter what I've tried `get image` only captures what's ahead of the car completely ignoring the `turn camera` command to capture what's behind instead. I also used `hide object` to hide the mirror right before the `get image` command so the mirror itself wouldn't show on the reflection image but DB also ignores that command and reflects the mirror too unless I grab a part of the screen that doesn't have the mirror object on it. This is part of the code I'm using. Any ideas? Thanks!

turn camera right 180: ` look back

get image 1, 115, 140, 310, 330, 1: `capture what's behind the car

texture object 1, 1: ` object 1 is the mirror object

turn camera left 180: ` look ahead
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Jan 2007 19:43
Hello 047,

In order to make sure you are capturing what the camera is looking at, you have to redraw the screen before the image is captured. Use of the sync command in the right place can accomplish this.

Check out this snippet. I don't redraw the screen when the camera looks behind and therefore only end up capturing what's currently in front of the camera:



Now here's the same example but I stick a SYNC command after I rotate the camera and another when I texture the Plain:



Take a look at this link:

http://forum.thegamecreators.com/?m=forum_view&t=96553&b=10

Enjoy your day.
047
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 27th Jan 2007 21:17
Thanks Latch, I tried adding sync to my code but it went from running silky smooth to a horrible flckering mess and still didn't work nearly as it should. I think that I'll try making a miniature recreation of the scenery of what should be happening behind the car. Then if I can put that somewhere on the screen hidden behind a sprite or something, the `get image` command should work ok. That's just a crazy idea I've just had but not sure if it's even possible or worth the trouble. What do you think?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Jan 2007 08:49
That's completely possible, but depending on how it was done, it might create more overhead than you want that would slow down processing time. If you have the time to experiment, I think you should give it a shot. Before you recreate the scene in miniature, try just taking an arbitray get image from somewhere on the visible screen now and texturing you mirror. See if that alone hits your program's performance. If it does, adding additional objects as minis and adding a sprite, might even cause more of a performance hit.

In the link I posted, I have a demo of something almost just like that, and Rigo has a nice demo of using a sprite on the whole screen with the get image command. One of the main problems is the flickering that can occur with the switching of the camera views. The other problem, when you can overcome the flickering problem by using a split screen or by drawing and capturing everything from behind a sprite, is refresh time. If you can find a way to get good FPS without jitter, I would be happy to hear it.

Enjoy your day.
Atex
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Canada
Posted: 5th Mar 2007 03:15
Hello, 047

Here's a simple way how to implement a rearview mirror with no flicker or visible fps loss. I wrote this small prog. when I was trying to make my own racing game



Hope it helps

Login to post a reply

Server time is: 2025-05-26 03:03:44
Your offset time is: 2025-05-26 03:03:44