Collision exception

Started by mbartnic, January 09, 2012, 11:16:25 PM

Previous topic - Next topic

mbartnic

Hello,

I have encountered following problem:

Durring execution of this line:

model.checkForCollisionEllipsoid(sv, new SimpleVector(.5f, 1.0f, 0.5f), 3);

Sometimes exception is thrown:

01-09 23:10:49.590: E/AndroidRuntime(12805): FATAL EXCEPTION: Thread-11
01-09 23:10:49.590: E/AndroidRuntime(12805): java.lang.RuntimeException: [ 1326147049599 ] - ERROR: java.lang.NullPointerException
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.Object3D.getWorldTransformation(Object3D.java:2531)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.Object3D.getInverseWorldTransformation(Object3D.java:6494)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.Object3D.ellipsoidIntersectsAABB(Object3D.java:3633)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.World.doWorldCollisionEllipsoid(World.java:1933)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.World.doWorldCollisionEllipsoid(World.java:2046)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.World.doWorldCollisionEllipsoid(World.java:2046)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.World.checkSomeCollisionEllipsoid(World.java:1797)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.World.checkObjCollisionEllipsoid(World.java:1287)
01-09 23:10:49.590: E/AndroidRuntime(12805): at com.threed.jpct.Object3D.checkForCollisionEllipsoid(Object3D.java:2697)


I do not know what could be wrong - I try to catch it but the app crushes.

Any clues why does it happen?

Object is added already to the game world.

EgonOlsen

Which version of jPCT-AE is that? Maybe rotation or translation matrix of that object is null?

mbartnic

Newest jPCT-ae release and you are right transformation matrix is null, but I don't know why. I do just translation and rotation in Y axis and ofcourse collision detection. Does it matter if I have logic and display in different  threads?

K24A3

Yes it matters. If you are modifying 3D objects while jPCT is drawing it can cause exceptions.

You should update the object movement and rotation in the same thread from within the onDrawFrame(GL10 gl) function. Use a frame delta (time elapsed since the previous frame) to move/rotate your objects, for example: translationVector.x += fSpeed * fDelta;

EgonOlsen


mbartnic

Thank you for answers, they helped a lot.