Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PhysicsConstraints.py « PyDoc « gameengine « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bec8973edc6b6b03530c4146cf9c79095d5386d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
"""
Documentation for the PhysicsConstraints module.
================================================

Example::
	
	
	#  Adding a point constraint  #
	###############################
	
	
	# import BGE internal module
	import PhysicsConstraints
	
	# get object list
	obj_list = GameLogic.getCurrentScene().objects
	
	# get object named Obj_1
	root = obj_list["root"]
	obj = obj_list["obj"]

	# get object physics ID
	phido = obj.getPhysicsId()
	
	# get root physics ID
	phidr = root.getPhysicsId()

	# want to use point constraint type
	constraint_type = 1
	
	# Use bottom right front corner of object for point constraint position
	point_pos_x = 1.0
	point_pos_y = -1.0
	point_pos_z = -1.0
	
	# create a point constraint
	const =	PhysicsConstraints.createConstraint( phido, phidr, constraint_type, point_pos_x, point_pos_y, point_pos_z)

	# stores the new constraint ID to be used later
	obj["constraint_ID"] = const.getConstraintId()	
	
	
Example::
	
	
	#  Removing a point constraint  #
	#################################
	
	
	# import BGE internal module
	import PhysicsConstraints
	
	# get object list
	obj_list = GameLogic.getCurrentScene().objects
	
	# get object 1
	obj = obj_list["obj"]
	
	# get constraint ID that was saved as an obj property
	# when the constraint was created
	constraint_ID = obj["constraint_ID"]
	
	# remove constraint
	PhysicsConstraints.removeConstraint(constraint_ID)

"""

def createConstraint(obj_PhysicsID, root_PhysicsID, constraintType, pointPos_x, pointPos_y, pointPos_z, edgePos_x, edgePos_y, edgePos_z, edgeAngle_x, edgeAngle_y, edgeAngle_z):
	"""	
	Create a point constraint between two objects, an edge constraint between two objects, or a vehicle constraint on an object.
	
	You only have to input the needed parammeters depending on the type of constraint you are trying to create.
	

	B{Point Constraint} ::
	
		While creating a point constraint, the "pointPos" values define where you want the pivot point to be located.
		If you are creating a point constraint be sure to assing the integer "1" as the constraintType value.
	
		Parameters to use:
		obj_PhysicsID, root_PhysicsID, constraintType, pointPos_x, pointPos_y, pointPos_z
	
	B{Edge Constraint} ::
		
		While creating an edge constraint, the "edgePos" values define where you want the center of the edge constraint to be.
		Also, the "edgeAngle" values define in which direction you want the edge constraint to point (As a 3 dimensions vector).
		If you want to create an edge constraint be sure to assing the integer "2" as the constraintType value.

		Parameters to use:
		obj_PhysicsID, root_PhysicsID, constraintType, edgePos_x, edgePos_y, edgePos_z, edgeAngle_x, edgeAngle_y, edgeAngle_z}		
	
	B{Vehicle Constraint} ::
		
		While creating a point constraint, the "pointPos" values define where you want the pivot point to be located.
		If you want to create an edge constraint be sure to assing the integer "0" as the constraintType value.

		Parameters to use :
		obj_PhysicsID, root_PhysicsID, constraintType
	
	@type obj_PhysicsID: integer
	@param obj_PhysicsID: The physic ID of the first object to constraint.

	@type root_PhysicsID: integer
	@param root_PhysicsID: The physic ID of the second object to constraint.

	@type constraintType: integer
	@param constraintType: The type of constraint.

	@type pointPos_x: float
	@param pointPos_x: The X position of the point constraint.

	@type pointPos_y: float
	@param pointPos_y: The Y position of the point constraint.

	@type pointPos_z: float
	@param pointPos_z: The Z position of the point constraint.

	@type edgePos_x: float
	@param edgePos_x: The X value of the center of the edge constraint.

	@type edgePos_y: float
	@param edgePos_y: The Y value of the center of the edge constraint.

	@type edgePos_z: float
	@param edgePos_z: The Z value of the center of the edge constraint.

	@type edgeAngle_x: float
	@param edgeAngle_x: The X value of the edge's orientation vector.

	@type edgeAngle_y: float
	@param edgeAngle_y: The Y value of the edge's orientation vector.

	@type edgeAngle_z: float
	@param edgeAngle_z: The Z value of the edge's orientation vector.

	@rtype: integer
	@return: The created constraint ID
	"""
	

def getAppliedImpulse(constraint_ID):
	"""
	Returns the applied impulse.
	
	@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
	@type constraint_ID: integer
	@rtype: float
	@return: Measure the stress on a constraint.
	"""


def getVehicleConstraint(constraint_ID):
	"""
	Returns the vehicle constraint ID.
	
	@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
	@type constraint_ID: integer
	@rtype: integer
	"""
def removeConstraint(constraint_ID):
	"""
	
	Removes the constraint between 2 game objects (point and edge constraints).
	
	It does not remove vehicle constraints.
	
	@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
	@type constraint_ID: integer
	"""
def setDeactivationLinearTreshold(linearTreshold):
	"""
	
	Sets the linear velocity that an object must be below before the deactivation timer can start.
	
	This affects every object in the scene, except for game objects that have 'No sleeping' turned on.
	
	@param linearTreshold: The linear velocity.
	@type linearTreshold: float
	"""
def setDeactivationAngularTreshold(angularTreshold):
	"""
	
	Sets the angular velocity that an object must be below before the deactivation timer can start.
	
	This affects every object in the scene, except for game objects that have 'No sleeping' turned on.
	
	@param angularTreshold: The angular velocity.
	@type angularTreshold: float
	"""
def setDeactivationTime(time):
	"""
	
	Time (in seconds) after objects with velocity less then thresholds (see below) are deactivated.
	
	This affects every object in the scene, except for game objects that have 'No sleeping' turned on.
	
	This function is directly related with the 2 above functions.
	
	
	@param time: The time in seconds.
	@type time: float
	"""
def setGravity(gx, gy, gz):
	"""
	Sets the gravity for the actual scene only.
	
	All other scenes remain unaffected.
	
	This affects every object in the scene that has physics enabled.
	
	@param gx: The force of gravity on world x axis.
	@type gx: float
	@param gy: The force of gravity on world y axis.
	@type gy: float
	@param gz: The force of gravity on world z axis.
	@type gz: float
	"""
def setLinearAirDamping(damping):
	"""
	
	Sets the linear air resistance for all objects in the scene.
	
	@param damping: The linear air resistance.
	@type damping: float
	"""
def setNumIterations(numIter):
	"""
	Sets the number of times an iterative constraint solver is repeated.
	
	Increasing the number of iterations improves the constraint solver at the cost of performances & the speed of the game engine.
	
	@param numIter: The number of timesubsteps. (Input 0 to suspend simulation numSubStep)
	@type numIter: integer
	"""
def setNumTimeSubSteps(numSubStep):
	"""
	Set the quality of the entire physics simulation including collision detection and constraint solver.
	
	Increase the number of time substeps to improves the quality of the entire physics simulation at the cost of the performance & the speed of the game engine.
	
	@param numSubStep: The number of timesubsteps. (Input 0 to suspend simulation numSubStep)
	@type numSubStep: integer
	"""
#def setDebugMode():
#	"""
#	
#	
#	
#	@param numIter: 
#	@type numIter: 
#	"""
#def setCcdMode():
#	"""
#	Does something
#	
#	@rtype: 
#	"""
#def setContactBreakingTreshold():
#	"""
#	Does something
#	
#	@rtype: 
#	"""
#def setSolverDamping():
#	"""
#	Does something
#	
#	@rtype: 
#	"""
#def setSolverTau():
#	"""
#	Does something
#	
#	@rtype: 
#	"""
#def setSolverType():
#	"""
#	Does something
#	
#	@rtype: 
#	"""
#def setSorConstant():
#	"""
#	Does something
#	
#	@rtype: 
#	"""
#def setUseEpa():
#	"""
#	Does something
#	
#	@rtype: 
#	"""