Hello.
I would like to make a wrapped sphere(to put some other bodies inside the sphere).There are a Wrapped Objects in the documentation,but there are no samples how to use it.
Does anybody know how to do it?
Wrapped sphere
Re: Wrapped sphere
There's an example in demo #29, Fancy Shapes. Basically, a WrappedBody shrinkwraps a set of other bodies (given to it in the constructor) in a convex shell. Keep in mind, if you keep the other bodies fully within the sphere, it will be as if the WrappedBody is only a sphere because the sphere defines the most extreme point in any direction.
Here's the relevant code:
Here's the relevant code:
Code: Select all
List<Entity> oddShape = new List<Entity>();
Sphere bottom = new Sphere(new Vector3(-2, 2, 0), 2f);
Cylinder middle = new Cylinder(new Vector3(-2, 3, 0), 0, 3);
middle.orientationQuaternion = Quaternion.CreateFromAxisAngle(Vector3.Right, (float)Math.PI / 6);
Sphere top = new Sphere(new Vector3(-2, 4, 0), 1f);
oddShape.Add(bottom);
oddShape.Add(middle);
oddShape.Add(top);
space.add(new WrappedBody(new Vector3(-3, 4, 0), oddShape, 100));
Re: Wrapped sphere
Thanks for the answer.
Im not sure if i understand the entity wrapped body.I need the sphere that reacts from the inside out.I mean that i put some spheres in this wrapped sphere and they collide inside this wrapped sphere and cannot go out.Like a bingo game.
Is it right to use the wrapped body entity to do this,or some other?
Im not sure if i understand the entity wrapped body.I need the sphere that reacts from the inside out.I mean that i put some spheres in this wrapped sphere and they collide inside this wrapped sphere and cannot go out.Like a bingo game.
Is it right to use the wrapped body entity to do this,or some other?
Re: Wrapped sphere
The WrappedBody is a solid convex object; you would need some sort of hollow object. This could be constructed using a CompoundBody (a series of primitives would compose its 'shell,') or a StaticTriangleGroup (if you don't need the shell to move).
Re: hollow sphere
It is very difficult to make a hollow sphere from other (convex) objects.And i think that it would not be very effective.
I would like to change the sphere entity to behave like the hollow sphere.Is it possible or easy to do?
(suggestion for the future version - sphere.hollow , box.hollow , capsule.hollow ...)
I would like to change the sphere entity to behave like the hollow sphere.Is it possible or easy to do?
(suggestion for the future version - sphere.hollow , box.hollow , capsule.hollow ...)
Re: Wrapped sphere
It would be quite difficult and would rely on an entirely different form of collision detection. This is why it is not supported in normal primitives. However, you can load in the triangles of a mesh representing the shape you want. Those triangles could then be used in either a CompoundBody or StaticTriangleGroup.