www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Schwapp on August 17, 2011, 12:46:06 am

Title: Collision problem
Post by: Schwapp 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...
Title: Re: Collision problem
Post by: EgonOlsen 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.
Title: Re: Collision problem
Post by: Schwapp 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
Title: Re: Collision problem
Post by: Schwapp 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...