[Solved] Spherical Game World?

Hey, sorry to be asking a few questions, thank you so much for your help so far…



I want to use the JME physics engine to limit my game world to the inside of a sphere. Characters stay within the edges in all directions. So far, the physics engine seems to be preventing this.



I’ve got an outer sphere as follows:



Material sphere_mat = new Material(assetManager, “Common/MatDefs/Misc/ShowNormals.j3md”);

sphere_mat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);



Sphere worldMesh = new Sphere(32,32,10,true,true);

worldGeo = new Geometry(“Sphere”, worldMesh);

worldGeo.setMaterial(sphere_mat);



RigidBodyControl world_phy = new RigidBodyControl(0.0f);

worldGeo.addControl(world_phy);

bulletAppState.getPhysicsSpace().add(world_phy);



And an object within that (a smaller sphere), which should drop to the bottom like a ball, with a little bounce:



Sphere innerSphere = new Sphere(32, 32, 0.4f, true, false);

Geometry sphereGeom = new Geometry(“Sphere”, innerSphere);

sphereGeom.setMaterial(mat);

sphereGeom.setLocalTranslation(0, 0, 0);



phy = new RigidBodyControl(0.05f);

sphereGeom.addControl(phy);

RigidBodyControl bulletAppState.getPhysicsSpace().add(phy);



The inner sphere (the ball) doesn’t appear. If I comment out the physics of the outer sphere, the ball is visible but falls through the bottom of the outer sphere.



(Note that I’ve used the undocumented ‘interior’ parameter of the outer sphere, in the hope this helps…)



Any suggestions for keeping the ball inside the outer sphere? If it involves flipping normals, as mentioned elsewhere, please could you tell me how to do this?



HUGE thanks in advance,

Peter.

a physic sphere is solid, but if i understand right, you need more lika a hollow one. I suggest try creating a sphere in a model program (it will then be a meshcoliisionshape, those only exist out of triangles, and are not filled.)

1 Like

Thanks EmpirePhoenix, that was the impression I was getting. I’ve made a work-around using JME domes, which are hollow (hemi-spheres).



All the best,

Peter.

I might be completely wrong here because I’m a noob too, but as I understand it your sphere only has a face in one direction so --( is solid and (-- is not solid. If you flip the normals then --) will be solid but --( won’t have a textured face any more.



I think you need a more complex shape for what you’re trying to do, extruded so that you have --((-- solid, so you have to make it as a mesh in Blender.



You should probably wait for a reply from someone who knows what they’re talking about though :stuck_out_tongue: