Class KX_PyConstraintBinding -- Blender Game Engine 2.49b



 
 


















createConstraint

(6DOF Constraint)


createConstraint(  
obj1_PhysicsID,
obj2_PhysicsID,
constraintType,

pivotPos_X, pivotPos_Y, pivotPos_Z,
pivotAxis_X, pivotAxis_Y, pivotAxix_Z,
Flag    )

6DOF ( 6 Degrees Of Freedom) set limits on the pivot's x,y and z position and the rotation of the pivot's x-axis, y-axis and z-axis.

Method Parameters:

obj1_PhysicsID:  The physics ID of object 1
   Type:  integer
obj2_PhysicsID:  The physics ID of object 2
   Type:  integer
constraintType:
   Type:  integer
     12 = 6DOF constraint
pivotPos_X:  
   Type:  float
pivotPos_Y:   
   Type:  float
pivotPos_Z:   
   Type: float
pivotAxis_X:  
   Type:  float
pivotAxis_Y:  
   Type:  float
pivotAxis_Z:
   Type:  float
Flag:
   Type:  integer
      128 = disable collision between obj1 and obj2

Note:
Pivot Position (pivotPos_X,  pivotPos_Y, pivotPos_Z) is the distance of the pivot from the object center of obj1.

Note:

Pivot Axis (pivotAxis_X,  pivotAxis_Y, pivotAxis_Z) is the euler angle of the pivot axis to the axis of the object center of obj1. 

Additional Parameters:

Pivot Max/Min Position:  
Allows you to set a min and max amount the pivot point can move from it's original position.

setParam(type, min, max)
type:  integer
  0 = pivot position X
  1 = pivot position Y
  2 = pivot position Z
min:   float
max:  float


Pivot Angle Rotation:
Allows you to set a min and max amount the angle can pivot.  
Min and Max values: uses Radians (?)
In other words, 0.52 = approximately 30 degrees

setParam(type, min, max)
type:  integer
  3 = pivot angle X
  4 = pivot angle Y
  5 = pivot angle Z
min:   float  
max:  float



Force -- Translational Motor:

Use with Pivot Max/Min Position.  (If the Pivot Point is locked in place, it can't move.)

Allows you to set a target velocity for the Pivot Point and the maximum force to apply to achieve it.

setParam(type, vel, maxForce)
type:  integer
  6 = pivot X axis
  7 = pivot Y axis
  8 = pivot Z axis
vel:   linear velocity
  Type:  float
  Range: -10,000.00 to 10,000.00
maxForce:  
  Type:  float
  Range:  -10,000.00 to 10,000.00

Force -- Rotational Motor:

Allows you to set a target angular velocity for the Pivot Point and the maximum force to apply to achieve it.

setParam(type, angVel, maxForce)
type:  integer
   9 = pivot X axis
 10 = pivot Y axis
 11 = pivot Z axis
angVel:   angular velocity
  Type:  float
  Range: -10,000.00 to 10,000.00
maxForce:  
  Type:  float
  Range:  -10,000.00 to 10,000.00

Springs -- Linear
Use with Pivot Max/Min Position.  (If the Pivot Point is locked in place, it can't move.)

Allows you to create a linear spring.

setParam(type, stiffness, reset)
type:  integer
 12 = pivot X axis
 13 = pivot Y axis
 14 = pivot Z axis
stiffness:  
  Type:  float
reset:  
  Type:  integer
    1 = return to original position
    0 = don't return to original position

Springs -- Angular
Allows you to create a angular spring.

setParam(type, stiffness, reset)
type:  integer
 15 = pivot X axis
 16 = pivot Y axis
 17 = pivot Z axis
stiffness:  
  Type:  float
reset:  
  Type:  integer
    1 = return to original position
    0 = don't return to original position

Sample Code


#################  6DOF Rotational Motor Constraint

# import PhysicConstraints Module
import PhysicsConstraints

# get current scene
scene = GameLogic.getCurrentScene()

# get object list
objList = scene.objects

# get object named OBCube_Green
obj1 = objList["OBCube_Green"]

# get object named OBCube_Red
obj2 = objList["OBCube_Red"]

# want to use a 6DOF constraint
constraintType = 12

# get obj1 physics ID
obj1_ID = obj1.getPhysicsId()

# get obj2 physics ID
obj2_ID = obj2.getPhysicsId()

# Use center of obj1 for pivot point
pivotPos_X =  0.0
pivotPos_Y =  0.0
pivotPos_Z =  0.0

# Make pivot axis orientation same as obj1 axis
pivotAxis_X = 0.0
pivotAxis_Y = 0.0
pivotAxis_Z = 0.0

# disable collisions between obj1 & obj2
flag = 128

# create a 6DOF constraint
cube_6DOF = PhysicsConstraints.createConstraint( obj1_ID, obj2_ID,
                                     constraintType,
                                     pivotPos_X, pivotPos_Y, pivotPos_Z,
                                     pivotAxis_X, pivotAxis_Y, pivotAxis_Z,
                                     flag)

# set rotation around pivot x and y axis to zero
cube_6DOF.setParam(3, 0.0, 0.0)
cube_6DOF.setParam(4, 0.0, 0.0)

# create rotational motor around the pivot z axis
cube_6DOF.setParam(11, 1.0, 100)


Example Blends


   
Game developers can use the game engine to create casual video games, first and third person shooters, role playing games, racing simulations and more. The game engine can be used to make both 2D games and 3D games.  Beginning game developers will only need basic knowledge of game design and programming to create rich and complex game models with photo realistic textures to add detail to the graphics of the video game.  Today's games need more than good looking low polygon game models.  Use normal maps and photo realistic textures to create high quality game models.