Author Topic: Need a little direction on Collusion Detection  (Read 1447 times)

Offline bajabob

  • byte
  • *
  • Posts: 1
    • View Profile
Need a little direction on Collusion Detection
« on: December 17, 2010, 08:52:55 am »
I am not new to Java, but am to jPCT! I must say, so far I am really impressed!

I am trying to solve this issue, I cannot register a callback even when my objects supposedly collide. Any input? I'm using the same object twice.

Init:
Code: [Select]
floor = Loader.load3DS(res.openRawResource(R.raw.object), 1)[0];
walls = Loader.load3DS(res.openRawResource(R.raw.object), 1)[0];

floor.translate(0, 0, -10);
floor.setName("floor");
floor.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
floor.addCollisionListener(this);

walls.translate(0, 0, 0);
walls.setName("walls");
walls.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
walls.addCollisionListener(this);

                                world.addObject(walls);
world.addObject(floor);

walls.strip();
floor.strip();

OnDrawFrame:
Code: [Select]
                                SimpleVector s = floor.getCenter();
floor.translate(s.x, s.y, s.z+1);

Override "collision":
Code: [Select]
                                Log.d("COLLUSION DETECTED!!!", "!!!!!!");

Can't wait to find out what I did. My first attempt at 3D.

Bob

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Need a little direction on Collusion Detection
« Reply #1 on: December 17, 2010, 09:06:13 am »
translate() doesn't recognize any collisions. You have to use one of the checkCollision...methods to actually make jPCT check for collisions. Have a look here: http://www.jpct.net/wiki/index.php/Collision_detection

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Need a little direction on Collusion Detection
« Reply #2 on: August 12, 2016, 09:58:46 am »
I'm almost certain that collisions break whenever setName() is called. Could you verify this, Egon?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Need a little direction on Collusion Detection
« Reply #3 on: August 12, 2016, 05:43:48 pm »
No, it has nothing to do with it. setName() sets a new name, i.e. it assigns a string. The name and the collisions are not related in any way.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Need a little direction on Collusion Detection
« Reply #4 on: August 12, 2016, 06:11:51 pm »
Then I will replicate it and show it to you.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Need a little direction on Collusion Detection
« Reply #5 on: August 13, 2016, 10:05:17 am »
Good luck with that. It's a simple String. It's not used for anything else then log output. The two topics are as unrelated as it gets.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Need a little direction on Collusion Detection
« Reply #6 on: August 18, 2016, 03:50:48 am »
And yet I've run into collision problems when I renamed my bullets in the past.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Need a little direction on Collusion Detection
« Reply #7 on: August 18, 2016, 07:37:47 am »
That's impossible, it has to be a conincidence. The name is used...

  • ...to print out log messages
  • ...in World to access objects via their name. But the API itself doesn't use this, it's solely for the user.
  • ...in Serializer/Deserializer to...serialize and deserialize the name.

That's it! There's no relation to collision whatsoever. It would be plain stupid if there were anyway.