Collision between two geometries

Hey guys…

I am developing a simple game right now…

In my game I got two geometries which is the moving red cube and the blue cube…

if the red cube touches or collide to the blue cube my program will output “Game over…” but I was having a problem in my codes…

Please help me how do this…



Here is my collision code:



public void simpleUpdate(float tpf) {

z-=0.001f;

red.setLocalTranslation(0, 0, z);

red.collideWith(blue, cr);

cr=new CollisionResults();

if(cr.size()>0){

System.out.println(“Game OVEr”);

}

}

Read the error output, then the manual. You cannot collide geometry vs geometry.

Im sorry that was not the code, this is the real one:



cr=new CollisionResults();

z-=0.001f;

red.setLocalTranslation(0, 0, z);

red.collideWith(blue, cr);

if(cr.size()>0){

System.out.println(“Game OVEr”);

}

So, how am i gonna do that?

@normen said:
Read the error output, then the manual. You cannot collide geometry vs geometry.


@blacksilver said:
So, how am i gonna do that?


What? Read?

Please help me…

I need to submit this game to my teacher next week…

Im just a ten year old guy…

English is not my primary language…

You have to do the collision with a bounding box instead of the geometry. As I said, read the error output. You teacher has internet as well, if I post the solution here you will get 0 points anyway.

I read this topic: Collision and Intersection in the Manual.

I set the boundvolume of the blue cube to BoundingBox:

Box bl=new Box(Vector3f.ZERO,1,1,1);

bl.setBound(new BoundingBox());

bl.UpdateBound();

blue= new Geometry(“Blue”, bl);



I did not set a bounding volume for the red box:



I tried the code:

CollisionResult c=new CollisionResult();

red.collideWith(blue,c);

if(c.size()>0){

System.out.println(“Game Over”);

}



This is the error:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

com.jme3.collision.UnsupportedCollisionException

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

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

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

at mygame.Main.simpleUpdate(Main.java:61)

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

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

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

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

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





Sir, please help me…please…

You have to collide with the bounding volume, as said you cannot collide geometry vs geometry, you have to do something like rootNode.collideWith(boundingBox);

Ah sir, what do you mean by a Collidable object?

Is it refering to spatial like nodes and geometries?

Thank you sir… I got it…

God bless…thank you so much… wojj…I got it,.,

Thank you Lord…!