Author Topic: Object3D.checkForCollisionEllipsoid(Unknown Source)  (Read 2618 times)

Offline Schwapp

  • byte
  • *
  • Posts: 11
    • View Profile
Object3D.checkForCollisionEllipsoid(Unknown Source)
« on: September 11, 2011, 03:56:46 pm »
Hello!
I splitted um my Code which created a simple Scene and a moveable character.
Before i splitted it up to more classes (like player, or scene...) the collision worked fine.
But now I get  the exception you see in the title :

Object3D.checkForCollisionEllipsoid(Unknown Source)

The whole exception says:

Exception in thread "main" java.lang.NullPointerException
   at com.threed.jpct.Object3D.checkForCollisionEllipsoid(Unknown Source)
   at WWWGame.Game.loop(Game.java:131)
   at WWWGame.Game.start(Game.java:81)
   at Start.init(Start.java:30)
   at Start.main(Start.java:16)


So there must be a variable in line 131 which is null... but there isn't.

Thats the line:

moveRes = szene.getPlayer().getObject().checkForCollisionEllipsoid(moveRes,
            ellipsoid, 8);

All variabled are defined and not null.
Any idea what the problem is?

Offline Schwapp

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Object3D.checkForCollisionEllipsoid(Unknown Source)
« Reply #1 on: September 11, 2011, 03:58:32 pm »
lol, the  8) should be a  8 )^^

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Object3D.checkForCollisionEllipsoid(Unknown Source)
« Reply #2 on: September 11, 2011, 08:13:39 pm »
Maybe the same reason as in this thread: http://www.jpct.net/forum2/index.php/topic,2226.msg16428.html? (I.e. failed to add the object to the world). The next release will handle this case with a better error message.

Offline neo187

  • int
  • **
  • Posts: 73
    • View Profile
Re: Object3D.checkForCollisionEllipsoid(Unknown Source)
« Reply #3 on: September 18, 2011, 05:42:46 pm »
I'm actually having the same problem though the object has been added to the world. I'm trying to add collision detection to the Ninja from the Bones demo, this function is called in the initialization bit:

Code: [Select]
private void addNinja() {

AnimatedGroup ninja = masterNinja.clone(AnimatedGroup.MESH_DONT_REUSE);

ninja.getRoot().translate(0,0,-20);
ninja.getRoot().setCollisionMode(Object3D.COLLISION_CHECK_SELF);

ninja.addToWorld(world);

ninjas.add(ninja);
}
And upon pressing a button I try to check for collisions before applying the translations
Code: [Select]
directionVector = new SimpleVector(0,0,2);

.....

directionVector = ninjas.get(0).getRoot().checkForCollisionEllipsoid(directionVector, ellipsoid, 2);
ninjas.get(0).getRoot().translate(directionVector);

But I keep getting a Null error for the checkForCollision line?

EDIT:

Raft just helped me out with this. For an AnimatedGroup the set and check need to be done on the Animated3D object, not on the Object3D. In the Ninja demo ninjas.get(0) returns the animated group, ninjas.get(0).get(0) returns the Animated3D object:

Code: [Select]
ninjas.get(0).get(0).setCollisionMode(Object3D.COLLISION_CHECK_SELF);
directionVector = ninjas.get(0).get(0).checkForCollisionEllipsoid(directionVector, ellipsoid, 1);
« Last Edit: September 18, 2011, 06:15:49 pm by neo187 »