find a certain internal position of the 3D model

Post Reply
water
Posts: 21
Joined: Fri Jun 05, 2020 8:36 am

find a certain internal position of the 3D model

Post by water » Wed Jul 01, 2020 8:20 am

I imported a 3D model of. Obj. I want to place small balls in some positions of the model, but I can't find a certain internal position of the 3D model, as shown in the figure. What should I do? Thank you for your time
Image

User avatar
drleviathan
Posts: 629
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: find a certain internal position of the 3D model

Post by drleviathan » Wed Jul 01, 2020 3:13 pm

In this other thread you mention your Bullet simulation slows or blocks when you "increase the number of small balls". What you failed to mention in that thread, but what appears to be the case in this one, you are running those small balls inside a concave mesh object. If that really is your world configuration then I would not be surprised it would run slow. Many collisions across nearly all triangles of a complex triangular mesh would be expensive to compute. It becomes even more expensive if you have enabled continuous collision detection (CCD) which will attempt to do sweeps inside the mesh.

If you're trying to simulate a "fluid" of small balls passing through a mesh cavity I suspect Bullet (a real-time rigid body simulation) might not be the right tool for the job. I don't know exactly what it would be but maybe something like smoothed particle hydrodynamics (SPH). Read this article to learn more.

Your question in this thread is not clear. Are you asking: How to transform between the model's local-frame and the world-frame? Or are you asking: How to tell if a local-frame position is inside vs outside the model? Or maybe... something else?

water
Posts: 21
Joined: Fri Jun 05, 2020 8:36 am

Re: find a certain internal position of the 3D model

Post by water » Thu Jul 02, 2020 12:48 am

Drleviathan, thank you very much for your help. I want to realize the movement of the ball in the imported model (similar to a tube). I want to place the ball in a certain position inside the model, and then fall under the influence of gravity and collide with the inner wall of the model. However, after importing the model, I can't get the position information of each area of the model (the centroid of the model is at (0,0,0), I don't know where to put the ball's initial position.What should I do? thank you for your time

User avatar
drleviathan
Posts: 629
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: find a certain internal position of the 3D model

Post by drleviathan » Thu Jul 02, 2020 3:04 am

Here are some ideas that occur to me:

Assuming your tube is closed and a small ball will not fall out once it is placed inside...

(1) Place a ball randomly (with some quantization) and let it fall. If it falls out the bottom of your simulation after a certain amount of time then conclude it was not inside and discard the point, else hash the point and store it in a std::map<hash, btVector3>.

(2) Repeat step (1) many many times until the map of unique quantized starting points stops growing. At this point you have found the full, or nearly full, set of possible starting points inside the tube.

I can imagine a variety of similar but smarter algorithms. For example, instead of picking a completely random point: pick one of the points on the tube as the "seed" and make a small random step away from that. Alternatively, pick a random triangle on the mesh, find its center point and move some random (or systematic) distance in the opposite direction of the normal (assuming your mesh triangles are indexed systematically using the right-hand-rule).

water
Posts: 21
Joined: Fri Jun 05, 2020 8:36 am

Re: find a certain internal position of the 3D model

Post by water » Thu Jul 02, 2020 3:15 am

drleviathan wrote:
Thu Jul 02, 2020 3:04 am
Here are some ideas that occur to me:

Assuming your tube is closed and a small ball will not fall out once it is placed inside...

(1) Place a ball randomly (with some quantization) and let it fall. If it falls out the bottom of your simulation after a certain amount of time then conclude it was not inside and discard the point, else hash the point and store it in a std::map<hash, btVector3>.

(2) Repeat step (1) many many times until the map of unique quantized starting points stops growing. At this point you have found the full, or nearly full, set of possible starting points inside the tube.

I can imagine a variety of similar but smarter algorithms. For example, instead of picking a completely random point: pick one of the points on the tube as the "seed" and make a small random step away from that. Alternatively, pick a random triangle on the mesh, find its center point and move some random (or systematic) distance in the opposite direction of the normal (assuming your mesh triangles are indexed systematically using the right-hand-rule).
'Thank you very much

Post Reply