2004-05-30 11:09:46 +00:00
|
|
|
# $Id$
|
2004-05-24 07:49:50 +00:00
|
|
|
# Documentation for game objects
|
|
|
|
|
|
|
|
class KX_GameObject:
|
|
|
|
"""
|
|
|
|
All game objects are derived from this class.
|
|
|
|
|
2004-06-02 12:43:27 +00:00
|
|
|
Properties assigned to game objects are accessible as attributes of this class.
|
2004-05-24 07:49:50 +00:00
|
|
|
|
2004-07-17 05:28:23 +00:00
|
|
|
@ivar name: The object's name.
|
|
|
|
@type name: string.
|
|
|
|
@ivar mass: The object's mass (provided the object has a physics controller). Read only.
|
|
|
|
@type mass: float
|
2004-05-31 13:06:04 +00:00
|
|
|
@ivar parent: The object's parent object. (Read only)
|
2004-06-02 12:43:27 +00:00
|
|
|
@type parent: L{KX_GameObject}
|
2004-07-17 05:28:23 +00:00
|
|
|
@ivar visible: visibility flag.
|
|
|
|
@type visible: boolean
|
2004-05-31 13:06:04 +00:00
|
|
|
@ivar position: The object's position.
|
|
|
|
@type position: list [x, y, z]
|
|
|
|
@ivar orientation: The object's orientation. 3x3 Matrix.
|
|
|
|
You can also write a Quaternion or Euler vector.
|
|
|
|
@type orientation: 3x3 Matrix [[float]]
|
|
|
|
@ivar scaling: The object's scaling factor. list [sx, sy, sz]
|
|
|
|
@type scaling: list [sx, sy, sz]
|
2008-06-14 17:12:49 +00:00
|
|
|
@ivar timeOffset: adjust the slowparent delay at runtime.
|
|
|
|
@type timeOffset: float
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
2008-06-27 11:35:55 +00:00
|
|
|
def endObject(visible):
|
|
|
|
"""
|
|
|
|
Delete this object, can be used inpace of the EndObject Actuator.
|
|
|
|
The actual removal of the object from the scene is delayed.
|
|
|
|
"""
|
2008-10-27 15:47:58 +00:00
|
|
|
def replaceMesh(mesh_name):
|
|
|
|
"""
|
|
|
|
Replace the mesh of this object with a new mesh. This works the same was as the actuator.
|
|
|
|
@type mesh_name: string
|
|
|
|
"""
|
2008-08-31 19:07:10 +00:00
|
|
|
def getVisible():
|
2008-06-26 12:39:06 +00:00
|
|
|
"""
|
|
|
|
Gets the game object's visible flag.
|
|
|
|
|
2008-08-31 19:07:10 +00:00
|
|
|
@rtype: boolean
|
2008-06-26 12:39:06 +00:00
|
|
|
"""
|
2004-05-24 07:49:50 +00:00
|
|
|
def setVisible(visible):
|
|
|
|
"""
|
|
|
|
Sets the game object's visible flag.
|
|
|
|
|
2008-06-29 21:52:23 +00:00
|
|
|
@type visible: boolean
|
|
|
|
"""
|
|
|
|
def getState():
|
|
|
|
"""
|
|
|
|
Gets the game object's state bitmask.
|
|
|
|
|
|
|
|
@rtype: int
|
|
|
|
@return: the objects state.
|
|
|
|
"""
|
2008-08-31 19:07:10 +00:00
|
|
|
def setState(state):
|
2008-06-29 21:52:23 +00:00
|
|
|
"""
|
2008-08-31 19:07:10 +00:00
|
|
|
Sets the game object's state flag.
|
2008-06-29 21:52:23 +00:00
|
|
|
The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
|
|
|
|
|
2008-08-31 19:07:10 +00:00
|
|
|
@type state: integer
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def setPosition(pos):
|
|
|
|
"""
|
2008-09-09 22:40:10 +00:00
|
|
|
Sets the game object's position.
|
|
|
|
Global coordinates for root object, local for child objects.
|
|
|
|
|
|
|
|
|
|
|
|
@type pos: [x, y, z]
|
|
|
|
@param pos: the new position, in local coordinates.
|
|
|
|
"""
|
|
|
|
def setWorldPosition(pos):
|
|
|
|
"""
|
|
|
|
Sets the game object's position in world coordinates regardless if the object is root or child.
|
2004-05-24 07:49:50 +00:00
|
|
|
|
|
|
|
@type pos: [x, y, z]
|
|
|
|
@param pos: the new position, in world coordinates.
|
|
|
|
"""
|
|
|
|
def getPosition():
|
|
|
|
"""
|
|
|
|
Gets the game object's position.
|
|
|
|
|
2004-05-31 13:06:04 +00:00
|
|
|
@rtype: list [x, y, z]
|
|
|
|
@return: the object's position in world coordinates.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def setOrientation(orn):
|
|
|
|
"""
|
|
|
|
Sets the game object's orientation.
|
|
|
|
|
2008-06-25 16:09:29 +00:00
|
|
|
@type orn: 3x3 rotation matrix, or Quaternion.
|
2004-05-24 07:49:50 +00:00
|
|
|
@param orn: a rotation matrix specifying the new rotation.
|
2008-06-25 16:09:29 +00:00
|
|
|
@note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
2008-06-02 17:31:05 +00:00
|
|
|
def alignAxisToVect(vect, axis):
|
|
|
|
"""
|
|
|
|
Aligns any of the game object's axis along the given vector.
|
|
|
|
|
|
|
|
@type vect: 3d vector.
|
|
|
|
@param vect: a vector to align the axis.
|
|
|
|
@type axis: integer.
|
|
|
|
@param axis:The axis you want to align
|
|
|
|
- 0: X axis
|
|
|
|
- 1: Y axis
|
|
|
|
- 2: Z axis (default)
|
|
|
|
"""
|
2008-07-04 00:05:50 +00:00
|
|
|
def getAxisVect(vect):
|
|
|
|
"""
|
|
|
|
Returns the axis vector rotates by the objects worldspace orientation.
|
|
|
|
This is the equivalent if multiplying the vector by the orientation matrix.
|
|
|
|
|
|
|
|
@type vect: 3d vector.
|
|
|
|
@param vect: a vector to align the axis.
|
|
|
|
@rtype: 3d vector.
|
|
|
|
@return: The vector in relation to the objects rotation.
|
|
|
|
|
|
|
|
"""
|
2004-05-24 07:49:50 +00:00
|
|
|
def getOrientation():
|
|
|
|
"""
|
|
|
|
Gets the game object's orientation.
|
|
|
|
|
2008-07-04 00:05:50 +00:00
|
|
|
@rtype: 3x3 rotation matrix
|
2004-05-31 13:06:04 +00:00
|
|
|
@return: The game object's rotation matrix
|
2008-06-25 16:09:29 +00:00
|
|
|
@note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
2008-07-03 01:34:50 +00:00
|
|
|
def getLinearVelocity(local = 0):
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
Gets the game object's linear velocity.
|
|
|
|
|
|
|
|
This method returns the game object's velocity through it's centre of mass,
|
|
|
|
ie no angular velocity component.
|
|
|
|
|
2008-05-06 20:55:55 +00:00
|
|
|
@type local: boolean
|
2008-07-03 01:34:50 +00:00
|
|
|
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
|
2008-05-06 20:55:55 +00:00
|
|
|
- True: you get the "local" velocity ie: relative to object orientation.
|
2004-05-31 13:06:04 +00:00
|
|
|
@rtype: list [vx, vy, vz]
|
|
|
|
@return: the object's linear velocity.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
2008-07-03 01:34:50 +00:00
|
|
|
def setLinearVelocity(velocity, local = 0):
|
|
|
|
"""
|
|
|
|
Sets the game object's linear velocity.
|
|
|
|
|
|
|
|
This method sets game object's velocity through it's centre of mass,
|
|
|
|
ie no angular velocity component.
|
|
|
|
|
|
|
|
@type velocity: 3d vector.
|
|
|
|
@param velocity: linear velocity vector.
|
|
|
|
@type local: boolean
|
|
|
|
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
|
|
|
|
- True: you get the "local" velocity ie: relative to object orientation.
|
|
|
|
"""
|
2008-08-27 03:34:53 +00:00
|
|
|
def getAngularVelocity(local = 0):
|
|
|
|
"""
|
|
|
|
Gets the game object's angular velocity.
|
|
|
|
|
|
|
|
@type local: boolean
|
|
|
|
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
|
|
|
|
- True: you get the "local" velocity ie: relative to object orientation.
|
|
|
|
@rtype: list [vx, vy, vz]
|
|
|
|
@return: the object's angular velocity.
|
|
|
|
"""
|
|
|
|
def setAngularVelocity(velocity, local = 0):
|
|
|
|
"""
|
|
|
|
Sets the game object's angular velocity.
|
|
|
|
|
|
|
|
@type velocity: 3d vector.
|
|
|
|
@param velocity: angular velocity vector.
|
|
|
|
@type local: boolean
|
|
|
|
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
|
|
|
|
- True: you get the "local" velocity ie: relative to object orientation.
|
|
|
|
"""
|
2004-05-24 07:49:50 +00:00
|
|
|
def getVelocity(point):
|
|
|
|
"""
|
|
|
|
Gets the game object's velocity at the specified point.
|
|
|
|
|
|
|
|
Gets the game object's velocity at the specified point, including angular
|
|
|
|
components.
|
|
|
|
|
|
|
|
@type point: list [x, y, z]
|
|
|
|
@param point: the point to return the velocity for, in local coordinates. (optional: default = [0, 0, 0])
|
2004-05-31 13:06:04 +00:00
|
|
|
@rtype: list [vx, vy, vz]
|
|
|
|
@return: the velocity at the specified point.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getMass():
|
|
|
|
"""
|
|
|
|
Gets the game object's mass.
|
|
|
|
|
2004-05-31 13:06:04 +00:00
|
|
|
@rtype: float
|
|
|
|
@return: the object's mass.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getReactionForce():
|
|
|
|
"""
|
|
|
|
Gets the game object's reaction force.
|
|
|
|
|
|
|
|
The reaction force is the force applied to this object over the last simulation timestep.
|
|
|
|
This also includes impulses, eg from collisions.
|
|
|
|
|
2004-05-31 13:06:04 +00:00
|
|
|
@rtype: list [fx, fy, fz]
|
|
|
|
@return: the reaction force of this object.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def applyImpulse(point, impulse):
|
|
|
|
"""
|
|
|
|
Applies an impulse to the game object.
|
|
|
|
|
|
|
|
This will apply the specified impulse to the game object at the specified point.
|
|
|
|
If point != getPosition(), applyImpulse will also change the object's angular momentum.
|
|
|
|
Otherwise, only linear momentum will change.
|
|
|
|
|
|
|
|
@type point: list [x, y, z]
|
|
|
|
@param point: the point to apply the impulse to (in world coordinates)
|
|
|
|
"""
|
|
|
|
def suspendDynamics():
|
|
|
|
"""
|
|
|
|
Suspends physics for this object.
|
|
|
|
"""
|
|
|
|
def restoreDynamics():
|
|
|
|
"""
|
|
|
|
Resumes physics for this object.
|
2008-07-03 01:34:50 +00:00
|
|
|
@Note: The objects linear velocity will be applied from when the dynamics were suspended.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def enableRigidBody():
|
|
|
|
"""
|
|
|
|
Enables rigid body physics for this object.
|
|
|
|
|
|
|
|
Rigid body physics allows the object to roll on collisions.
|
2008-07-03 01:34:50 +00:00
|
|
|
@Note: This is not working with bullet physics yet.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def disableRigidBody():
|
|
|
|
"""
|
|
|
|
Disables rigid body physics for this object.
|
2008-07-03 01:34:50 +00:00
|
|
|
@Note: This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getParent():
|
|
|
|
"""
|
|
|
|
Gets this object's parent.
|
|
|
|
|
2004-06-02 12:43:27 +00:00
|
|
|
@rtype: L{KX_GameObject}
|
2004-05-31 13:06:04 +00:00
|
|
|
@return: this object's parent object, or None if this object has no parent.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
2008-04-06 18:30:52 +00:00
|
|
|
def setParent(parent):
|
|
|
|
"""
|
|
|
|
Sets this object's parent.
|
2008-05-06 20:55:55 +00:00
|
|
|
|
|
|
|
@type parent: L{KX_GameObject}
|
|
|
|
@param parent: new parent object.
|
2008-04-06 18:30:52 +00:00
|
|
|
"""
|
|
|
|
def removeParent():
|
|
|
|
"""
|
|
|
|
Removes this objects parent.
|
|
|
|
"""
|
2008-07-20 17:18:46 +00:00
|
|
|
def getChildren():
|
|
|
|
"""
|
|
|
|
Return a list of immediate children of this object.
|
|
|
|
@rtype: list
|
|
|
|
@return: a list of all this objects children.
|
|
|
|
"""
|
|
|
|
def getChildrenRecursive():
|
|
|
|
"""
|
|
|
|
Return a list of children of this object, including all their childrens children.
|
|
|
|
@rtype: list
|
|
|
|
@return: a list of all this objects children recursivly.
|
|
|
|
"""
|
2004-05-24 07:49:50 +00:00
|
|
|
def getMesh(mesh):
|
|
|
|
"""
|
|
|
|
Gets the mesh object for this object.
|
|
|
|
|
|
|
|
@type mesh: integer
|
|
|
|
@param mesh: the mesh object to return (optional: default mesh = 0)
|
2004-06-02 12:43:27 +00:00
|
|
|
@rtype: L{KX_MeshProxy}
|
2004-05-31 13:06:04 +00:00
|
|
|
@return: the first mesh object associated with this game object, or None if this object has no meshs.
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
def getPhysicsId():
|
|
|
|
"""
|
|
|
|
Returns the user data object associated with this game object's physics controller.
|
|
|
|
"""
|
2008-06-26 12:39:06 +00:00
|
|
|
def getPropertyNames():
|
|
|
|
"""
|
|
|
|
Gets a list of all property names.
|
|
|
|
@rtype: list
|
|
|
|
@return: All property names for this object.
|
|
|
|
"""
|
2005-01-16 05:55:04 +00:00
|
|
|
def getDistanceTo(other):
|
|
|
|
"""
|
|
|
|
Returns the distance to another object or point.
|
|
|
|
|
|
|
|
@param other: a point or another L{KX_GameObject} to measure the distance to.
|
|
|
|
@type other: L{KX_GameObject} or list [x, y, z]
|
|
|
|
@rtype: float
|
|
|
|
"""
|
2008-08-03 21:59:36 +00:00
|
|
|
def getVectTo(other):
|
|
|
|
"""
|
|
|
|
Returns the vector and the distance to another object or point.
|
|
|
|
The vector is normalized unless the distance is 0, in which a NULL vector is returned.
|
|
|
|
|
|
|
|
@param other: a point or another L{KX_GameObject} to get the vector and distance to.
|
|
|
|
@type other: L{KX_GameObject} or list [x, y, z]
|
|
|
|
@rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z))
|
|
|
|
@return: (distance, globalVector(3), localVector(3))
|
|
|
|
"""
|
2008-04-06 20:02:41 +00:00
|
|
|
def rayCastTo(other,dist,prop):
|
|
|
|
"""
|
|
|
|
Look towards another point/object and find first object hit within dist that matches prop.
|
|
|
|
|
|
|
|
The ray is always casted from the center of the object, ignoring the object itself.
|
|
|
|
The ray is casted towards the center of another object or an explicit [x,y,z] point.
|
2008-05-24 22:50:31 +00:00
|
|
|
Use rayCast() if you need to retrieve the hit point
|
2008-04-06 20:02:41 +00:00
|
|
|
|
|
|
|
@param other: [x,y,z] or object towards which the ray is casted
|
2008-05-24 18:06:58 +00:00
|
|
|
@type other: L{KX_GameObject} or 3-tuple
|
2008-04-06 20:02:41 +00:00
|
|
|
@param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
|
|
|
|
@type dist: float
|
|
|
|
@param prop: property name that object must have; can be omitted => detect any object
|
|
|
|
@type prop: string
|
|
|
|
@rtype: L{KX_GameObject}
|
|
|
|
@return: the first object hit or None if no object or object does not match prop
|
|
|
|
"""
|
2008-09-02 22:13:07 +00:00
|
|
|
def rayCast(objto,objfrom,dist,prop,face,xray,poly):
|
2008-05-24 18:06:58 +00:00
|
|
|
"""
|
|
|
|
Look from a point/object to another point/object and find first object hit within dist that matches prop.
|
BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal:
0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
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.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
matname: The name of polygon material, empty if no material.
material: The material of the polygon
texture: The texture name of the polygon.
matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
use this to retrieve vertex proxy from mesh proxy
visible: visible state of the polygon: 1=visible, 0=invisible
collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
getMaterialName(): Returns the polygon material name with MA prefix
getMaterial(): Returns the polygon material
getTextureName(): Returns the polygon texture name
getMaterialIndex(): Returns the material bucket index of the polygon.
getNumVertex(): Returns the number of vertex of the polygon.
isVisible(): Returns whether the polygon is visible or not
isCollider(): Returns whether the polygon is receives collision or not
getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
getNumPolygons(): Returns the number of polygon in the mesh.
getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
2008-08-27 19:34:19 +00:00
|
|
|
if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
|
|
|
|
if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element.
|
2008-09-02 22:13:07 +00:00
|
|
|
|
|
|
|
Ex::
|
2008-05-24 18:06:58 +00:00
|
|
|
# shoot along the axis gun-gunAim (gunAim should be collision-free)
|
2008-05-24 22:50:31 +00:00
|
|
|
ob,point,normal = gun.rayCast(gunAim,None,50)
|
2008-05-24 18:06:58 +00:00
|
|
|
if ob:
|
|
|
|
# hit something
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
The ray ignores the object on which the method is called.
|
BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal:
0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
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.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
matname: The name of polygon material, empty if no material.
material: The material of the polygon
texture: The texture name of the polygon.
matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
use this to retrieve vertex proxy from mesh proxy
visible: visible state of the polygon: 1=visible, 0=invisible
collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
getMaterialName(): Returns the polygon material name with MA prefix
getMaterial(): Returns the polygon material
getTextureName(): Returns the polygon texture name
getMaterialIndex(): Returns the material bucket index of the polygon.
getNumVertex(): Returns the number of vertex of the polygon.
isVisible(): Returns whether the polygon is visible or not
isCollider(): Returns whether the polygon is receives collision or not
getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
getNumPolygons(): Returns the number of polygon in the mesh.
getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
2008-08-27 19:34:19 +00:00
|
|
|
It is casted from/to object center or explicit [x,y,z] points.
|
2008-09-02 22:13:07 +00:00
|
|
|
|
|
|
|
The face paremeter determines the orientation of the normal::
|
BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal:
0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
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.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
matname: The name of polygon material, empty if no material.
material: The material of the polygon
texture: The texture name of the polygon.
matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
use this to retrieve vertex proxy from mesh proxy
visible: visible state of the polygon: 1=visible, 0=invisible
collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
getMaterialName(): Returns the polygon material name with MA prefix
getMaterial(): Returns the polygon material
getTextureName(): Returns the polygon texture name
getMaterialIndex(): Returns the material bucket index of the polygon.
getNumVertex(): Returns the number of vertex of the polygon.
isVisible(): Returns whether the polygon is visible or not
isCollider(): Returns whether the polygon is receives collision or not
getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
getNumPolygons(): Returns the number of polygon in the mesh.
getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
2008-08-27 19:34:19 +00:00
|
|
|
0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
|
|
|
|
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
|
2008-09-02 22:13:07 +00:00
|
|
|
|
BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal:
0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
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.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
matname: The name of polygon material, empty if no material.
material: The material of the polygon
texture: The texture name of the polygon.
matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
use this to retrieve vertex proxy from mesh proxy
visible: visible state of the polygon: 1=visible, 0=invisible
collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
getMaterialName(): Returns the polygon material name with MA prefix
getMaterial(): Returns the polygon material
getTextureName(): Returns the polygon texture name
getMaterialIndex(): Returns the material bucket index of the polygon.
getNumVertex(): Returns the number of vertex of the polygon.
isVisible(): Returns whether the polygon is visible or not
isCollider(): Returns whether the polygon is receives collision or not
getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
getNumPolygons(): Returns the number of polygon in the mesh.
getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
2008-08-27 19:34:19 +00:00
|
|
|
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
|
2008-09-02 22:13:07 +00:00
|
|
|
The prop and xray parameters interact as follow::
|
BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal:
0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
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.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
matname: The name of polygon material, empty if no material.
material: The material of the polygon
texture: The texture name of the polygon.
matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
use this to retrieve vertex proxy from mesh proxy
visible: visible state of the polygon: 1=visible, 0=invisible
collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
getMaterialName(): Returns the polygon material name with MA prefix
getMaterial(): Returns the polygon material
getTextureName(): Returns the polygon texture name
getMaterialIndex(): Returns the material bucket index of the polygon.
getNumVertex(): Returns the number of vertex of the polygon.
isVisible(): Returns whether the polygon is visible or not
isCollider(): Returns whether the polygon is receives collision or not
getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
getNumPolygons(): Returns the number of polygon in the mesh.
getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
2008-08-27 19:34:19 +00:00
|
|
|
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
|
|
|
|
prop off, xray on : idem.
|
|
|
|
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
|
|
|
|
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.
|
|
|
|
The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
|
|
|
|
If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
|
2008-09-02 22:13:07 +00:00
|
|
|
|
|
|
|
The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
|
2008-05-24 18:06:58 +00:00
|
|
|
|
2008-09-02 22:13:07 +00:00
|
|
|
@param objto: [x,y,z] or object to which the ray is casted
|
|
|
|
@type objto: L{KX_GameObject} or 3-tuple
|
|
|
|
@param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center
|
|
|
|
@type objfrom: L{KX_GameObject} or 3-tuple or None
|
2008-05-24 18:06:58 +00:00
|
|
|
@param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
|
|
|
|
@type dist: float
|
|
|
|
@param prop: property name that object must have; can be omitted => detect any object
|
|
|
|
@type prop: string
|
BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal:
0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
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.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
matname: The name of polygon material, empty if no material.
material: The material of the polygon
texture: The texture name of the polygon.
matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
use this to retrieve vertex proxy from mesh proxy
visible: visible state of the polygon: 1=visible, 0=invisible
collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
getMaterialName(): Returns the polygon material name with MA prefix
getMaterial(): Returns the polygon material
getTextureName(): Returns the polygon texture name
getMaterialIndex(): Returns the material bucket index of the polygon.
getNumVertex(): Returns the number of vertex of the polygon.
isVisible(): Returns whether the polygon is visible or not
isCollider(): Returns whether the polygon is receives collision or not
getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
getNumPolygons(): Returns the number of polygon in the mesh.
getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
2008-08-27 19:34:19 +00:00
|
|
|
@param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
|
|
|
|
@type face: int
|
|
|
|
@param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
|
|
|
|
@type xray: int
|
|
|
|
@param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
|
|
|
|
@type poly: int
|
|
|
|
@rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
|
2008-08-31 19:07:10 +00:00
|
|
|
or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
|
BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal:
0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
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.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
matname: The name of polygon material, empty if no material.
material: The material of the polygon
texture: The texture name of the polygon.
matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
use this to retrieve vertex proxy from mesh proxy
visible: visible state of the polygon: 1=visible, 0=invisible
collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
getMaterialName(): Returns the polygon material name with MA prefix
getMaterial(): Returns the polygon material
getTextureName(): Returns the polygon texture name
getMaterialIndex(): Returns the material bucket index of the polygon.
getNumVertex(): Returns the number of vertex of the polygon.
isVisible(): Returns whether the polygon is visible or not
isCollider(): Returns whether the polygon is receives collision or not
getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
getNumPolygons(): Returns the number of polygon in the mesh.
getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
2008-08-27 19:34:19 +00:00
|
|
|
@return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
|
|
|
|
If no hit, returns (None,None,None) or (None,None,None,None)
|
|
|
|
If the object hit is not a static mesh, polygon is None
|
2008-05-24 18:06:58 +00:00
|
|
|
"""
|
2008-06-02 17:31:05 +00:00
|
|
|
|
|
|
|
|