collision detection

Started by manumoi, July 04, 2005, 11:49:13 PM

Previous topic - Next topic

manumoi

Hello, i m having a problem with collision detection...
I create a terrain object with many triangles.

then i call this function

public void setupTerrainOctreeAndCollision(){
   OcTree oc = new OcTree(terrain, 100, OcTree.MODE_OPTIMIZED);
   terrain.setOcTree(oc);
   oc.setCollisionUse(OcTree.COLLISION_USE);
   Config.collideOffset = 250;
   terrain.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
terrain.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
   }

After that i create an avatar with an md2 file

public void loadModel(){
   model=Loader.loadMD2(modelPath+"tris.md2", 0.5f);
   model.setCollisionMode(Object3D.COLLISION_CHECK_SELF);
   model.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
...

In this configuration, collisions occur and my avatar can t go through walls... But the problem is it can go through others avatars... When i try to put:

model.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);

there is no more collision and i don t understand why

Do you have an idea ???


PS :

my forward method is :

// ELLIPSOID_RADIUS is defined as in the FPS example
private void moveForward(){
   SimpleVector a = model.getZAxis();
   a.scalarMul(5f);
   a = model.checkForCollisionEllipsoid(a,ELLIPSOID_RADIUS, 5);
   model.translate(a);
   animating=true;
   }


Tell me if you need something else to understand my code

EgonOlsen

Because your models should collide with others objects (models or the level) but each one should act as a collider itself to others, you have to use a combination of both modes on your model(s).
Try:

model.setCollisionMode(Object3D.COLLISION_CHECK_SELF|Object3D.COLLISION_CHECK_OTHERS);