Author Topic: Collision problem  (Read 2446 times)

Offline Schwapp

  • byte
  • *
  • Posts: 11
    • View Profile
Collision problem
« on: August 17, 2011, 12:46:06 am »
Hello again :)
Since the last problem was solved (thanks for that again) I got a new one.
I'm still working with a scene which has a terrain and a figure.
I'm trying out the Collision samples and have one problem:
When I say
Code: [Select]

private SimpleVector moveRes = new SimpleVector(0, 0, 0);
private SimpleVector ellipsoid = new SimpleVector(2, 2, 2);
private static final float DAMPING = 0.1f;
moveRes=character.checkForCollisionEllipsoid(moveRes, ellipsoid, 8);
character.translate(moveRes);
SimpleVector t = new SimpleVector(0, 1, 0);
t = character.checkForCollisionEllipsoid(t, ellipsoid, 1);
character.translate(t);
if (moveRes.length() > DAMPING) {
moveRes.makeEqualLength(new SimpleVector(0, 0, DAMPING));
} else {
moveRes = new SimpleVector(0, 0, 0);
}
and
Code: [Select]

character.setCollisionMode(Object3D.COLLISION_CHECK_SELF);
terrain.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
it works not PERFECT.
The figure just falls half into the terrain.
Sorry, i can't explain it better in english, here a screenshot: http://imageshack.us/f/832/scr01o.png/
When  i don't use collisionModes, the figure just stands on top of the ground, whith collision it falls into the terrain...
« Last Edit: August 17, 2011, 12:52:35 am by Schwapp »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Collision problem
« Reply #1 on: August 17, 2011, 07:04:34 am »
You have to adjust the ellipsoid to match your model dimensions, for example try (2,6,2) instead of (2,2,2). In addition, i'm not sure if the gravity part of your code is actually working correctly for such a large model. Keep in mind that jPCT offers no magic "everything works as expected"-collision method for all cases. You might have to try a few things and understand how it works to use the provided methods in a way that the actual outcome matches your requirements.

Offline Schwapp

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Collision problem
« Reply #2 on: August 17, 2011, 05:38:37 pm »
Again solved the problem, i've now done it to (2, 11, 2)
Thank you again  ;D

Offline Schwapp

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Collision problem
« Reply #3 on: August 24, 2011, 04:03:55 pm »
I discovered a new problem, the ground - collision works fine, but there's also a tree placed in the terrain file.
The Object3D just ignores the tree and walks right through...
I don't know how to solve it and I have no idea how somebody could help me, with these rare information...
« Last Edit: August 24, 2011, 04:28:06 pm by Schwapp »