jPCT-AE - a 3d engine for Android > Support

Collision exception

(1/2) > >>

mbartnic:
Hello,

I have encountered following problem:

Durring execution of this line:


--- Code: ---model.checkForCollisionEllipsoid(sv, new SimpleVector(.5f, 1.0f, 0.5f), 3);
--- End code ---

Sometimes exception is thrown:


--- Code: ---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)

--- End code ---

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:
Some words on thread safety (apply to jPCT-AE too): http://www.jpct.net/wiki/index.php/Multithreading#Thread_safety

Navigation

[0] Message Index

[#] Next page

Go to full version