collision detection

Started by Veko, January 27, 2009, 02:47:06 PM

Previous topic - Next topic

Veko

Got a new problem :D.

If I understand checkForCollisionSpherical correct; when there is collision, checkForCollisionSpherical returns a vector different from the translation vector you entered with the check (the correct new translation)

I tried to apply this to my code :

m_ClientObjects is a Vector<Object3D>

all the Object3D in the vector have   
object.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);

the object where I'm testing the collision for has
object.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS | Object3D.COLLISION_CHECK_SELF);

  for (int i=0;i<STATE.m_ClientObjects.size();++i)
            {
                SimpleVector temp= STATE.m_ClientObjects.elementAt(i).checkForCollisionSpherical(a, 128);

                if (temp != a)
                {
                    a = temp;
                    System.out.println("New translation: " + temp);
                }
            }


But this snippet of code doesn't work, the SimpleVectors a and temp are always the same... so there is always collision ?? (eventhough there isn't)

What am I doing wrong ?

EgonOlsen

Use equals() instead, i.e.


if (!temp.equals(a)) {....}

Veko

ok that helped :p

Now I got a dillema, I mainly got square objects like boxes etc. in my scene and I don't really know what to pick for the collision detection, ellipsoid or spherical. I'm worried about the corners of the square objects not being collided with.

Is there somekind of way that I could use similiar to the checkForCollisionSpherical, because the return vector is really handy

EgonOlsen

Do you need that corrected translation vector or are you simply stopping the movement once the returned vector differs from the input one?

Veko

I need the corrected translation vector
but that works fine with spheres and ellipses, but with boxes i'm not sure how to proceed,

I'm trying to mess around a bit with the boundingboxes, but so far I'm not succesfull

EgonOlsen

Can you describe what those boxes do exactly? Do they move freely, do they move on a 2d plane, are they more like the boxes in Tetris...what are they?

Veko

the boxes are static objects in the game and they're used for blocking access (so the player has to go around them)
they stand in a 3d plane

They're much like the boxes and walls in your game robombs

EgonOlsen

If they are static and the player moves (and the player can be approximated by a sphere or an ellipsoid, i.e. it's not a box himself), there's no problem. Just go with ellipsoid collision detection (it's the most flexible one) and you should be fine. At least this is what Robombs does too.

Veko

#8
alright i'll give it a shot

* what should the SimpleVector ellipsoid be ? (i.e how do I determine the radius of the epplisoid in x,y and z direction for a box)

EgonOlsen

Quote from: Veko on January 27, 2009, 08:32:33 PM
* what should the SimpleVector ellipsoid be ? (i.e how do I determine the radius of the epplisoid in x,y and z direction for a box)
The approx. dimension of the player. The boxes doesn't matter. Collision detection in jPCT always is primitive (ray, sphere, ellipsoid) against actual geometry, not against another primitive. Therefor, the boxes don't need to be approximated by an ellipsoid.

Veko

ow ok, cool I thought every object the partakes in the collision needs to be ellipsoid or sphererical