Now my journey in the JPCT its in the collision phase ...
Well sometimes the Character is able to go thru the cube, sometimes it hits the cube, and got stopped, so sometimes its working, sometimes not ... any help would be great !
look what I'm doing :
I have a class that Wrap around every Object3D that I create, and this is the translate method
public void translate(SimpleVector where) {
int collisionObject = w.checkCollision(getTransformedCenter(), where,
5);
if (collisionObject == Object3D.NO_OBJECT) {
super.translate(where);
syncTranslate(where);
}
else {
System.out.println("colide with " + collisionObject );
}
}
the basic idea is dont allow those objets to go thru other object ... :)
and this is the init() method of my Game class
public void init() throws Exception {
System.out.println("Config.maxPolysVisible=" + Config.maxPolysVisible);
Config.maxPolysVisible = 12000;
Config.collideOffset = 250;
Config.tuneForOutdoor();
addTexture("alita2", "models/alita/alita2.jpg");
addTexture("floor", "textures/floor.jpg");
addTexture("red", "textures/red.jpg");
AbstractEntity[] list = new AbstractEntity[3];
list[0] = ModelUtil.loadModelMD2(getWorld(), "alita/tris", 0, -90, 0,
0.9f);
list[0].setTexture("alita2");
setCurrent(list[0]);
Animation run = list[0].getAnimationSequence();
anim = run.createSubSequence("run");
list[1] = new AbstractEntity(PlaneUtil.getPlane("floor", 20, 300),
getWorld());
list[1].setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
list[2] = new AbstractEntity(Primitives.getCube(50), getWorld());
list[2].setTexture("red");
list[2].setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
addObjects(list);
PositionUtil.placeOver(list[0], 0, 0);
PositionUtil.placeOver(list[2], -50, -50);
CameraUtil.setCameraLookingFromTop(getCamera(), list[0]);
LightUtil.addDefaultLight(getWorld());
addFPSListener(this);
Config.tuneForOutdoor();
Logger.setLogLevel(Logger.LL_ONLY_ERRORS);
}
errr
I solved the problem (at least I think I solved ...)
at the code
int collisionObject = w.checkCollision(getTransformedCenter(), where, 5 );
I increased the distance of the colision check from "5" to "25" and now my character lost its "ghost" powers ... ehhehehe
so it become :
int collisionObject = w.checkCollision(getTransformedCenter(), where, 25 );
Good job:D
But remember that there are two other collision detection schemes, ellipsoid and spherical. The "manual" tells you more about them and when to use them.
thanks !
but this one worked very fine ...
I'm in trouble now with the terrain creation hehehe