www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: KOsmos on May 19, 2009, 11:46:26 pm

Title: collision detection
Post by: KOsmos on May 19, 2009, 11:46:26 pm
Hi

I can't apply any of the collision detection methods.

I have 3 Objects:

Code: [Select]
//a floor
terrain = Primitives.getPlane(30, 60);
terrain.setTexture("rocks");
terrain.rotateX((float)Math.toRadians(90));

//wall
wall = Primitives.getBox(10, 15);
wall.translate(-400,0,0);
wall.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS|Object3D.COLLISION_CHECK_SELF);
wall.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

//player
public Player(){
       super(Primitives.getSphere(30));
       this.translate(0, -30, 0);
       this.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS | Object3D.COLLISION_CHECK_SELF);
       this.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
}

public void moveForward(){
        int objID=checkForCollision(getZAxis(), getSpeed());
        if (objID==Object3D.NO_OBJECT) {
           super.moveForward();
        }
}

I move the player(ball) as in the car example. I want to perform a collision check against the wall. What am I missing?

Edit:
It actually works, but when the wall is a plane and not a box. Why can't I apply this method to a box?
Title: Re: collision detection
Post by: EgonOlsen on May 20, 2009, 03:25:14 pm
Try to increase this value: http://www.jpct.net/doc/com/threed/jpct/Config.html#collideOffset (http://www.jpct.net/doc/com/threed/jpct/Config.html#collideOffset)
Title: Re: collision detection
Post by: KOsmos on May 20, 2009, 10:54:11 pm
That solved my problem. Thank You.