BangTao Posted January 13, 2017 Share Posted January 13, 2017 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.. Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 13, 2017 Share Posted January 13, 2017 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. Quote Link to comment Share on other sites More sharing options...
BangTao Posted January 13, 2017 Author Share Posted January 13, 2017 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). Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 13, 2017 Share Posted January 13, 2017 Sorry forgot to paste the link I was referring to this new method should help with intersections but have not studied it yet. Quote Link to comment Share on other sites More sharing options...
BangTao Posted January 13, 2017 Author Share Posted January 13, 2017 OKay ,thx anyway.i'll have look at it .and will try my best to study it ,thx. Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 13, 2017 Share Posted January 13, 2017 Had a play around with new methods and works provided green balloon is much smaller than red sphere. The new method will soon be available without putting the code into PG. http://www.babylonjs-playground.com/#1LS9HN#5 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.