bostak Posted May 31, 2015 Share Posted May 31, 2015 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! Quote Link to comment Share on other sites More sharing options...
Temechon Posted May 31, 2015 Share Posted May 31, 2015 Hello, I would do something like this:var pickedPoint = scene.pick(...)if (pickedPoint.hit) { if (pickedPoint.pickedMesh.isVisible()) { // your code here }} Quote Link to comment Share on other sites More sharing options...
bostak Posted May 31, 2015 Author Share Posted May 31, 2015 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! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 31, 2015 Share Posted May 31, 2015 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. Quote Link to comment Share on other sites More sharing options...
Testouille Posted June 1, 2015 Share Posted June 1, 2015 I'm new so I don't know.Trace a ray from yourself to the point. If the collision with the ray is not your point, then your point is not visible. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
bostak Posted June 2, 2015 Author Share Posted June 2, 2015 Thanks for all of your suggestions! I will try out the raytracing approach and will provide a playground sample when finished. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.