~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to doc/python_api/examples/bge.constraints.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Basic Physics Constraint
 
3
++++++++++++++++++++++++
 
4
Example of how to create a hinge Physics Constraint between two objects.
 
5
"""
 
6
from bge import logic
 
7
from bge import constraints
 
8
 
 
9
# get object list
 
10
objects = logic.getCurrentScene().objects
 
11
 
 
12
# get object named Object1 and Object 2
 
13
object_1 = objects["Object1"]
 
14
object_2 = objects["Object2"]
 
15
 
 
16
# want to use Edge constraint type
 
17
constraint_type = 2
 
18
 
 
19
# get Object1 and Object2 physics IDs
 
20
physics_id_1 = object_1.getPhysicsId()
 
21
physics_id_2 = object_2.getPhysicsId()
 
22
 
 
23
# Use bottom right edge of Object1 for hinge position
 
24
edge_position_x = 1.0
 
25
edge_position_y = 0.0
 
26
edge_position_z = -1.0
 
27
 
 
28
# use Object1 y axis for angle to point hinge
 
29
edge_angle_x = 0.0
 
30
edge_angle_y = 1.0
 
31
edge_angle_z = 0.0
 
32
 
 
33
# create an edge constraint
 
34
constraints.createConstraint(physics_id_1, physics_id_2,
 
35
                             constraint_type,
 
36
                             edge_position_x, edge_position_y, edge_position_z,
 
37
                             edge_angle_x, edge_angle_y, edge_angle_z)