CodeRecipe( );

one stop for all game coders..

Follow us on Twitter
Home
Managing rigid body Print E-mail
User Rating: / 1
PoorBest 
Written by CR Team   
Monday, 10 August 2009 14:16

There is a certain process in order to manage the rigid bodies created using Director+Ageia physics engine.rbody

Few are the things that need to be kept in mind while making use of rigid bodies in your 3d environment:

We have listed 6 of them for now Cool

1. Name the rigid Body with the same name as the 3d model, this will help you to manage them easily.

Create RigidBody
1
2
3
4
5
6
7
--Create rigid body for the model named "car"
physX = member("physX")
p3dmember = member("3dWorld")
car_model = p3dmember.model("car")
 
rb_car = physX.createRigidBody(car_model.name,car_model.name,\
#box,#dynamic)

2. Delete a model only after the rigid body is deleted.

Deleting rigid body
1
2
3
4
5
6
7
8
9
10
11
12
physX = member("physX")
p3dmember = member("3dWorld")
car_model = p3dmember.model("car")
 
--If rigid body has same name as model,
-- life becomes easier
rb_car = physX.getRigidBody(car_model.name)
 
--first delete rigid body
physX.deleteRigidBody(rb_car)
--Only then delete the model
p3dmember.deleteModel(car_model.name)

3. DONOT delete a rigid body within a collision handler ! Populate a list of rigid bodies to be deleted and then once out of the collision handler , delete the rigidbody in the list.

4. Set the mass greater than zero, as soon as the rigid body is created.

Rigid body Mass
1
2
3
4
rb_car = physX.createRigidBody(car_model.name,car_model.name,\
#box,#dynamic)
--set a mass greater than 1
rb_car.mass = 10

5. Properties like linear-damping, friction will be taken from the physics world in case you dont specify them to each of the rigid body created. Hence specify own values in case you want specific rigid body to behave as desired !

physics world <-> rigid body
1
2
3
4
5
6
7
8
9
10
11
physX = member("physX")
 
physX.friction = 0.2
--all rigid bodies in physics world will have
-- 0.2 friction value
 
--rb_car will by default have a fiction of 0.2
rb_car = physX.getRigidBody("car")
rb_car_tyre = physX.getRigidBody("tyre")
--specify a new friction only for the tyre
rb_car_tyre.friction = 0.8

6. Disable LOD modifier in case you are getting errors while creating rigid bodies for specific model ( as a last workaround though )

Will add more in case something noticeable is found :)
 

CR Login

CodeRecipe Store

Twitter Feed

CR :) >>: RT @indiegamescom: Student game dev competition Dare to be Digital now accepting applicants http://t.co/Hf1phWJG