Jump to content

How to test visibility of a point?


bostak
 Share

Recommended Posts

Hi,

 

Noob question: I use scene.pick to pick a point on a mesh. After rotating the camera (I use ArcRotateCamera), how can I test if that point is still visible? The context is that I want to label the picked points (similar to labeling in the DebugLayer) but only display the label when the point is visible in the activeCamera.

 

Any pointers in the righ direction are appreciated!

Link to comment
Share on other sites

Thanks for your response! Even if the mesh is visible, a point on it may not be.

 

Imagine a simple scene with a cylinder mesh and arcrotatecamera. The user picks a point on the 'front' of the cylinder. Then he moves/rotates the camera to the backside of the cylinder. The cylinder mesh is still visible, but the picked point is now hidden. i.e. obstructed from camera view by the 'backside' of the cylinder.

 

I am looking for a way to dynamically test if a previously picked point (on the surface of a mesh) is visible in the active camera or not. 

 

Thanks again for your help!

Link to comment
Share on other sites

Hi bostak, welcome aboard!   I don't have an answer, but I made a test playground... http://www.babylonjs-playground.com/#1S9TVO

 

This uses our 'decal' feature to place a (red) point on the side of a mesh.  The decal is a mesh, itself.  It's something to test-with.

 

I went forum searching and found this thread, but I'm not sure it pertains. In my BJS experiences, I have seen the term "occlusion' used at times.  I think, maybe, that is the modern term for "the hidden-line algorithm" that I once studied.  If I understand your issue, you would like to dynamically test if the picked-point is 'occluded' (blocked?) from camera view.

 

Check to make sure I am using the word 'occlude' correctly, and if so, search the world.  http://www.html5gamedevs.com/topic/12677-occlusion-culling/?hl=occlusion  (one search find).

 

Did you see someone mention Rays?  If you did a camera ray-shot at the decal... in the animation loop (constantly), then you would know when the camera-to-decal ray has been interrupted.  (maybe)

 

A github search of the BJS framework source code... for 'ray'... brings back quite a large return.  There's fun in there.  :)  

 

What IS your "picked point"?  If it is an actual mesh, such as decal, then Temechon's decal.isVisible() might work, except, there is no such function. :)

 

You need to have SOMETHING to view... for the picked point.  Remember that the "point" (or the decal) can be super-tiny.

 

I found a Boolean property on abstractMesh... called .isBlocked and I tried using it in the animation loop of a PG demo...

 

http://www.babylonjs-playground.com/#1S9TVO#1

 

It didn't work.  The boundingBox around the decal should disappear when the decal is blocked.  No go.  :)  But I see .intersects(ray, whatever) is on abstractMesh too.  Lots of other options ahead.  :)

 

There IS a property called .isVisible on all mesh, but I think it is used to report the value of the .visibility property, and not for occlusion testing. I tested it in the demo. It failed, too.

 

Ok, that's all I have.  Be aware that I am wrong, quite often.  I am a newbie, so, hopefully, smarter people than I will comment soon.  Be well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...