Very strange model / collision problem

Hey guys!



I made a slope model - and I want to watch my box roll down the hill after I have added everything to the physics space.



SO i do all my coding - and then my box kinda falls through the surface of my slope and hits the inside ground of the model then sits still… so the physics is not linking to my slope - it thinks thats not a surface and the box falls inside the slope model.



I have a picture to explain. It shows a flyCamera half inside the slope half outside so you can see what im talking about!



I need the box to be sitting on the white surface slope outside of the inside of the model :smiley:







This is the code I have to load the slope + add to physics:



   private Node setupHill() {

      // assetManager.registerLocator("resources/misc/wildhouse.zip",
      // ZipLocator.class.getName());
      Spatial scene = assetManager
            .loadModel("resources/models/slopef.mesh.xml");

      // assetManager.
      DirectionalLight sun = new DirectionalLight();
      sun.setDirection(new Vector3f(-0.4790551f, -0.39247334f, -0.7851566f));
      sun.setColor(ColorRGBA.White.clone().multLocal(2));
      scene.addLight(sun);

      CollisionShape hillCollisionShape = CollisionShapeFactory
            .createMeshShape(scene);
      hillNode = new PhysicsNode(scene, hillCollisionShape, 0);
      hillNode.setName("hill");
      hillNode.setFriction(0.1f);
      hillNode.setLocalScale(0.1f);
      Quaternion roll = new Quaternion();
      roll.fromAngleAxis(FastMath.DEG_TO_RAD * 90f, new Vector3f(1, 0, 0));
      hillNode.setLocalRotation(roll);

      hillNode.center();

      getPhysicsSpace().add(hillNode);
      rootNode.attachChild(hillNode);

      return hillNode;
   }

CollisionShapeFactory.createMeshShape(scene);



only uses first geometry in the scene.



Workarounds, comining them or using compound collision shapes

Right, i understand the collision shape comment, but i dont understand how to actually workaround the problem!



Cheers,

:smiley:

Well either you have one geometry for collision (maybee an simplified additional one to safe some processing power as well)  , or you generate shapes for each object and combine them using a CompoundShape (wich is one shape consisting out of many)

Im sorry you have completely lost me.



In the jme3 test for loading a scene - it loads main.scene i think from the wildhouse zip.



I can successfully use the CollisionShapeFactory.createFromMesh(scene) for that - and it creates the physics correctly etc - and my model is really not any different to the scene loaded from the wildhouse.zip file.



Its not a big ask - load a model, apply physics to it.



I have no idea what you mean by create a Geometry or compund shapes - I am loading this file in as an ogre mesh xml - i dont deal with the geometry and shapes - jme does…

Yes you will have to think about the collision shapes and geometry, otherwise you will create very low-performamce games.

Maybe my answer in this post can be of aid for you.

[glow=red,2,300]but it works in the test for loading a scene…[/glow]



All i want is instead of loading the main.scene from wildhouse - to load my model instead and have the same physics on it…



I am unsure how this is any different to the jme3 wildhouse example…



I still dont understand how to make a solution to this problem - would anybody mind showing me how to actually solve it.

TBH i dont understand why the other thread you linked to norman is the way it is - the guy proposed what is seemingly 2 pieces of equivalent code, one works one doesnt!?



I would very much like an example solution to the problem I have here… Im not trying mesh to mesh collision either - i have 1 mesh and one BoxCollisionShape…



Cheers,



Andy

The problem actually disappears if i change the mass of my terrain from 0 to 1…except my terrain plummets towards the ground… so i dont know if that has anything to do with this?