www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Colli on July 23, 2012, 08:46:57 am

Title: PolygonID of an event TYPE_SOURCE
Post by: Colli on July 23, 2012, 08:46:57 am
Hi,

My question is how can a I get the PolygonID of an event which type is TYPE_SOURCE . The object's(this object is the only one moving in my scene) collision mode which triggers this event is set to COLLISION_CHECK_SELF.  The other objects (which can't move) are set to COLLISION_CHECK_OTHERS. That is for me a problem because i need the polygonID of the moving object.

here is the collision setup in code :
Code: [Select]
                        Ball.setCollisionMode(Object3D.COLLISION_CHECK_SELF);
Wall.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
Cube.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);

ballPolygonManager = Ball.getPolygonManager();
wallPolygonManager = Wall.getPolygonManager();
cubePolygonManager = Cube.getPolygonManager();

Wall.addCollisionListener(new CollisionListener() {
public void collision(CollisionEvent ce) {
polygonID = ce.getPolygonIDs();
polygonManager = wallPolygonManager;
}

public boolean requiresPolygonIDs() {
return true;
}
});

Cube.addCollisionListener(new CollisionListener() {
public void collision(CollisionEvent ce) {
polygonID = ce.getPolygonIDs();
polygonManager = cubePolygonManager;
}

public boolean requiresPolygonIDs() {
return true;
}
});
Thanks for any help
Title: Re: PolygonID of an event TYPE_SOURCE
Post by: EgonOlsen on July 23, 2012, 10:15:43 am
There's no such thing. Collisions in jPCT are always ray/sphere/ellipsoid against polygons. It's not polygon against polygon and that's why there is no such thing as a source polygon.
Title: Re: PolygonID of an event TYPE_SOURCE
Post by: AGP on July 29, 2012, 09:25:04 am
You could probably get the transformed center of a given triangle on the moving object then call something like calcMinDistance() on the static objects. Come to think of it, what you probably want is the opposite: call calcMinDistance() from the static objects and  get the polygon ID from the CollisionEvent (your listener implementation must return that you want the ID).