Missing Collisions

I created a model in blender and imported it into jme with the ogre exporter. I create a dynamic collision shape using the collision shape factory. It doesn’t move fast at all and still misses the collision or glitches through. I have tried using the gImpact collision shape and it does the same thing. The weird thing is that it isn’t consistent. every once and a while it will act correctly. I have done this before and never seemed to have any problems. I am using blender 2.63.

Here is a simple test project with blender assets included: https://www.dropbox.com/sh/7t4ylxsxnnnbbst/KGFWcfSEZ5

Any ideas?
Thanks.

Anybody have any input? I was hoping I was just being dumb and doing something wrong. I have tried increasing accuracy (up to 1f/1000f) and ccd on the object (.001f and higher) but it still misses.

I doubt anyone will take the time and download and sift through your whole project. Make a simpler test case for the issue. If it doesn’t happen in the test case, find out whats different in your code.

It is a test case…I would not expect anyone to sift through an entire project.

So here is a copy and paste test case since it seems that is preferred. There are two objects, a model and a cube. Both have collision shapes generated in the same way but the model will fall through the map. Which may point to a problem with the model?

Model download here: https://www.dropbox.com/sh/6oxb042kdjvlldb/i2nbEqS33c

[java]package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.asset.TextureKey;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.collision.shapes.MeshCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;

public class Main extends SimpleApplication {
BulletAppState bulletState;
private AmbientLight ambientLight;
protected RigidBodyControl rbc;
protected Node model;
protected Material mat;

public static void main(String[] args) {
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Interface/Logo/Monkey.jpg", true);
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    tex.setMinFilter(Texture.MinFilter.Trilinear);
    mat.setTexture("ColorMap", tex);
    
    bulletState = new BulletAppState();
    bulletState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    
    stateManager.attach(bulletState);
    bulletState.getPhysicsSpace().enableDebug(assetManager);

    this.getCamera().setLocation(new Vector3f(0,2,10));

    initStillBackground();
}


private void initStillBackground() {
    setupFloor();
    ambientLight = new AmbientLight();
    ambientLight.setColor(ColorRGBA.White.mult(.5f));
    rootNode.addLight(ambientLight);

    addObject1();
    addObject2();
}

public void setupFloor() {
    Box floor = new Box(Vector3f.ZERO, 100, 1f, 100);
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setLocalTranslation(new Vector3f(0f, -3, 0f));

    floorGeom.addControl(new RigidBodyControl(new MeshCollisionShape(floorGeom.getMesh()), 0));
    rootNode.attachChild(floorGeom);
    bulletState.getPhysicsSpace().addAll(floorGeom);
}

public void addObject1(){
    model = (Node) assetManager.loadModel("Models/Pistol/Pistol.j3o");
    Geometry geo = (Geometry) model.getChild("Pistol");
    CollisionShape gun = CollisionShapeFactory.createDynamicMeshShape(geo);
    rbc = new RigidBodyControl(gun, 1);
    model.addControl(rbc);
    rootNode.attachChild(model);
    bulletState.getPhysicsSpace().addAll(model);
}

public void addObject2(){
    Box floor = new Box(.2f, .2f, .2f);
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setLocalTranslation(new Vector3f(10f, 0f, 0f));

    floorGeom.addControl(new RigidBodyControl(CollisionShapeFactory.createDynamicMeshShape(floorGeom), 1));
    rootNode.attachChild(floorGeom);
    bulletState.getPhysicsSpace().addAll(floorGeom);
}

}
[/java]

Dynamic Mesh shapes are prone for errorous behaviour, try to use a HullCollisionShape instead, for a gun that shoudl work good enough in terms of believability, and also is better performance wise.
Also are you using jbullet? I’m not even sure that the gimpact stuff is completly ported.

Thanks for the reply @EmpirePhoenix. I tried the hull collision shape but It still falls through.
Yes, I am using the bullet port offered by JME.

Hm, you see the collisionshapes correctly with the debug mode or?

Does it work if you use a box for the collisionshape, but render only the model?

Also the only difference I really see, is that for the pistol you get a child while the others are directly used, not sure if that can make problems, I would assume it shouldnot.

You could try to directly add the controls via add instead of addall, to rule out that they are not found by addall.