Author Topic: PolygonID of an event TYPE_SOURCE  (Read 1929 times)

Offline Colli

  • byte
  • *
  • Posts: 13
    • View Profile
PolygonID of an event TYPE_SOURCE
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: PolygonID of an event TYPE_SOURCE
« Reply #1 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.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: PolygonID of an event TYPE_SOURCE
« Reply #2 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).