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 / Checking to see if an Area is Visible

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Nov 2010 15:37
Basically I want to check if a plain (coordinates) or volume (coordinates) are visible or a part of it is visible in the current camera frustum. So if it's behind an object it's not visible, but if it's behind an object with a hole (checked via a bounding mesh for speed) in it then it's visible. It's like what you do in occlusion culling, except I'm not culling anything, just checking to see if a space is visible.

I have no idea where to begin on this, so does anyone have any ideas?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Eminent
16
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 28th Nov 2010 18:36
Object in screen command. Returns 1 if visible, 0 if not visible .


Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Nov 2010 18:54
Have you used the object in screen command? Believe me it's useless. Also I'm not checking an object, but a 3d space or bounds.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 28th Nov 2010 20:53
Quote: "Believe me it's useless."


Open your mind, make cubes for the 3d bounds :p

revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Nov 2010 21:30 Edited at: 28th Nov 2010 21:32
Quote: "Open your mind, make cubes for the 3d bounds :p"


I believe that he is referring to the fact that it will return a 1 if the object is behind the camera, almost as if the view frustum extends forwards and backwards.

Sasuke, mabey you could use object in screen() as a preliminary check. Then you could calculate a vector from the camera to the object, and use the camera's direction vector to see if the object is really on screen.

At this point you might be able to use raycasting to tell if the object is being blocked or not.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Nov 2010 00:59 Edited at: 29th Nov 2010 01:01
Quote: "I believe that he is referring to the fact that it will return a 1 if the object is behind the camera, almost as if the view frustum extends forwards and backwards."


It's even worse than that.

Quote: "Sasuke, mabey you could use object in screen() as a preliminary check. Then you could calculate a vector from the camera to the object, and use the camera's direction vector to see if the object is really on screen."


You'd have to do that for every point just to see if it's in the screen cause just doing it to the position of it won't work.

Quote: "At this point you might be able to use raycasting to tell if the object is being blocked or not."


Same as before ish. What if the middle of the space is blocked but a part that doesn't contain any points (bound points) isn't. Raycasting wouldn't work for this.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 29th Nov 2010 01:49
Well you didn't specify what this is for, do you really need that kind of accuracy?
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Nov 2010 02:23
It's basically the same idea that cell-based occlusion culling does using portals, but more similar to Fallout 3's Room Markers. So you'd create a Room or Cell (box volume) and every object in that Room is connected to it. Then you create another next to it. Everything in the current viewing Room is visible and everything else or outside the Room is culled. Now we need to put a Door (plain bounds) or Hole in the Room to join the two Rooms up. If a Door is visible in the current viewing room then the connecting Room is visible and every object it contains. That's basically it.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2010 13:48
Any ideas on this? I'm lost.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Dec 2010 14:13
Doesn't "object visible(obj)" do this? Not sure I ever used it but that's what I thought it was for...

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2010 15:34
Object Visible is pretty much as useless as Object In Screen. Plus I'm not checking an object, just a plains coordinates.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Dec 2010 15:41
Maybe you should ask Evolved about his portal culling system shown here (or study it):


Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2010 15:55
Ooooh! That's pretty much what I was looking for. The only thing I don't know how to do is check to see if any part of an object/or coordinates is visible in the current viewing frustum. Can I ask where you found that vid, or is a link on his site?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Dec 2010 16:07 Edited at: 16th Dec 2010 16:08
Quote: "The only thing I don't know how to do is check to see if any part of an object/or coordinates is visible in the current viewing frustum"

Maybe using raycasting? I'm guessing maybe the portal consists of two planes maybe if you send a ray at one edge of a plane and it hits the other plane you can see through the portal:


I subscribe to Evolved's youtube channel, some great stuff on there! Check out is FPS engine (free downloadable source code!!)...

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2010 16:18 Edited at: 16th Dec 2010 16:19
Good idea, but the questions you would then bump into is what part of the edge would you check, what if the edge is obstructed but only a part round the middle is visible, what if there's a door in the way but with a tiny glass window. This is why i'm stuck. But cheers for the help baxslash

Quote: "I subscribe to Evolved's youtube channel, some great stuff on there! Check out is FPS engine (free downloadable source code!!)..."


Neat, I might do the same, cheers.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Dec 2010 16:26
Quote: "what part of the edge would you check, what if the edge is obstructed but only a part round the middle is visible, what if there's a door in the way but with a tiny glass window."

Don't mean to repeat what someone else has already said but do you really need that level of accuracy?

If the door is partly clear just make the room behind it visible using the same check (whether the 'little window' is visible or not) just in case! If it's 'possible' some of it might be visible then assume it is...

That's what I would do for sure.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2010 16:34
Quote: "Don't mean to repeat what someone else has already said but do you really need that level of accuracy?"


Well I guess the only way we'll know for sure is by testing the method, post back with the code later.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th Dec 2010 18:17
Just make the door windows pseudo transparent and treat them as solid. Then check if the door space is visible and the door is open.
(Pseudo transparent means it looks like the window is see through, but isn't Kinda like being cube mapped or something.)

If the door space is visible and the door is closed, next room = hidden
If the door space is visible and the door is open, next room = visible

My signature is NOT a moderator plaything! Stop changing it!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Dec 2010 18:45
What about making an object box 100,100,0 and make a hole on it exactly where you want the door, and then just check with intesect object to see if you go through the hole.


Cheers.

I'm not a grumpy grandpa
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Dec 2010 19:25
If this is for culling, you can use octree culling (basically you divide the scene up into smaller and smaller regions. If a region fails the test you can completely ignore any sub-regions, otherwise you test the sub-regions and so on). I made a plugin for this a while back which also lets you specify portals between regions for room-based culling.

If you need per-pixel accuracy, you need to draw the object to an image or bitmap without clearing the depth buffer used to draw the scene, and then see if any pixels are drawn to the image. Obviously this is pointless for culling as it involves drawing the object.

[b]

Login to post a reply

Server time is: 2026-07-21 07:03:14
Your offset time is: 2026-07-21 07:03:14