Creating spheres inside Box

Hello I’m new to the whole Jmonkey interface and as such I unsure about how I would go about placing sphere geometries into a box. I’m attempting to simulate a bouncing ball game where the spheres bounce inside the box. The thing is I’m unsure how to place the spheres inside the box. I’ve looked at the collision and physic tutorials so I believe I’ll be able to handle the bouncing aspect. Any help in the right direction would be helpful.

You… you think you know how to handle the physics but you don’t know how to place objects :?

For some reason I just can’t wrap my head around placing a sphere inside a cube, but setting the restitution of both a cube and sphere is simple. I suppose for me its always the simple stuff that alludes me.

your box is “solid” and you can’t put stuff in, try make it out of 6 quads

…just make a mesh collision shape from a box geometry, not a physics box.

Thanks I’ve been reading up on the collision shapes, I figured I’d probably have to create a custom mesh shape. Though once I’ve created the shape how do I place the balls inside said shape? Do I have to use a node?

@normen said: ..just make a *mesh* collision shape from a box geometry, not a physics box.

ah that actually works, i always thought u were making that up :wink: I must have tried it with implicit BoxCollisionShapes before

@GrandSekiza said: Thanks I've been reading up on the collision shapes, I figured I'd probably have to create a custom mesh shape. Though once I've created the shape how do I place the balls inside said shape? Do I have to use a node?

You can move them with setPhysicsLocation (), or create a node/or existing spatial, move them, and then add the physics controls.

And to use a box just do:

[java]Box b = new Box (1, 1, 1);
Geometry g = new Geometry (“box”, b);
g.setMaterial (…);
CollisionShape createMeshShape = CollisionShapeFactory.createMeshShape(geometry);[/java]

Thanks for all the help guys!