- Home /
Visualizing space between three or more objects
I have been trying to visualize the space either within objects or between objects. I would appreciate any input here.
The simplest case is, let say i have an empty cup. You fill up the cub with water, let it ice and remove the cup. In this case you have the ice formation which is the space inside the cub. How can I create a mesh the represents space inside the cup?
I am also trying to visualize the negative space between four cubes (picutre below) or three cubes and one sphere. If there was a way to fill them with water and freez it for example, you would be able to see what that looks like.
Fig1: four cubes
Fig2: three cubes and one sphere
Any ideas on how I can achieve this?
I'm not sure what the goal here is nor how good you have to be or how fast. But if the situations "real" world, you could use small spheres and rigidbodies and pour them into the cavity and freeze them. You might have to shake them around with a bit of AddForce() to get them to settle into more complex shapes.
You could also run a "probe" down into the cavity systematically ray casting to generate points to produce a point cloud. You could place a small sphere at these points, or could place a small disc or plane at each hit point using the normal (or inverse normal) at that point.
Thanks robertbu for your input. The first approach you have suggested works for static objects and also depends on physics engine contraints in terms of how many of those spheres can be simulated. It is a great suggestion.
In terms of ray casting, thats a very interesting approach too. $$anonymous$$aybe find the center point between all parties and start sending rays at random directions. If there is a hit, place a sphere or some sort of representation there and see what the point cloud looks like. This should visualize the outer space (edge) and outline the space. I am going to give this a try.
What would be great if there was a way to generate a mesh from this space. This is why I am trying to figure out. Although with the ray tracing if I can come up with enough points, maybe can use it as vertices and see what that mesh looks like.
Great suggestions. Appreciate your input :-)
Rather than casting from a central point, how about moving the point downward from the top of the cavity to the bottom, casting in a circular plane. It might be easier to build a mesh from the results.
Sure casting from bottom would definitely work as well. I will be doing this for moving objects. Lets say 4 humanoid moving and are positioned in a circular position. In terms of raycasting my 4 animated humanoid don't have ridget bodies.
As far as I could find, raycasting requires colliders. Is there a way to raycast and detect the collision between a given ray and mesh vertices?
I prefer to not get physics involved. Below is a screen shot of an acutal space I am interested in. As these guys move, the mesh collider I added to each one doesn't get updated because there is a skinned mesh renderer. So trying to see if I can do this just by using some sort of raycasting to detect collision of the ray with mesh vertices.
Your pictured didn't post. You don't need a rigidbody for raycasting, but you do need a collider. You can use layers to isolate the the colliders and raycasts from the rest of your game logic. As for verticies, you can easily get them from the mesh and convert them into world coordinates, but I don't know how you do the occlusion culling. That is, telling if a particular vertex can be seen from the stat point or if it is occluded by another part of the mesh (or even another mesh).
Your answer
Follow this Question
Related Questions
Adjusting strange Vector3.Normalize behaviour 2 Answers
Game Object's Vector3 changing threw script without reason 1 Answer
Incorrect cube subdivision mesh 1 Answer
Help with generating dynamic mesh 0 Answers
Round edges of cubes? 2 Answers