[Opensim-dev] Physics Of Simplicity

dan miller danbmil99 at yahoo.com
Sat Nov 17 10:07:17 UTC 2007


for the record -- this isn't really a sphere/box collision detector; it's a
box/box detector.  An actual sphere/box check would be somewhat more
expensive.

> The basic idea is that all prims are rectilinear solids, and all avatars
> are
> spheres.  (we may introduce a tweak later which would make the avatar an
> elongated ellipse, but the sphere case is easier to understand and
> implement, so we'll start with that.)
> 
> Taking the simplest case, imagine a prim with dimensions (a, b, c), and
> oriented so that its edges are parallel to the x, y, and z coordinates. 
> Its
> center is at location (x0, y0, z0).
> 
> The avatar will be a sphere with radius r.  We wish to place the avatar at
> location, (x1, y1, z1).  Our question is, does this move put the avatar in
> a
> place where it overlaps (penetrates) the prim?  (Obviously in the real
> world
> we need to do this test against every prim in the scene).
> 
> In this simplified case, the math is pretty easy.  For each axis, we do a
> range check.  The algorithm looks like this:
> 
> if( abs(x1-x0) >= (a/2+r) ) return false
> if( abs(y1-y0) >= (b/2+r) ) return false
> if( abs(z1-z0) >= (c/2+r) ) return false
> return true
> 
> Something this simple would be good enough to test out some ideas and walk
> on level prims.  To get rotation into the picture, all we have to do is
> recalculate the avatar's position according to the local rotational frame
> of
> the prim.  I'm not sure of the exact calls, but you would get a rotational
> matrix representing the prim's present orientation, invert it, and multply
> the vector (x1, y1, z1) by that inverted matrix (or maybe you can do it
> with
> quaternions).  Now you can do the same check as above, and get the correct
> results in the prim's rotational frame of reference.
> 
> Next step will be avatar movement.
> 
> 
> -danx0r
> 
> _______________________________________________
> Opensim-dev mailing list
> Opensim-dev at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/opensim-dev
> 




More information about the Opensim-dev mailing list