Author Topic: collision basics  (Read 4609 times)

Offline athanazio

  • byte
  • *
  • Posts: 49
    • View Profile
    • http://www.athanazio.pro.br
collision basics
« on: December 10, 2006, 04:28:28 am »
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

Code: [Select]
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
Code: [Select]

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);
}

Offline athanazio

  • byte
  • *
  • Posts: 49
    • View Profile
    • http://www.athanazio.pro.br
collision basics
« Reply #1 on: December 10, 2006, 05:16:55 am »
errr
I solved the problem (at least I think I solved ...)
 
at the code

Code: [Select]

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 :


Code: [Select]

int collisionObject = w.checkCollision(getTransformedCenter(), where, 25 );

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
collision basics
« Reply #2 on: December 10, 2006, 06:04:13 pm »
Good job:D
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
collision basics
« Reply #3 on: December 12, 2006, 09:38:38 pm »
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.

Offline athanazio

  • byte
  • *
  • Posts: 49
    • View Profile
    • http://www.athanazio.pro.br
collision basics
« Reply #4 on: December 12, 2006, 09:40:53 pm »
thanks !
but this one worked very fine ...
I'm in trouble now with the terrain creation hehehe