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 Professional Discussion / I need to hide background object that block the camera view.

Author
Message
Dimis
15
Years of Service
User Offline
Joined: 12th Jun 2011
Location: Athens, Hellas
Posted: 28th Mar 2012 14:08 Edited at: 28th Mar 2012 14:21
I am making a 2 player fighting game, like Mortal Kombat. Recently I decided to make the fight take place in a totally 3d arena. My big problem now is the background. Objects from the background keep getting in front of the camera all the time and they block the view. So have to make background object hide or fade with alpha mapping, I will decide what is best later.
The camera is pointing all the time at the middle of where the 2 fighters are in the 3d world and is far enough to keep both fighters inside the visible area. Now when the fighters walk near the end of the backgrounds the camera will go behind background objects. I made a mock-up image to show the problem.

So my question is, what is the best way to determine if an object is between the fighters and the camera? Keep in mind that this check will be in the main loop so it has to be very efficient and fast.
Background objects could be either individual objects or one big object with multiple limbs, whatever will help most.

Thanks in advance.





Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Mar 2012 14:22
A simple but poor way would be to increase the cameras near draw range. Another option would be to do a distance check between all scenery and the camera, if it's less than X distance then hide (or exclude) it.

My signature is NOT a moderator plaything! Stop changing it!
Dimis
15
Years of Service
User Offline
Joined: 12th Jun 2011
Location: Athens, Hellas
Posted: 28th Mar 2012 14:34
Increasing the cameras near draw range will not help much because I can't determine how far will the camera go behind objects.
I guess that, distance checks is the best way to go, but we are talking about a large number of checks. I will have to keep the number of background objects low. I have to think about that.

Thanks for the advice!


mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 28th Mar 2012 14:43
Please provide typical decoration plan for typical scene. Just scheme.
Dimis
15
Years of Service
User Offline
Joined: 12th Jun 2011
Location: Athens, Hellas
Posted: 28th Mar 2012 14:53
@mrHandy
That is how the game is now. Camera is set, as if the game was 2D. There are no objects blocking the view. But I want to make the action fully 3d.
Does that video help?



Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 28th Mar 2012 16:39
The game looks bad ass.

I would imagine you could use fast 2D distance checks to check hundreds of object per loop without any real slow down. e.g.


If you want that to be faster, just do the visibility check every 10th of a second or something. Adjust it for the speed of your camera movements.

Dimis
15
Years of Service
User Offline
Joined: 12th Jun 2011
Location: Athens, Hellas
Posted: 28th Mar 2012 17:13
@ Fallout
Maybe I am worried with no reason. I will make my 3d backgrounds with all the objects that I want and I will see if there is any slow down.
Thanks for the code too!
Now that I think about it, I will have to add one more check to make objects visible again when they don't block the screen. Probably I will have to store the hidden objects in an array.

Thanks again!


Login to post a reply

Server time is: 2026-07-09 21:20:08
Your offset time is: 2026-07-09 21:20:08