0

I am trying to put a collision-shape onto my model. But everytime I init the game, I get an NegativeArraySizeException.

private void createSoundBit(float x, float y, float z)
    {
        Spatial npc1 = assetManager.loadModel("Models/sound/sound.j3o");
        npcNode.attachChild(npc1);
        CollisionShape noteshape = CollisionShapeFactory.createDynamicMeshShape(npc1);
        npcRigid = new RigidBodyControl(noteshape,123.0f);
        npcRigid.setFriction(0f);
        npcRigid.setMass(60f);
        npcRigid.setPhysicsLocation(new Vector3f(x,y,z));
        collmanager = new CollManager();
        getPhysicsSpace().addCollisionListener(collmanager);

        npc1.addControl(npcRigid);
        bulletAppState.getPhysicsSpace().add(npcRigid);
        rootNode.attachChild(npcNode);
    }

I don't know why it happens

Stacktrace:

java.lang.NegativeArraySizeException
    at com.jme3.bullet.collision.shapes.HullCollisionShape.getPoints(HullCollisionShape.java:71)
    at com.jme3.bullet.collision.shapes.HullCollisionShape.<init>(HullCollisionShape.java:24)
    at com.jme3.bullet.util.CollisionShapeFactory.createSingleDynamicMeshShape(CollisionShapeFactory.java:241)
    at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:112)
    at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:94)
    at com.jme3.bullet.util.CollisionShapeFactory.createDynamicMeshShape(CollisionShapeFactory.java:188)
    at Main.createSoundBit(Main.java:206)
    at Main.simpleInitApp(Main.java:83)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
    at java.lang.Thread.run(Thread.java:722)
4

1 回答 1

0

对我来说,它可能是以下两种情况之一:您的文件 sound.j3o 已损坏或 jmonkeyengine 中存在错误。尝试加载一些其他文件,看看发生了什么。有问题的部分来源:

FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
vertices.rewind();
int components = mesh.getVertexCount() * 3;
float[] pointsArray = new float[components];
// ...

所以,看起来像mesh.getVertexCount()返回负值。

于 2013-01-26T20:17:02.283 回答