Setting physics collision properties in Python

From Digital Spaces

Jump to: navigation, search
if 'initializedFlag' not in locals().keys():
	for physics in dss_core.DIPhysics.GetFactoriesWithInterface():
		physics.SetContactBetweenShapes( 
			( "vehicle_wheel1_shape", "vehicle_wheel2_shape", "vehicle_wheel3_shape", "vehicle_wheel4_shape", ),
			( "terrain_shape", ), 
			{ "staticFriction": 1.0, "kineticFriction": 0.5, "pyramidFriction": True, } )
	
	initializedFlag = True
 

This script only does work the first time it is ran. It sets that for the shapes vehicle_wheel1_shape, vehicle_wheel2_shape, vehicle_wheel3_shape, vehicle_wheel4_shape, colliding with terrain_shape will have the specified properties set.

Currently, this function is implemented as an extension available to the scripting engine only. You cannot change the properties after calling this function. Calling this function again with new properties may work, however be aware that what is occuring is the first set of properties are being applied, then over-ridden with the second set. Any properties not over-ridden will remain from the first set.

To see the properties that can be set here, see the API documentation for DIPhysicsMaterial.

To see a more powerful way of having on-the-fly collision properties, see the next example Altering physics behaviour in Python.

Personal tools