Unspported Collision Exception

I have 4 geometries that are the roofs and they are attached to a node called collidables. i use a for loop to get the collision results between each element in the sphere geometry called balls. The problem is that when i run it, an error comes up saying unsupported collision exception.



Heres the code:



Node collidables;

Geometry[] balls = new Geometry[10];

Geometry roof1,roof2,longroof1,longroof2;



public void simpleInitApp(){

collidables = new Node(“Collide Stuff”);

collidables.attachChild(roof1);

collidables.attachChild(roof2);

collidables.attachChild(longroof1);

collidables.attachChild(longroof2);

}



public void simpleUpdate(float tpf) {

CollisionResults res = new CollisionResults();

for (int a =0;a < balls.length;a++){

balls[a].collideWith(collidables,res);

if (res > 0){

System.out.println(“Balls were struck”);

}

}

}





Any help is appreciated thanks.

Dude, that code you posted above is not much useful to identify your issue.

lol, that code has a lot of balls, sadly they never get struck xD

Here’s the error:



com.jme3.collision.UnsupportedCollisionException

at com.jme3.collision.bih.BIHTree.collideWith(BIHTree.java:479)

at com.jme3.scene.Mesh.collideWith(Mesh.java:486)

at com.jme3.scene.Geometry.collideWith(Geometry.java:255)

at megaman.Other.simpleUpdate(Other.java:855)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:241)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:146)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:203)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:208)

at java.lang.Thread.run(Thread.java:662)

normen said:
lol, that code has a lot of balls, sadly they never get struck xD

I agree xD. How does those balls will get struck if never were instanced?...

the y is decreasing repeatedly for each ball in the for loop, i forgot to put it in there

@hamid14: That code you posted will never work, you have to instance the geometries or they will never get truck man. Are you using that code or did you post a simple version of your code?

its a simple version of the code, the full code has the geometries being instanced and they have materials, attached too rootnode. but it still doesnt work.

Here’s the full code: I’d appreciate any helpful suggestions :confused:

Node collidables;

Geometry[] balls = new Geometry[10];

Geometry roof1,roof2,longroof1,longroof2;

public void simpleInitApp(){

Box roofBox = new Box(Vector3f.ZERO,5,5,5);

roof1 = new Geometry(“Roof 1”,roofBox);

roof2 = new Geometry(“Roof2”,roofBox);

longroof1 = new Geometry(“Long Roof 1”,roofBox);

longroof2 = new Geometry(“Long Roof 2”,roofBox);

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

roofMat.setColor(“Color”,ColorRGBA.Red);

roof1.setMaterial(roofMat);

roof2.setMaterial(roofMat);

longroof1.setMaterial(roofMat);

longroof2.setMaterial(roofMat);

collidables = new Node(“Collide Stuff”);

collidables.attachChild(roof1);

collidables.attachChild(roof2);

collidables.attachChild(longroof1);

collidables.attachChild(longroof2);

rootNode.attachChild(collidables);

for (int a = 0;a < balls.length;a++){

balls[a] = new Geometry(“BALLZ”,roofBox);

balls[a].setMaterial(roofMat);

balls[a].move(0,50,0);

rootNode.attachChild(balls[a]);

}

}

public void simpleUpdate(float tpf) {

for (int a =0;a 0){

balls[a].move(0,-1,0);

CollisionResults res = new CollisionResults();

collidables.collideWith(balls[a],res);

if (res.size > 0) {

System.out.println(“Balls were struck”);

}

Hey man, your balls weren’t instanced yet, you just instanced their array.

i used this code to instance them



for (int a = ;a < balls.length;a++){

balls[a] = new Geometry("Balls " + a,roofBox);

balls[a].setMaterial(roofMat);

balls[a].move(0,35,0);

rootNode.attachChild(balls[a]);

}

I don’t know if it work when using a single mesh instance, try creating one mesh for each geometry.

how would i do that?

Hamid, it really makes no sense what you ask and show us here. You have a problem with an unsupported collision exception which means you try to do a collision check that cannot be done. The stacktrace contains a line number and further info about the error. Are you really thinking that anybody could help you if you post parts of your code as pseudo-code here, especially when they are totally irrelevant to the exception? Please read the manual on how to do collisions.

Here the full code:



pre type="java"
import com.bulletphysics.collision.shapes.CollisionShape;


import com.jme3.app.SimpleApplication;


import com.jme3.bullet.BulletAppState;


import com.jme3.bullet.control.RigidBodyControl;


import com.jme3.bullet.util.CollisionShapeFactory;


import com.jme3.collision.CollisionResults;


import com.jme3.material.Material;


import com.jme3.math.ColorRGBA;


import com.jme3.math.Vector3f;


import com.jme3.scene.Geometry;


import com.jme3.scene.shape.Box;





/**


 


 
 @author Administrator


 */


public class Collide extends SimpleApplication {





    Geometry box1, box2;





    public static void main(String[] args) {


        Collide app = new Collide();


        app.start();


    }


    private BulletAppState bulletAppState;





    @Override


    public void simpleInitApp() {


        bulletAppState = new BulletAppState(); //Create the physics object


        stateManager.attach(bulletAppState); //Attach the physics object to the game


        bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0f, -1f, 0f));


        Box boxg = new Box(Vector3f.ZERO, 5, 5, 5);


        box1 = new Geometry(“Box 1”, boxg);


        box2 = new Geometry(“Box 2”, boxg);


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


        mat.setColor(“Color”, ColorRGBA.Red);


        box1.setMaterial(mat);


        box2.setMaterial(mat);


        rootNode.attachChild(box1);


        rootNode.attachChild(box2);


        com.jme3.bullet.collision.shapes.CollisionShape shape = CollisionShapeFactory.createMeshShape(box1);


        RigidBodyControl body = new RigidBodyControl(shape, 0);


        box1.addControl(body);


        box2.addControl(body);


        bulletAppState.getPhysicsSpace().add(body);





    }





    @Override


    public void simpleUpdate(float tpf) {


        CollisionResults res = new CollisionResults();


        box1.collideWith(box1, res);





    }


}



/pre

Hey man, you are confusing the things, don’t confuse physics with collision results. Just apply physics forces to your physics objects and they will collide. Read the manual as @normen said. Also, create a test project in jmp and be happy xD.

i cant read the manual, because when i want to use the help topics in the sdk by pressing f1, nothing happens. I looked at the physics page on this site, but i tried to learn what i could, but that didnt help me fix my code either. The box geometry just goes DOWN and i need to check if it collides with the other box underneath it, but as you already know, i am having an error using collideWith. I look at the javadoc too, but it didnt help at all. I even posted the code prior to your post glaucomardano. -_-

hamid14 said:
I even posted the code prior to your post glaucomardano. -_-


I know it dude, or do you think i didn't read your code -.-...

How i said in my previous post, you don't need to use CollisionResults at same time you are using physics. Remove it from your code, if you wanna check physics collisions just implement PhysicsCollisionListener on your app. If you really wanna learn jme, create a TestGame in jmp and read, read and read.