~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to source/gameengine/PyDoc/KX_GameObject.py

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: KX_GameObject.py 14713 2008-05-06 20:55:55Z ben2610 $
 
1
# $Id: KX_GameObject.py 16450 2008-09-09 22:40:10Z ben2610 $
2
2
# Documentation for game objects
3
3
 
4
4
class KX_GameObject:
22
22
        @type orientation: 3x3 Matrix [[float]]
23
23
        @ivar scaling: The object's scaling factor. list [sx, sy, sz]
24
24
        @type scaling: list [sx, sy, sz]
 
25
        @ivar timeOffset: adjust the slowparent delay at runtime.
 
26
        @type timeOffset: float
25
27
        """
26
 
        
 
28
        def endObject(visible):
 
29
                """
 
30
                Delete this object, can be used inpace of the EndObject Actuator.
 
31
                The actual removal of the object from the scene is delayed.
 
32
                """     
 
33
        def getVisible():
 
34
                """
 
35
                Gets the game object's visible flag.
 
36
                
 
37
                @rtype: boolean
 
38
                """     
27
39
        def setVisible(visible):
28
40
                """
29
41
                Sets the game object's visible flag.
30
42
                
31
43
                @type visible: boolean
32
44
                """
 
45
        def getState():
 
46
                """
 
47
                Gets the game object's state bitmask.
 
48
                
 
49
                @rtype: int
 
50
                @return: the objects state.
 
51
                """     
 
52
        def setState(state):
 
53
                """
 
54
                Sets the game object's state flag.
 
55
                The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
 
56
                
 
57
                @type state: integer
 
58
                """
33
59
        def setPosition(pos):
34
60
                """
35
 
                Sets the game object's position.
 
61
                Sets the game object's position. 
 
62
                Global coordinates for root object, local for child objects.
 
63
                
 
64
                
 
65
                @type pos: [x, y, z]
 
66
                @param pos: the new position, in local coordinates.
 
67
                """
 
68
        def setWorldPosition(pos):
 
69
                """
 
70
                Sets the game object's position in world coordinates regardless if the object is root or child.
36
71
                
37
72
                @type pos: [x, y, z]
38
73
                @param pos: the new position, in world coordinates.
50
85
                
51
86
                @type orn: 3x3 rotation matrix, or Quaternion.
52
87
                @param orn: a rotation matrix specifying the new rotation.
 
88
                @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
 
89
                """
 
90
        def alignAxisToVect(vect, axis):
 
91
                """
 
92
                Aligns any of the game object's axis along the given vector.
 
93
                
 
94
                @type vect: 3d vector.
 
95
                @param vect: a vector to align the axis.
 
96
                @type axis: integer.
 
97
                @param axis:The axis you want to align
 
98
                                        - 0: X axis
 
99
                                        - 1: Y axis
 
100
                                        - 2: Z axis (default) 
 
101
                """
 
102
        def getAxisVect(vect):
 
103
                """
 
104
                Returns the axis vector rotates by the objects worldspace orientation.
 
105
                This is the equivalent if multiplying the vector by the orientation matrix.
 
106
                
 
107
                @type vect: 3d vector.
 
108
                @param vect: a vector to align the axis.
 
109
                @rtype: 3d vector.
 
110
                @return: The vector in relation to the objects rotation.
 
111
 
53
112
                """
54
113
        def getOrientation():
55
114
                """
57
116
                
58
117
                @rtype: 3x3 rotation matrix
59
118
                @return: The game object's rotation matrix
 
119
                @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
60
120
                """
61
 
        def getLinearVelocity(local):
 
121
        def getLinearVelocity(local = 0):
62
122
                """
63
123
                Gets the game object's linear velocity.
64
124
                
66
126
                ie no angular velocity component.
67
127
                
68
128
                @type local: boolean
69
 
                @param local: - False: you get the "global" velocity ie: relative to world orientation.
 
129
                @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
70
130
                              - True: you get the "local" velocity ie: relative to object orientation.
71
131
                @rtype: list [vx, vy, vz]
72
132
                @return: the object's linear velocity.
73
133
                """
 
134
        def setLinearVelocity(velocity, local = 0):
 
135
                """
 
136
                Sets the game object's linear velocity.
 
137
                
 
138
                This method sets game object's velocity through it's centre of mass,
 
139
                ie no angular velocity component.
 
140
                
 
141
                @type velocity: 3d vector.
 
142
                @param velocity: linear velocity vector.
 
143
                @type local: boolean
 
144
                @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
 
145
                              - True: you get the "local" velocity ie: relative to object orientation.
 
146
                """
 
147
        def getAngularVelocity(local = 0):
 
148
                """
 
149
                Gets the game object's angular velocity.
 
150
                
 
151
                @type local: boolean
 
152
                @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
 
153
                              - True: you get the "local" velocity ie: relative to object orientation.
 
154
                @rtype: list [vx, vy, vz]
 
155
                @return: the object's angular velocity.
 
156
                """
 
157
        def setAngularVelocity(velocity, local = 0):
 
158
                """
 
159
                Sets the game object's angular velocity.
 
160
                
 
161
                @type velocity: 3d vector.
 
162
                @param velocity: angular velocity vector.
 
163
                @type local: boolean
 
164
                @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
 
165
                              - True: you get the "local" velocity ie: relative to object orientation.
 
166
                """
74
167
        def getVelocity(point):
75
168
                """
76
169
                Gets the game object's velocity at the specified point.
118
211
        def restoreDynamics():
119
212
                """
120
213
                Resumes physics for this object.
 
214
                @Note: The objects linear velocity will be applied from when the dynamics were suspended.
121
215
                """
122
216
        def enableRigidBody():
123
217
                """
124
218
                Enables rigid body physics for this object.
125
219
                
126
220
                Rigid body physics allows the object to roll on collisions.
 
221
                @Note: This is not working with bullet physics yet.
127
222
                """
128
223
        def disableRigidBody():
129
224
                """
130
225
                Disables rigid body physics for this object.
 
226
                @Note: This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
131
227
                """
132
228
        def getParent():
133
229
                """
147
243
                """
148
244
                Removes this objects parent.
149
245
                """
 
246
        def getChildren():
 
247
                """
 
248
                Return a list of immediate children of this object.
 
249
                @rtype: list
 
250
                @return: a list of all this objects children.
 
251
                """
 
252
        def getChildrenRecursive():
 
253
                """
 
254
                Return a list of children of this object, including all their childrens children.
 
255
                @rtype: list
 
256
                @return: a list of all this objects children recursivly.
 
257
                """
150
258
        def getMesh(mesh):
151
259
                """
152
260
                Gets the mesh object for this object.
160
268
                """
161
269
                Returns the user data object associated with this game object's physics controller.
162
270
                """
 
271
        def getPropertyNames():
 
272
                """
 
273
                Gets a list of all property names.
 
274
                @rtype: list
 
275
                @return: All property names for this object.
 
276
                """
163
277
        def getDistanceTo(other):
164
278
                """
165
279
                Returns the distance to another object or point.
168
282
                @type other: L{KX_GameObject} or list [x, y, z]
169
283
                @rtype: float
170
284
                """
 
285
        def getVectTo(other):
 
286
                """
 
287
                Returns the vector and the distance to another object or point.
 
288
                The vector is normalized unless the distance is 0, in which a NULL vector is returned.
 
289
                
 
290
                @param other: a point or another L{KX_GameObject} to get the vector and distance to.
 
291
                @type other: L{KX_GameObject} or list [x, y, z]
 
292
                @rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z))
 
293
                @return: (distance, globalVector(3), localVector(3))
 
294
                """
171
295
        def rayCastTo(other,dist,prop):
172
296
                """
173
297
                Look towards another point/object and find first object hit within dist that matches prop.
174
298
 
175
299
                The ray is always casted from the center of the object, ignoring the object itself.
176
300
                The ray is casted towards the center of another object or an explicit [x,y,z] point.
 
301
                Use rayCast() if you need to retrieve the hit point 
177
302
 
178
303
                @param other: [x,y,z] or object towards which the ray is casted
179
 
                @type other: L{KX_GameObject} or string
 
304
                @type other: L{KX_GameObject} or 3-tuple
180
305
                @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
181
306
                @type dist: float
182
307
                @param prop: property name that object must have; can be omitted => detect any object
184
309
                @rtype: L{KX_GameObject}
185
310
                @return: the first object hit or None if no object or object does not match prop
186
311
                """
187
 
        
 
 
b'\\ No newline at end of file'
 
312
        def rayCast(objto,objfrom,dist,prop,face,xray,poly):
 
313
                """
 
314
                Look from a point/object to another point/object and find first object hit within dist that matches prop.
 
315
                if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
 
316
                if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element.
 
317
                
 
318
                Ex::
 
319
                        # shoot along the axis gun-gunAim (gunAim should be collision-free)
 
320
                        ob,point,normal = gun.rayCast(gunAim,None,50)
 
321
                        if ob:
 
322
                                # hit something
 
323
 
 
324
                Notes:                          
 
325
                The ray ignores the object on which the method is called.
 
326
                It is casted from/to object center or explicit [x,y,z] points.
 
327
                
 
328
                The face paremeter determines the orientation of the normal:: 
 
329
                  0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
 
330
                  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
 
331
                  
 
332
                The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
 
333
                The prop and xray parameters interact as follow::
 
334
                    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
 
335
                    prop off, xray on : idem.
 
336
                    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
 
337
                    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
 
338
                The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
 
339
                If there is no hit or the hit object is not a static mesh, None is returned as 4th element. 
 
340
                
 
341
                The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
 
342
 
 
343
                @param objto: [x,y,z] or object to which the ray is casted
 
344
                @type objto: L{KX_GameObject} or 3-tuple
 
345
                @param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center
 
346
                @type objfrom: L{KX_GameObject} or 3-tuple or None
 
347
                @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
 
348
                @type dist: float
 
349
                @param prop: property name that object must have; can be omitted => detect any object
 
350
                @type prop: string
 
351
                @param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
 
352
                @type face: int
 
353
                @param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
 
354
                @type xray: int
 
355
                @param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
 
356
                @type poly: int
 
357
                @rtype:    3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
 
358
                        or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
 
359
                @return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
 
360
                         If no hit, returns (None,None,None) or (None,None,None,None)
 
361
                         If the object hit is not a static mesh, polygon is None
 
362
                """
 
363
 
 
364