How do to use JigLibX only to collision detection?

Jan 10, 2008 at 3:37 PM
hi...

I would like the to use the JigLibX without friction, inertia, and other properties of physic...

in other words, I would like to use only to collision detection... is possible?

Thanks...

Coordinator
Jan 11, 2008 at 1:38 PM
Edited Jan 11, 2008 at 1:39 PM
Instead of using the PhysicSystem use the CollisionSystem. Then call DetectAllCollisions(List<Body> bodies, CollisionFunctor collisionFunctor, CollisionSkinPredicate2 collisionPredicate, float collTolerance)

"bodies" are the bodies which should get tested
"collisionFunctor" Derive your own class from CollisionFunctor or use BasicCollisionFunctor. The function passes all collisions back to them.
"collisionPredicate" Derive an class from CollisionSkinPredicate2 or use null to let JigLibX know which bodies should not be considered.
"collTolerance" The tollerance of detection.
Jan 12, 2008 at 1:19 PM
Edited Jan 12, 2008 at 1:25 PM
I'm testing only the collisionsystem...

I would like know if is right... they are only 2 objects: 1 floor and 1 teapot...


in my construtor:
---------------------------
collisionSystem = new CollisionSystemGrid(32, 32, 4, 13, 13, 13);
collisionSystem.UseSweepTests = false;
--------------------------------


in my initalize:
----------------------------
collisions = new List<CollisionInfo>();
collisionFunctor = new BasicCollisionFunctor(collisions);
---------------------------


in my LoadContent() I code:
------------------------------------------------------
// define floor
floorModel = Content.Load<Model>("floor");
floorBody = new Body();
floorCS = new CollisionSkin(floorBody);

floorCS.AddPrimitive(new Box(new Vector3(0, 0, 0),Matrix.Identity, 3 * Vector3.One), (int)MaterialTable.MaterialID.UserDefined, new MaterialProperties(0.5f, 0.5f, 0.5f));
floorBody.CollisionSkin = floorCS;
floorBody.Position = new Vector3(0, 0, 0);

floorBody.MoveTo(new Vector3(0, 0, 0), Matrix.Identity);
floorBody.EnableBody();


// define teapot
teapotModel = Content.Load<Model>("teapot");
teapotBody = new Body();
teapotCS = new CollisionSkin(teapotBody);

teapotCS.AddPrimitive(new Sphere(new Vector3(0, 10, 0), 3f), (int)MaterialTable.MaterialID.UserDefined, new MaterialProperties(0.5f, 0.5f, 0.5f));
teapotBody.CollisionSkin = teapotCS;
teapotBody.Position = new Vector3(0, 0, 0);
posTeapot = teapotBody.Position;

teapotBody.MoveTo(posTeapot, Matrix.Identity);
teapotBody.EnableBody();


bodies = new List<Body>();
bodies.Add(floorBody);
bodies.Add(teapotBody);
----------------------------------------------



in my update I write:
------------------------------
// move down the teapot testing if exist collision

if (kstate.IsKeyDown(Keys.Down))
{
posTeapot.Y += 0.01f;
teapotBody.MoveTo(posTeapot, Matrix.Identity);
collisionSystem.DetectAllCollisions(bodies, collisionFunctor, null, 0.05f);

if (collisions.Count > 0)
posTeapot.Z -= 1;
}
---------------------------------------


the teapot is down ok, but...

again I ask: what is wrong???

because I dont get none collision ....

:-(


please, help me...
Jan 13, 2008 at 1:00 AM
ok, ok, its working... :-)

my problem was add the skin of objects to the collisionSystem...

but, I found other way to code, using the objects geometry: SphereObject, BoxObject...

the secret: dont forget add the objects geometry to the CollisionSystem:

collisionSystem.AddCollisionSkin(floorPhysic.PhysicsSkin);

thanks noone88...