Jump to content

Babylon Intersect with Sphere ..Question


BangTao
 Share

Recommended Posts

hello,guys ,There is a question.erm.....i set the balloon1'X from 0 to 9,to check if it intersect with the red Sphere ,The console shows "6"(the right answer should be "2") which means this balloon is always intersect with the red ball....why..i'm confused.. http://www.babylonjs-playground.com/#1LS9HN

Thanks for u time..

Link to comment
Share on other sites

In this playground  http://www.babylonjs-playground.com/#1LS9HN#1  the loop for re-positioning the balloon is done ten times with the following results for each k

0 TRUE
1 TRUE
2 TRUE
3 TRUE
4 TRUE
5 TRUE
6 FALSE
7 FALSE
8 FALSE
9 FALSE

So intersectsMesh is working but why is it giving positive results for the small values of k when it appears that the sphere and balloon are not intersecting?

This is because the intersection is based not on the meshes themselves but the bounding boxes of the meshes (shown as white cube outlines).

This PG http://www.babylonjs-playground.com/#1LS9HN#2  shows that while the sphere and mesh overlap their bounding boxes do ans so intersectsMesh is true.

Another point which may be of interest is that if you want to see the balloon move then loops will not work. You need to re-draw the balloon on each rendering of a new frame, for example

http://www.babylonjs-playground.com/#1LS9HN#3

Of course this does not solve the problem of knowing when the sphere and balloon intersect as spheres.

There is a brand new method which may turn out to be of help but it is so new I have not tried it yet.

Link to comment
Share on other sites

4 hours ago, JohnK said:

In this playground  http://www.babylonjs-playground.com/#1LS9HN#1  the loop for re-positioning the balloon is done ten times with the following results for each k

0 TRUE
1 TRUE
2 TRUE
3 TRUE
4 TRUE
5 TRUE
6 FALSE
7 FALSE
8 FALSE
9 FALSE

So intersectsMesh is working but why is it giving positive results for the small values of k when it appears that the sphere and balloon are not intersecting?

This is because the intersection is based not on the meshes themselves but the bounding boxes of the meshes (shown as white cube outlines).

This PG http://www.babylonjs-playground.com/#1LS9HN#2  shows that while the sphere and mesh overlap their bounding boxes do ans so intersectsMesh is true.

Another point which may be of interest is that if you want to see the balloon move then loops will not work. You need to re-draw the balloon on each rendering of a new frame, for example

http://www.babylonjs-playground.com/#1LS9HN#3

Of course this does not solve the problem of knowing when the sphere and balloon intersect as spheres.

There is a brand new method which may turn out to be of help but it is so new I have not tried it yet.

 

Thank u JohnK,and now i have totally understand how intersectsMesh works.

but i still wanna check if two meshs real intersection,not by BoundingBox....So,i'm tring to write a method to make it ,i've read the source code about intersectsMesh method.,,but i dont have any idea...

any idea for that?I can never thank you enough ( for your support).

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...