Hi,
I am trying to add the capability of collision detection to Line( com.jme3.scene.shape.Line ). But some how collision isn’t detected. Below is the snippet and exception.
[java]
Line link = new Line(start, end);
Geometry geo = new Geometry(“Link”, link);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setTexture(“ColorMap”, assetManager.loadTexture("/Textures/stripes_1.png"));
mat.setColor(“Color”, ColorRGBA.White);
geo.setMaterial(mat);
MeshCollisionShape level_shape = new MeshCollisionShape(geo.getMesh());
RigidBodyControl rgbc = new RigidBodyControl(level_shape);
geo.addControl(rgbc);
rootNode.attachChild(geo);
[/java]
Exception
java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkIndex(Unknown Source)
at java.nio.DirectShortBufferU.get(Unknown Source)
at com.jme3.scene.mesh.IndexShortBuffer.get(IndexShortBuffer.java:53)
at com.jme3.bullet.collision.shapes.MeshCollisionShape.createCollisionMesh(MeshCollisionShape.java:91)
at com.jme3.bullet.collision.shapes.MeshCollisionShape.<init>(MeshCollisionShape.java:68)
at com.XXX.lib.jme3d.Launcher.createInterPlaneLinks(Launcher.java:480)
at com.XXX.lib.jme3d.Launcher.simpleInitApp(Launcher.java:499)
Can someone please let me know what might be the issue with the above code? If you feel the the MeshCollisionShape is not suitable please suggest the suitable one.