2002-10-12 11:37:38 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2011-02-22 10:33:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file KX_GameObject.h
|
|
|
|
* \ingroup ketsji
|
|
|
|
* \brief General KX game object.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2012-02-23 10:41:31 +00:00
|
|
|
#ifndef __KX_GAMEOBJECT_H__
|
|
|
|
#define __KX_GAMEOBJECT_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-09-15 16:13:32 +00:00
|
|
|
#if defined(WIN32) && !defined(FREE_WINDOWS)
|
2002-10-12 11:37:38 +00:00
|
|
|
// get rid of this stupid "warning 'this' used in initialiser list", generated by VC when including Solid/Sumo
|
|
|
|
#pragma warning (disable : 4355)
|
|
|
|
#endif
|
|
|
|
|
2011-01-27 00:02:25 +00:00
|
|
|
#include <stddef.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "ListValue.h"
|
|
|
|
#include "SCA_IObject.h"
|
|
|
|
#include "SG_Node.h"
|
|
|
|
#include "MT_Transform.h"
|
|
|
|
#include "MT_CmMatrix4x4.h"
|
2011-05-06 20:18:42 +00:00
|
|
|
#include "CTR_Map.h"
|
|
|
|
#include "CTR_HashedPtr.h"
|
2008-04-06 18:30:52 +00:00
|
|
|
#include "KX_Scene.h"
|
2008-06-17 10:06:38 +00:00
|
|
|
#include "KX_KetsjiEngine.h" /* for m_anim_framerate */
|
2008-06-25 14:09:15 +00:00
|
|
|
#include "KX_IPhysicsController.h" /* for suspend/resume */
|
2008-07-15 20:05:23 +00:00
|
|
|
#include "DNA_object_types.h"
|
2008-08-14 08:58:25 +00:00
|
|
|
#include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
|
2002-10-12 11:37:38 +00:00
|
|
|
#define KX_OB_DYNAMIC 1
|
|
|
|
|
|
|
|
//Forward declarations.
|
|
|
|
struct KX_ClientObjectInfo;
|
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
|
|
|
class KX_RayCast;
|
2002-10-12 11:37:38 +00:00
|
|
|
class RAS_MeshObject;
|
|
|
|
class KX_IPhysicsController;
|
2009-04-07 22:14:06 +00:00
|
|
|
class PHY_IGraphicController;
|
2008-03-15 17:08:58 +00:00
|
|
|
class PHY_IPhysicsEnvironment;
|
2011-05-24 07:52:29 +00:00
|
|
|
class BL_ActionManager;
|
2008-06-18 06:46:49 +00:00
|
|
|
struct Object;
|
2010-07-09 22:22:51 +00:00
|
|
|
class KX_ObstacleSimulation;
|
2011-07-05 05:22:02 +00:00
|
|
|
struct bAction;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-04-15 10:57:28 +00:00
|
|
|
/* utility conversion function */
|
2009-04-20 09:13:59 +00:00
|
|
|
bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok, const char *error_prefix);
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2009-04-15 10:57:28 +00:00
|
|
|
|
2009-06-22 04:26:48 +00:00
|
|
|
#ifdef USE_MATHUTILS
|
|
|
|
void KX_GameObject_Mathutils_Callback_Init(void);
|
|
|
|
#endif
|
|
|
|
|
2004-04-24 06:40:15 +00:00
|
|
|
/**
|
|
|
|
* KX_GameObject is the main class for dynamic objects.
|
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
class KX_GameObject : public SCA_IObject
|
|
|
|
{
|
2011-11-06 01:39:36 +00:00
|
|
|
Py_Header
|
2004-05-16 12:52:54 +00:00
|
|
|
protected:
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-24 06:40:15 +00:00
|
|
|
bool m_bDyna;
|
|
|
|
KX_ClientObjectInfo* m_pClient_info;
|
|
|
|
STR_String m_name;
|
|
|
|
STR_String m_text;
|
2008-04-30 19:58:44 +00:00
|
|
|
int m_layer;
|
2002-10-12 11:37:38 +00:00
|
|
|
std::vector<RAS_MeshObject*> m_meshes;
|
BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive
performance improvement in the culling and in the rasterizer when
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms) 2.48 1st round 3rd round
All objects static, 323.0 86.0 7.2
all visible, 1000 in
the view frustrum
All objects static, 219.0 49.7 N/A(*)
all invisible.
All objects moving, 323.0 105.6 34.7
all visible, 1000 in
the view frustrum
Scene destruction 40min 40min 4s
(*) : this time is not representative because the frame rate was at 60fps.
In that case, the GPU holds down the GE by frame sync. By design, the
overhead of the rasterizer is 0 when the the objects are invisible.
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
2009-05-07 09:13:01 +00:00
|
|
|
SG_QList m_meshSlots; // head of mesh slots of this
|
2008-06-18 06:46:49 +00:00
|
|
|
struct Object* m_pBlenderObject;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
struct Object* m_pBlenderGroupObject;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-24 06:40:15 +00:00
|
|
|
bool m_bSuspendDynamics;
|
|
|
|
bool m_bUseObjectColor;
|
2008-05-25 14:37:39 +00:00
|
|
|
bool m_bIsNegativeScaling;
|
2004-04-24 06:40:15 +00:00
|
|
|
MT_Vector4 m_objectColor;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
// visible = user setting
|
|
|
|
// culled = while rendering, depending on camera
|
|
|
|
bool m_bVisible;
|
|
|
|
bool m_bCulled;
|
2009-04-13 20:08:33 +00:00
|
|
|
bool m_bOccluder;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-24 06:40:15 +00:00
|
|
|
KX_IPhysicsController* m_pPhysicsController1;
|
2009-04-07 22:14:06 +00:00
|
|
|
PHY_IGraphicController* m_pGraphicController;
|
2008-03-15 17:08:58 +00:00
|
|
|
STR_String m_testPropName;
|
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
|
|
|
bool m_xray;
|
2008-03-15 17:08:58 +00:00
|
|
|
KX_GameObject* m_pHitObject;
|
|
|
|
|
2004-04-24 06:40:15 +00:00
|
|
|
SG_Node* m_pSGNode;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-24 06:40:15 +00:00
|
|
|
MT_CmMatrix4x4 m_OpenGL_4x4Matrix;
|
2010-06-16 00:23:24 +00:00
|
|
|
|
2010-07-09 22:22:51 +00:00
|
|
|
KX_ObstacleSimulation* m_pObstacleSimulation;
|
2011-02-16 17:07:18 +00:00
|
|
|
|
2011-09-07 15:34:04 +00:00
|
|
|
|
2011-05-24 07:52:29 +00:00
|
|
|
// The action manager is used to play/stop/update actions
|
|
|
|
BL_ActionManager* m_actionManager;
|
2011-06-11 00:22:35 +00:00
|
|
|
|
|
|
|
BL_ActionManager* GetActionManager();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
public:
|
Patch: [ #2439 ] Makes objects react properly to deformations after a mesh replacement call.
from brian hayward (bthayward)
Detailed description:
Currently, when an armature deformed object's mesh is replaced by the ReplaceMesh actuator, the new mesh fails to deform to the armature's movement.
My patch fixes this by properly replacing the deform controller along with the mesh (when appropriete).
For instance, if one had an animated character using any of the standard deformation techniques (armature, ipo, RVK, or AVK), that character's mesh would currently be prevented from changing mid-game. It could be replaced, but the new mesh would lack the controller which tells it how to deform. If one wanted to dynamiclly add a hat on top of the character's head, it would require storing a secondary prebuilt character (mesh, armature, logic, ect...) on another layer FOR EACH HAT the character could possibly wear, then swapping out the whole character when the hat change was desired. So if you had 4 possible hat/character combos, you would have 4 character meshes, 4 armatures, 4 sets of logic, and so on. I find this lack of flexibility to be unresonable.
With my patch, one could accomplish the same thing mearly by making one version of the character in the main layer, and adding an invisible object atop the character's head (which is parented to the head bone). Then whenever it becomes desirable, one can replace the invisible object's mesh with the desirable hat's mesh, then make it visible. With my patch, the hat object would then continue to deform to the character's head regardless of which hat was currently being worn.
*note 1*
for armature/mesh deformations, the new mesh must have properly assigned vertex groups which match one or more of the bones of the target armature before the replaceMesh call is made. Otherwise the vertices won't react to the armature because they won't know how. (not sure if vertices can be scripted to change groups after the game has started)
*note 2*
The added processing time involved with replacing the object's deform controller is negligible.
2005-04-18 11:44:21 +00:00
|
|
|
bool m_isDeformable;
|
|
|
|
|
2009-04-13 20:08:33 +00:00
|
|
|
/**
|
|
|
|
* Helper function for modules that can't include KX_ClientObjectInfo.h
|
|
|
|
*/
|
|
|
|
static KX_GameObject* GetClientObject(KX_ClientObjectInfo* info);
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-04-12 14:22:51 +00:00
|
|
|
// Python attributes that wont convert into CValue
|
|
|
|
//
|
|
|
|
// there are 2 places attributes can be stored, in the CValue,
|
|
|
|
// where attributes are converted into BGE's CValue types
|
|
|
|
// these can be used with property actuators
|
|
|
|
//
|
|
|
|
// For the python API, For types that cannot be converted into CValues (lists, dicts, GameObjects)
|
2009-04-17 20:06:06 +00:00
|
|
|
// these will be put into "m_attr_dict", logic bricks cannot access them.
|
2009-04-12 14:22:51 +00:00
|
|
|
//
|
|
|
|
// rules for setting attributes.
|
|
|
|
//
|
2009-04-17 20:06:06 +00:00
|
|
|
// * there should NEVER be a CValue and a m_attr_dict attribute with matching names. get/sets make sure of this.
|
|
|
|
// * if CValue conversion fails, use a PyObject in "m_attr_dict"
|
|
|
|
// * when assigning a value, first see if it can be a CValue, if it can remove the "m_attr_dict" and set the CValue
|
2009-04-12 14:22:51 +00:00
|
|
|
//
|
2009-04-17 20:06:06 +00:00
|
|
|
PyObject* m_attr_dict;
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2009-04-12 14:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
virtual void /* This function should be virtual - derived classed override it */
|
|
|
|
Relink(
|
2011-05-06 20:18:42 +00:00
|
|
|
CTR_Map<CTR_HashedPtr, void*> *map
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2012-03-04 04:35:12 +00:00
|
|
|
* Compute an OpenGl compatible 4x4 matrix. Has the
|
2002-10-12 11:37:38 +00:00
|
|
|
* side effect of storing the result internally. The
|
|
|
|
* memory for the matrix remains the property of this class.
|
|
|
|
*/
|
|
|
|
double*
|
|
|
|
GetOpenGLMatrix(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a pointer to a MT_CmMatrix4x4 storing the
|
|
|
|
* opengl transformation for this object. This is updated
|
|
|
|
* by a call to GetOpenGLMatrix(). This class owns the
|
|
|
|
* memory for the returned matrix.
|
|
|
|
*/
|
|
|
|
|
|
|
|
MT_CmMatrix4x4*
|
|
|
|
GetOpenGLMatrixPtr(
|
|
|
|
) {
|
|
|
|
return &m_OpenGL_4x4Matrix;
|
|
|
|
};
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
/**
|
|
|
|
* Update the blender object obmat field from the object world position
|
|
|
|
* if blendobj is NULL, update the object pointed by m_pBlenderObject
|
|
|
|
* The user must take action to restore the matrix before leaving the GE.
|
|
|
|
* Used in Armature evaluation
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
UpdateBlenderObjectMatrix(Object* blendobj=NULL);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Get a pointer to the game object that is the parent of
|
|
|
|
* this object. Or NULL if there is no parent. The returned
|
|
|
|
* object is part of a reference counting scheme. Calling
|
|
|
|
* this function ups the reference count on the returned
|
|
|
|
* object. It is the responsibility of the caller to decrement
|
|
|
|
* the reference count when you have finished with it.
|
|
|
|
*/
|
|
|
|
KX_GameObject*
|
|
|
|
GetParent(
|
|
|
|
);
|
|
|
|
|
2008-04-06 18:30:52 +00:00
|
|
|
/**
|
|
|
|
* Sets the parent of this object to a game object
|
|
|
|
*/
|
BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
(objects without parent).
* Nesting of compound shape is not possible: a child
object with "Add to parent" button set will be added
to the top parent compound shape, regardless of its
position in the parent-child hierarchy and even if its
immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound
shape, it looses temporarily all its physics capability
to the benefit of the parent: it cannot register collisions
and the characteristics of its shape are lost (ghost, sensor,
dynamic, etc.).
* Nested compound shape is not supported: if the object
being parented is already a compound shape, it is not
added to the compound parent (as if the Compound option
was not set in the actuator or the setParent function).
* To ensure compatibility with old blend files, the Blender
subversion is changed to 2.48.5 and the old blend files
are automatically converted to match the old behavior:
all children of a Compound object will have the "Add to
parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
ghost all the time.
* Make sure the child object does not enter in collision with
the parent shape when the Ghost option if off and the parent is
dynamic: the collision creates a reaction force but the parent
cannot escape the child, so the force builds up and produces
eratic movements.
* The collision capability of an ordinary object (dynamic or static)
is limited when it is parented: it becomes automatically static
and can only detect dynamic and sensor objects.
* A sensor object retain its full collision capability when parented:
it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
Sets this object's parent.
Control the shape status with the optional compound and ghost parameters:
compound=1: the object shape should be added to the parent compound shape (default)
compound=0: the object should keep its individual shape.
In that case you can control if it should be ghost or not:
ghost=1 if the object should be made ghost while parented (default)
ghost=0 if the object should be solid while parented
Note: if the object type is sensor, it stays ghost regardless of ghost parameter
parent: KX_GameObject reference or string (object name w/o OB prefix)
2009-05-21 13:32:15 +00:00
|
|
|
void SetParent(KX_Scene *scene, KX_GameObject *obj, bool addToCompound=true, bool ghost=true);
|
2008-04-06 18:30:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the parent of this object to a game object
|
|
|
|
*/
|
|
|
|
void RemoveParent(KX_Scene *scene);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-06-01 07:42:40 +00:00
|
|
|
/*********************************
|
|
|
|
* Animation API
|
|
|
|
*********************************/
|
|
|
|
|
2011-06-01 05:46:19 +00:00
|
|
|
/**
|
|
|
|
* Adds an action to the object's action manager
|
|
|
|
*/
|
2011-06-29 01:53:17 +00:00
|
|
|
bool PlayAction(const char* name,
|
2011-06-01 05:46:19 +00:00
|
|
|
float start,
|
|
|
|
float end,
|
|
|
|
short layer=0,
|
2011-06-23 22:12:49 +00:00
|
|
|
short priority=0,
|
2011-06-01 05:46:19 +00:00
|
|
|
float blendin=0.f,
|
|
|
|
short play_mode=0,
|
2011-07-03 01:59:17 +00:00
|
|
|
float layer_weight=0.f,
|
2011-06-16 01:18:52 +00:00
|
|
|
short ipo_flags=0,
|
2011-06-01 05:46:19 +00:00
|
|
|
float playback_speed=1.f);
|
|
|
|
|
2011-06-01 07:42:40 +00:00
|
|
|
/**
|
|
|
|
* Gets the current frame of an action
|
|
|
|
*/
|
|
|
|
float GetActionFrame(short layer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current frame of an action
|
|
|
|
*/
|
|
|
|
void SetActionFrame(short layer, float frame);
|
|
|
|
|
2011-07-05 05:22:02 +00:00
|
|
|
/**
|
|
|
|
* Gets the currently running action on the given layer
|
|
|
|
*/
|
|
|
|
bAction *GetCurrentAction(short layer);
|
|
|
|
|
2011-08-08 04:28:30 +00:00
|
|
|
/**
|
|
|
|
* Sets play mode of the action on the given layer
|
|
|
|
*/
|
|
|
|
void SetPlayMode(short layer, short mode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the start and end times of the action on the given layer
|
|
|
|
*/
|
|
|
|
void SetTimes(short layer, float start, float end);
|
|
|
|
|
2011-06-01 05:46:19 +00:00
|
|
|
/**
|
2011-07-07 03:53:24 +00:00
|
|
|
* Stop playing the action on the given layer
|
2011-06-01 05:46:19 +00:00
|
|
|
*/
|
|
|
|
void StopAction(short layer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if an action has finished playing
|
|
|
|
*/
|
|
|
|
bool IsActionDone(short layer);
|
|
|
|
|
2011-05-24 07:52:29 +00:00
|
|
|
/**
|
|
|
|
* Kick the object's action manager
|
|
|
|
*/
|
|
|
|
void UpdateActionManager(float curtime);
|
|
|
|
|
2011-06-01 07:42:40 +00:00
|
|
|
/*********************************
|
|
|
|
* End Animation API
|
|
|
|
*********************************/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Construct a game object. This class also inherits the
|
|
|
|
* default constructors - use those with care!
|
|
|
|
*/
|
|
|
|
|
|
|
|
KX_GameObject(
|
|
|
|
void* sgReplicationInfo,
|
2009-06-28 11:22:26 +00:00
|
|
|
SG_Callbacks callbacks
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
virtual
|
|
|
|
~KX_GameObject(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section Stuff which is here due to poor design.
|
2002-10-12 11:37:38 +00:00
|
|
|
* Inherited from CValue and needs an implementation.
|
|
|
|
* Do not expect these functions do to anything sensible.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- does nothing!
|
|
|
|
*/
|
|
|
|
CValue*
|
|
|
|
Calc(
|
|
|
|
VALUE_OPERATOR op,
|
|
|
|
CValue *val
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- does nothing!
|
|
|
|
*/
|
|
|
|
CValue*
|
|
|
|
CalcFinal(
|
|
|
|
VALUE_DATA_TYPE dtype,
|
|
|
|
VALUE_OPERATOR op,
|
|
|
|
CValue *val
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- does nothing!
|
|
|
|
*/
|
|
|
|
const
|
|
|
|
STR_String &
|
|
|
|
GetText(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- does nothing!
|
|
|
|
*/
|
2009-04-12 06:41:01 +00:00
|
|
|
double
|
2002-10-12 11:37:38 +00:00
|
|
|
GetNumber(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section Inherited from CValue. These are the useful
|
2002-10-12 11:37:38 +00:00
|
|
|
* part of the CValue interface that this class implements.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- returns the name of this object.
|
|
|
|
*/
|
2009-05-10 20:53:58 +00:00
|
|
|
STR_String&
|
2002-10-12 11:37:38 +00:00
|
|
|
GetName(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- set the name of this object.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetName(
|
2009-05-10 20:53:58 +00:00
|
|
|
const char *name
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- return a new copy of this
|
|
|
|
* instance allocated on the heap. Ownership of the new
|
|
|
|
* object belongs with the caller.
|
|
|
|
*/
|
2004-03-22 22:02:18 +00:00
|
|
|
virtual CValue*
|
2002-10-12 11:37:38 +00:00
|
|
|
GetReplica(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited from CValue -- Makes sure any internal
|
|
|
|
* data owned by this class is deep copied. Called internally
|
|
|
|
*/
|
2004-03-22 22:02:18 +00:00
|
|
|
virtual void
|
2009-04-22 12:16:41 +00:00
|
|
|
ProcessReplica();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the linear velocity of the game object.
|
|
|
|
*/
|
2008-05-06 20:55:55 +00:00
|
|
|
MT_Vector3
|
2002-10-12 11:37:38 +00:00
|
|
|
GetLinearVelocity(
|
2008-05-06 20:55:55 +00:00
|
|
|
bool local=false
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
2008-10-01 07:55:02 +00:00
|
|
|
/**
|
|
|
|
* Return the linear velocity of a given point in world coordinate
|
|
|
|
* but relative to center of object ([0,0,0]=center of object)
|
|
|
|
*/
|
|
|
|
MT_Vector3
|
|
|
|
GetVelocity(
|
|
|
|
const MT_Point3& position
|
|
|
|
);
|
|
|
|
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
/**
|
|
|
|
* Return the mass of the object
|
|
|
|
*/
|
|
|
|
MT_Scalar
|
|
|
|
GetMass();
|
|
|
|
|
2009-04-08 16:25:00 +00:00
|
|
|
/**
|
|
|
|
* Return the local inertia vector of the object
|
|
|
|
*/
|
|
|
|
MT_Vector3
|
|
|
|
GetLocalInertia();
|
|
|
|
|
2008-06-24 19:37:43 +00:00
|
|
|
/**
|
|
|
|
* Return the angular velocity of the game object.
|
|
|
|
*/
|
|
|
|
MT_Vector3
|
|
|
|
GetAngularVelocity(
|
|
|
|
bool local=false
|
|
|
|
);
|
|
|
|
|
2008-06-02 17:31:05 +00:00
|
|
|
/**
|
|
|
|
* Align the object to a given normal.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
AlignAxisToVect(
|
|
|
|
const MT_Vector3& vect,
|
added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
up_nor = Vector(0,0,1)
own_mat = Matrix(*own.getOrientation()).transpose()
own_up = up_nor * own_mat
ang = AngleBetweenVecs(own_up, up_nor)
if ang > 0.005:
# Set orientation
cross = CrossVecs(own_up, up_nor)
new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
own.setOrientation(new_mat.transpose())
M source/gameengine/Ketsji/KX_GameObject.cpp
M source/gameengine/Ketsji/KX_GameObject.h
2008-07-09 09:21:52 +00:00
|
|
|
int axis = 2,
|
|
|
|
float fac = 1.0
|
2008-06-02 17:31:05 +00:00
|
|
|
);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Quick'n'dirty obcolor ipo stuff
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
SetObjectColor(
|
|
|
|
const MT_Vector4& rgbavec
|
|
|
|
);
|
|
|
|
|
2010-01-16 23:53:51 +00:00
|
|
|
const MT_Vector4&
|
|
|
|
GetObjectColor();
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-08 11:34:50 +00:00
|
|
|
void
|
|
|
|
ResolveCombinedVelocities(
|
|
|
|
const MT_Vector3 & lin_vel,
|
|
|
|
const MT_Vector3 & ang_vel,
|
|
|
|
bool lin_vel_local,
|
|
|
|
bool ang_vel_local
|
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \return a pointer to the physics controller owned by this class.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
KX_IPhysicsController* GetPhysicsController();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
void SetPhysicsController(KX_IPhysicsController* physicscontroller,bool isDynamic)
|
|
|
|
{
|
|
|
|
m_bDyna = isDynamic;
|
|
|
|
m_pPhysicsController1 = physicscontroller;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-24 03:12:10 +00:00
|
|
|
virtual class RAS_Deformer* GetDeformer()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
virtual void SetDeformer(class RAS_Deformer* deformer)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-04-07 22:14:06 +00:00
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \return a pointer to the graphic controller owner by this class
|
2009-04-07 22:14:06 +00:00
|
|
|
*/
|
|
|
|
PHY_IGraphicController* GetGraphicController()
|
|
|
|
{
|
|
|
|
return m_pGraphicController;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetGraphicController(PHY_IGraphicController* graphiccontroller)
|
|
|
|
{
|
|
|
|
m_pGraphicController = graphiccontroller;
|
|
|
|
}
|
2009-05-01 19:02:23 +00:00
|
|
|
/*
|
|
|
|
* @add/remove the graphic controller to the physic system
|
|
|
|
*/
|
BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
* Actor option: the collisioning object must have the Actor flag set to be detected
* property/material: as specified in the collision sensors attached to it
Broadphase filtering is important for performance reason: the collision points
will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
to the suface by increasing the margin in the Advanced Settings panel.
The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
because of the Scenegraph optimizations and they can have multiple collision sensors
on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
"warning btCollisionDispatcher::needsCollision: static-static collision!"
In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects
2009-05-17 12:51:51 +00:00
|
|
|
void ActivateGraphicController(bool recurse);
|
2009-04-07 22:14:06 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section Coordinate system manipulation functions
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
void NodeSetLocalPosition(const MT_Point3& trans );
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
void NodeSetLocalOrientation(const MT_Matrix3x3& rot );
|
2009-06-23 13:34:45 +00:00
|
|
|
void NodeSetGlobalOrientation(const MT_Matrix3x3& rot );
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
void NodeSetLocalScale( const MT_Vector3& scale );
|
cucumber merge: world scaling + video texture constants
revisions: 38166,38167,38177,38179,38180,38187,38242
To be implemented after merge:
1) add pydocs(rst) for the video texture new defines
2) see if a NodeSetLocalMatrix would fit well
#43439 by kupoman
Changing the worldTransform and localTransform python attributes to use BLI_math to simplify the code
#38242 by kupoman
Adding the constants SOURCE_ERROR, SOURCE_EMPTY, SOURCE_READY, SOURCE_PLAYING, SOURCE_STOPPED to the video texture module. Updates to the documentation will follow after a merge with trunk
#38187 by kupoman
Updates to the documentation to reflect that worldScale is now writable, and added localTransform and worldTransform to KX_GameObject.
#38180 by kupoman
The Transform attribute of KX_GameObject was based on world space data. I converted that one to worldTransform, and added a localTransform for local space transform information.
#38179 by kupoman
Fixed the transform attribute of KX_GameObject's set method to properly deal with negative scaling.
#38177 by kupoman
Updated the transform property on KX_GameObject so that it is now read/write, and added the corresponding set method. Also simplified the get method by calling GetOpenGLMatrix instead of making the matrix myself.
#38167 by kupoman
Adding a read only transform attribute to KX_GameObject that returns a 4x4 matrix representing the object's transformations.
#38166 by kupoman
Adding a worldScale attribute to KX_GameObject. This attribute scales the object independently of its parent's scale.
2012-01-22 03:21:28 +00:00
|
|
|
void NodeSetWorldScale( const MT_Vector3& scale );
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
void NodeSetRelativeScale( const MT_Vector3& scale );
|
2002-10-12 11:37:38 +00:00
|
|
|
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
// adapt local position so that world position is set to desired position
|
|
|
|
void NodeSetWorldPosition(const MT_Point3& trans);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void
|
|
|
|
NodeUpdateGS(
|
2009-04-07 22:14:06 +00:00
|
|
|
double time
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
2009-06-23 13:34:45 +00:00
|
|
|
const MT_Matrix3x3& NodeGetWorldOrientation( ) const;
|
|
|
|
const MT_Vector3& NodeGetWorldScaling( ) const;
|
|
|
|
const MT_Point3& NodeGetWorldPosition( ) const;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-06-23 13:34:45 +00:00
|
|
|
const MT_Matrix3x3& NodeGetLocalOrientation( ) const;
|
|
|
|
const MT_Vector3& NodeGetLocalScaling( ) const;
|
|
|
|
const MT_Point3& NodeGetLocalPosition( ) const;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section scene graph node accessor functions.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
SG_Node* GetSGNode( )
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
return m_pSGNode;
|
|
|
|
}
|
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
const SG_Node* GetSGNode( ) const
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
return m_pSGNode;
|
|
|
|
}
|
|
|
|
|
2008-06-18 06:46:49 +00:00
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section blender object accessor functions.
|
2008-06-18 06:46:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct Object* GetBlenderObject( )
|
|
|
|
{
|
|
|
|
return m_pBlenderObject;
|
|
|
|
}
|
|
|
|
|
2012-03-11 19:09:01 +00:00
|
|
|
void SetBlenderObject(struct Object* obj)
|
2008-06-18 06:46:49 +00:00
|
|
|
{
|
|
|
|
m_pBlenderObject = obj;
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
struct Object* GetBlenderGroupObject( )
|
|
|
|
{
|
|
|
|
return m_pBlenderGroupObject;
|
|
|
|
}
|
|
|
|
|
2012-03-11 19:09:01 +00:00
|
|
|
void SetBlenderGroupObject(struct Object* obj)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
m_pBlenderGroupObject = obj;
|
|
|
|
}
|
2008-06-18 06:46:49 +00:00
|
|
|
|
2008-07-15 20:05:23 +00:00
|
|
|
bool IsDupliGroup()
|
|
|
|
{
|
|
|
|
return (m_pBlenderObject &&
|
|
|
|
(m_pBlenderObject->transflag & OB_DUPLIGROUP) &&
|
|
|
|
m_pBlenderObject->dup_group != NULL) ? true : false;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Set the Scene graph node for this game object.
|
|
|
|
* warning - it is your responsibility to make sure
|
|
|
|
* all controllers look at this new node. You must
|
|
|
|
* also take care of the memory associated with the
|
|
|
|
* old node. This class takes ownership of the new
|
|
|
|
* node.
|
|
|
|
*/
|
2005-08-22 18:31:19 +00:00
|
|
|
void SetSGNode(SG_Node* node )
|
|
|
|
{
|
|
|
|
m_pSGNode = node;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-22 18:31:19 +00:00
|
|
|
//Is it a dynamic/physics object ?
|
|
|
|
bool IsDynamic() const
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
return m_bDyna;
|
|
|
|
}
|
2008-05-14 20:22:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if this object has a vertex parent relationship
|
|
|
|
*/
|
|
|
|
bool IsVertexParent( )
|
|
|
|
{
|
|
|
|
return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
|
|
|
|
bool NeedRayCast(KX_ClientObjectInfo* client);
|
2008-03-15 17:08:58 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section Physics accessors for this node.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* All these calls get passed directly to the physics controller
|
|
|
|
* owned by this object.
|
|
|
|
* This is real interface bloat. Why not just use the physics controller
|
|
|
|
* directly? I think this is because the python interface is in the wrong
|
|
|
|
* place.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
ApplyForce(
|
|
|
|
const MT_Vector3& force, bool local
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
ApplyTorque(
|
|
|
|
const MT_Vector3& torque,
|
|
|
|
bool local
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
ApplyRotation(
|
|
|
|
const MT_Vector3& drot,
|
|
|
|
bool local
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
ApplyMovement(
|
|
|
|
const MT_Vector3& dloc,
|
|
|
|
bool local
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
addLinearVelocity(
|
|
|
|
const MT_Vector3& lin_vel,
|
|
|
|
bool local
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
setLinearVelocity(
|
|
|
|
const MT_Vector3& lin_vel,
|
|
|
|
bool local
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
setAngularVelocity(
|
|
|
|
const MT_Vector3& ang_vel,
|
|
|
|
bool local
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the physics object transform based upon the current SG_Node
|
|
|
|
* position.
|
|
|
|
*/
|
2004-05-26 12:06:41 +00:00
|
|
|
void
|
2002-10-12 11:37:38 +00:00
|
|
|
UpdateTransform(
|
|
|
|
);
|
|
|
|
|
2004-05-26 12:06:41 +00:00
|
|
|
static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
|
|
|
|
|
BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
* Actor option: the collisioning object must have the Actor flag set to be detected
* property/material: as specified in the collision sensors attached to it
Broadphase filtering is important for performance reason: the collision points
will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
to the suface by increasing the margin in the Advanced Settings panel.
The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
because of the Scenegraph optimizations and they can have multiple collision sensors
on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
"warning btCollisionDispatcher::needsCollision: static-static collision!"
In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects
2009-05-17 12:51:51 +00:00
|
|
|
/**
|
|
|
|
* only used for sensor objects
|
|
|
|
*/
|
|
|
|
void SynchronizeTransform();
|
|
|
|
|
|
|
|
static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
|
|
|
|
|
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
|
|
|
/**
|
|
|
|
* Function to set IPO option at start of IPO
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
InitIPO(
|
|
|
|
bool ipo_as_force,
|
|
|
|
bool ipo_add,
|
|
|
|
bool ipo_local
|
|
|
|
);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Odd function to update an ipo. ???
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
UpdateIPO(
|
|
|
|
float curframetime,
|
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
|
|
|
bool recurse
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
2006-01-06 03:46:54 +00:00
|
|
|
/**
|
|
|
|
* Updates Material Ipo data
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
UpdateMaterialData(
|
2008-07-25 13:45:57 +00:00
|
|
|
dword matname_hash,
|
2006-01-06 03:46:54 +00:00
|
|
|
MT_Vector4 rgba,
|
|
|
|
MT_Vector3 specrgb,
|
|
|
|
MT_Scalar hard,
|
|
|
|
MT_Scalar spec,
|
|
|
|
MT_Scalar ref,
|
|
|
|
MT_Scalar emit,
|
|
|
|
MT_Scalar alpha
|
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section Mesh accessor functions.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update buckets to indicate that there is a new
|
|
|
|
* user of this object's meshes.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
AddMeshUser(
|
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
* Update buckets with data about the mesh after
|
|
|
|
* creating or duplicating the object, changing
|
|
|
|
* visibility, object color, .. .
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
void
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
UpdateBuckets(
|
2008-09-05 16:22:14 +00:00
|
|
|
bool recursive
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the meshes associated with this class
|
|
|
|
* and remove from the bucketing system.
|
|
|
|
* Don't think this actually deletes any of the meshes.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
RemoveMeshes(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a mesh to the set of meshes associated with this
|
|
|
|
* node. Meshes added in this way are not deleted by this class.
|
|
|
|
* Make sure you call RemoveMeshes() before deleting the
|
|
|
|
* mesh though,
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
AddMesh(
|
|
|
|
RAS_MeshObject* mesh
|
|
|
|
){
|
|
|
|
m_meshes.push_back(mesh);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pick out a mesh associated with the integer 'num'.
|
|
|
|
*/
|
|
|
|
RAS_MeshObject*
|
|
|
|
GetMesh(
|
|
|
|
int num
|
|
|
|
) const {
|
|
|
|
return m_meshes[num];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the number of meshes currently associated with this
|
|
|
|
* game object.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
GetMeshCount(
|
|
|
|
) const {
|
|
|
|
return m_meshes.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the debug color of the meshes associated with this
|
|
|
|
* class. Does this still work?
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetDebugColor(
|
|
|
|
unsigned int bgra
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset the debug color of meshes associated with this class.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ResetDebugColor(
|
|
|
|
);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/**
|
|
|
|
* Was this object marked visible? (only for the explicit
|
|
|
|
* visibility system).
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
bool
|
|
|
|
GetVisible(
|
|
|
|
void
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/**
|
|
|
|
* Set visibility flag of this object
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
void
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
SetVisible(
|
2008-09-05 16:22:14 +00:00
|
|
|
bool b,
|
|
|
|
bool recursive
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
* Was this object culled?
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2009-04-13 20:08:33 +00:00
|
|
|
inline bool
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GetCulled(
|
2002-10-12 11:37:38 +00:00
|
|
|
void
|
2009-04-13 20:08:33 +00:00
|
|
|
) { return m_bCulled; }
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
* Set culled flag of this object
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2009-04-13 20:08:33 +00:00
|
|
|
inline void
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
SetCulled(
|
|
|
|
bool c
|
2009-04-13 20:08:33 +00:00
|
|
|
) { m_bCulled = c; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is this object an occluder?
|
|
|
|
*/
|
|
|
|
inline bool
|
|
|
|
GetOccluder(
|
|
|
|
void
|
|
|
|
) { return m_bOccluder; }
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-04-13 20:08:33 +00:00
|
|
|
/**
|
|
|
|
* Set occluder flag of this object
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetOccluder(
|
|
|
|
bool v,
|
|
|
|
bool recursive
|
|
|
|
);
|
|
|
|
|
2008-04-30 19:58:44 +00:00
|
|
|
/**
|
|
|
|
* Change the layer of the object (when it is added in another layer
|
|
|
|
* than the original layer)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetLayer(
|
|
|
|
int l
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the object layer
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
GetLayer(
|
|
|
|
void
|
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-05-25 14:37:39 +00:00
|
|
|
/**
|
|
|
|
* Get the negative scaling state
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
IsNegativeScaling(
|
|
|
|
void
|
|
|
|
) { return m_bIsNegativeScaling; }
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section Logic bubbling methods.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop making progress
|
|
|
|
*/
|
|
|
|
void Suspend(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resume making progress
|
|
|
|
*/
|
|
|
|
void Resume(void);
|
|
|
|
|
2008-06-25 14:09:15 +00:00
|
|
|
void SuspendDynamics(void) {
|
|
|
|
if (m_bSuspendDynamics)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_pPhysicsController1)
|
|
|
|
{
|
|
|
|
m_pPhysicsController1->SuspendDynamics();
|
|
|
|
}
|
|
|
|
m_bSuspendDynamics = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RestoreDynamics(void) {
|
|
|
|
if (!m_bSuspendDynamics)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_pPhysicsController1)
|
|
|
|
{
|
|
|
|
m_pPhysicsController1->RestoreDynamics();
|
|
|
|
}
|
|
|
|
m_bSuspendDynamics = false;
|
|
|
|
}
|
2010-06-16 00:23:24 +00:00
|
|
|
|
2010-07-09 22:22:51 +00:00
|
|
|
void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
|
2010-06-16 00:23:24 +00:00
|
|
|
{
|
2010-07-09 22:22:51 +00:00
|
|
|
m_pObstacleSimulation = obstacleSimulation;
|
2010-06-16 00:23:24 +00:00
|
|
|
}
|
2011-02-16 17:07:18 +00:00
|
|
|
|
2010-06-16 00:23:24 +00:00
|
|
|
void UnregisterObstacle()
|
|
|
|
{
|
2010-07-09 22:22:51 +00:00
|
|
|
m_pObstacleSimulation = NULL;
|
2010-06-16 00:23:24 +00:00
|
|
|
}
|
2008-06-25 14:09:15 +00:00
|
|
|
|
2004-03-22 22:02:18 +00:00
|
|
|
KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
|
2009-04-19 12:46:39 +00:00
|
|
|
|
|
|
|
CListValue* GetChildren();
|
|
|
|
CListValue* GetChildrenRecursive();
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
2012-03-02 16:05:54 +00:00
|
|
|
* \section Python interface functions.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2009-04-15 10:57:28 +00:00
|
|
|
virtual PyObject* py_repr(void)
|
2009-04-12 14:22:51 +00:00
|
|
|
{
|
2011-12-30 12:44:16 +00:00
|
|
|
return PyUnicode_From_STR_String(GetName());
|
2009-04-12 14:22:51 +00:00
|
|
|
}
|
2009-08-25 22:51:18 +00:00
|
|
|
|
2008-09-09 22:40:10 +00:00
|
|
|
KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
|
2008-12-09 04:13:23 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce);
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque);
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject, ApplyRotation);
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject, ApplyMovement);
|
2008-08-27 03:34:53 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
|
2009-08-25 22:51:18 +00:00
|
|
|
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
|
2009-08-25 22:51:18 +00:00
|
|
|
|
|
|
|
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
|
2008-09-05 16:22:14 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
|
2009-04-13 20:08:33 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,SetOcclusion);
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
|
|
|
|
KX_PYMETHOD_O(KX_GameObject,SetState);
|
2008-08-27 03:34:53 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
|
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,SuspendDynamics);
|
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
|
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
|
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
|
2008-08-27 03:34:53 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
|
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
|
BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
(objects without parent).
* Nesting of compound shape is not possible: a child
object with "Add to parent" button set will be added
to the top parent compound shape, regardless of its
position in the parent-child hierarchy and even if its
immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound
shape, it looses temporarily all its physics capability
to the benefit of the parent: it cannot register collisions
and the characteristics of its shape are lost (ghost, sensor,
dynamic, etc.).
* Nested compound shape is not supported: if the object
being parented is already a compound shape, it is not
added to the compound parent (as if the Compound option
was not set in the actuator or the setParent function).
* To ensure compatibility with old blend files, the Blender
subversion is changed to 2.48.5 and the old blend files
are automatically converted to match the old behavior:
all children of a Compound object will have the "Add to
parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
ghost all the time.
* Make sure the child object does not enter in collision with
the parent shape when the Ghost option if off and the parent is
dynamic: the collision creates a reaction force but the parent
cannot escape the child, so the force builds up and produces
eratic movements.
* The collision capability of an ordinary object (dynamic or static)
is limited when it is parented: it becomes automatically static
and can only detect dynamic and sensor objects.
* A sensor object retain its full collision capability when parented:
it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
Sets this object's parent.
Control the shape status with the optional compound and ghost parameters:
compound=1: the object shape should be added to the parent compound shape (default)
compound=0: the object should keep its individual shape.
In that case you can control if it should be ghost or not:
ghost=1 if the object should be made ghost while parented (default)
ghost=0 if the object should be solid while parented
Note: if the object type is sensor, it stays ghost regardless of ghost parameter
parent: KX_GameObject reference or string (object name w/o OB prefix)
2009-05-21 13:32:15 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,SetParent);
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
|
2009-08-25 22:51:18 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
|
2008-07-20 17:18:46 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
|
2008-08-27 03:34:53 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
|
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
|
2009-07-26 01:32:37 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,ReplaceMesh);
|
2008-07-04 00:05:50 +00:00
|
|
|
KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
|
2008-03-15 17:08:58 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
|
2008-05-24 22:50:31 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_GameObject,rayCast);
|
2009-02-23 06:41:10 +00:00
|
|
|
KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
|
|
|
|
KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
|
2009-04-08 16:57:08 +00:00
|
|
|
KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
|
2009-07-25 22:57:29 +00:00
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
|
2011-05-24 07:52:29 +00:00
|
|
|
|
|
|
|
KX_PYMETHOD_DOC(KX_GameObject, playAction);
|
2011-07-16 05:25:15 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_GameObject, stopAction);
|
2011-06-23 22:44:24 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_GameObject, getActionFrame);
|
|
|
|
KX_PYMETHOD_DOC(KX_GameObject, setActionFrame);
|
2011-07-16 05:25:15 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_GameObject, isPlayingAction);
|
2009-05-26 16:15:40 +00:00
|
|
|
|
|
|
|
/* Dict access */
|
|
|
|
KX_PYMETHOD_VARARGS(KX_GameObject,get);
|
|
|
|
|
2009-03-24 19:37:17 +00:00
|
|
|
/* attributes */
|
|
|
|
static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static PyObject* pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
|
2010-10-11 10:47:20 +00:00
|
|
|
static PyObject* pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-03-24 19:37:17 +00:00
|
|
|
static PyObject* pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-14 12:34:39 +00:00
|
|
|
static PyObject* pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-03-24 19:37:17 +00:00
|
|
|
static PyObject* pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-15 21:17:08 +00:00
|
|
|
static PyObject* pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-08 16:25:00 +00:00
|
|
|
static PyObject* pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-15 21:17:08 +00:00
|
|
|
static PyObject* pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-04-25 07:17:36 +00:00
|
|
|
static int pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-15 21:17:08 +00:00
|
|
|
static PyObject* pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
cucumber merge: world scaling + video texture constants
revisions: 38166,38167,38177,38179,38180,38187,38242
To be implemented after merge:
1) add pydocs(rst) for the video texture new defines
2) see if a NodeSetLocalMatrix would fit well
#43439 by kupoman
Changing the worldTransform and localTransform python attributes to use BLI_math to simplify the code
#38242 by kupoman
Adding the constants SOURCE_ERROR, SOURCE_EMPTY, SOURCE_READY, SOURCE_PLAYING, SOURCE_STOPPED to the video texture module. Updates to the documentation will follow after a merge with trunk
#38187 by kupoman
Updates to the documentation to reflect that worldScale is now writable, and added localTransform and worldTransform to KX_GameObject.
#38180 by kupoman
The Transform attribute of KX_GameObject was based on world space data. I converted that one to worldTransform, and added a localTransform for local space transform information.
#38179 by kupoman
Fixed the transform attribute of KX_GameObject's set method to properly deal with negative scaling.
#38177 by kupoman
Updated the transform property on KX_GameObject so that it is now read/write, and added the corresponding set method. Also simplified the get method by calling GetOpenGLMatrix instead of making the matrix myself.
#38167 by kupoman
Adding a read only transform attribute to KX_GameObject that returns a 4x4 matrix representing the object's transformations.
#38166 by kupoman
Adding a worldScale attribute to KX_GameObject. This attribute scales the object independently of its parent's scale.
2012-01-22 03:21:28 +00:00
|
|
|
static int pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-15 21:17:08 +00:00
|
|
|
static PyObject* pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
cucumber merge: world scaling + video texture constants
revisions: 38166,38167,38177,38179,38180,38187,38242
To be implemented after merge:
1) add pydocs(rst) for the video texture new defines
2) see if a NodeSetLocalMatrix would fit well
#43439 by kupoman
Changing the worldTransform and localTransform python attributes to use BLI_math to simplify the code
#38242 by kupoman
Adding the constants SOURCE_ERROR, SOURCE_EMPTY, SOURCE_READY, SOURCE_PLAYING, SOURCE_STOPPED to the video texture module. Updates to the documentation will follow after a merge with trunk
#38187 by kupoman
Updates to the documentation to reflect that worldScale is now writable, and added localTransform and worldTransform to KX_GameObject.
#38180 by kupoman
The Transform attribute of KX_GameObject was based on world space data. I converted that one to worldTransform, and added a localTransform for local space transform information.
#38179 by kupoman
Fixed the transform attribute of KX_GameObject's set method to properly deal with negative scaling.
#38177 by kupoman
Updated the transform property on KX_GameObject so that it is now read/write, and added the corresponding set method. Also simplified the get method by calling GetOpenGLMatrix instead of making the matrix myself.
#38167 by kupoman
Adding a read only transform attribute to KX_GameObject that returns a 4x4 matrix representing the object's transformations.
#38166 by kupoman
Adding a worldScale attribute to KX_GameObject. This attribute scales the object independently of its parent's scale.
2012-01-22 03:21:28 +00:00
|
|
|
static PyObject* pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2010-02-12 03:40:28 +00:00
|
|
|
static PyObject* pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-03-24 19:37:17 +00:00
|
|
|
static PyObject* pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-04 15:54:07 +00:00
|
|
|
static PyObject* pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-05-17 16:30:18 +00:00
|
|
|
static PyObject* pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static PyObject* pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-05-07 14:53:40 +00:00
|
|
|
static PyObject* pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2010-01-16 23:53:51 +00:00
|
|
|
static PyObject* pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2008-06-26 12:39:06 +00:00
|
|
|
|
2012-03-13 06:22:43 +00:00
|
|
|
/* Experimental! */
|
2009-04-05 08:48:51 +00:00
|
|
|
static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static PyObject* pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-04-04 15:54:07 +00:00
|
|
|
|
2009-04-02 05:38:05 +00:00
|
|
|
/* getitem/setitem */
|
|
|
|
static PyMappingMethods Mapping;
|
2009-06-12 12:56:12 +00:00
|
|
|
static PySequenceMethods Sequence;
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
2009-04-17 20:06:06 +00:00
|
|
|
|
|
|
|
|
2012-02-23 10:41:31 +00:00
|
|
|
#endif //__KX_GAMEOBJECT_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|