BGE: New isDynamicSuspended python attribute
[blender.git] / source / gameengine / Ketsji / KX_GameObject.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file KX_GameObject.h
29  *  \ingroup ketsji
30  *  \brief General KX game object.
31  */
32
33 #ifndef __KX_GAMEOBJECT_H__
34 #define __KX_GAMEOBJECT_H__
35
36 #ifdef _MSC_VER
37    /* get rid of this stupid "warning 'this' used in initialiser list", generated by VC when including Solid/Sumo */
38 #  pragma warning (disable:4355)
39 #endif 
40
41 #include <stddef.h>
42
43 #include "ListValue.h"
44 #include "SCA_IObject.h"
45 #include "SG_Node.h"
46 #include "MT_Transform.h"
47 #include "MT_CmMatrix4x4.h"
48 #include "CTR_Map.h"
49 #include "CTR_HashedPtr.h"
50 #include "KX_Scene.h"
51 #include "KX_KetsjiEngine.h" /* for m_anim_framerate */
52 #include "DNA_constraint_types.h" /* for constraint replication */
53 #include "DNA_object_types.h"
54 #include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
55
56 //Forward declarations.
57 struct KX_ClientObjectInfo;
58 class KX_RayCast;
59 class RAS_MeshObject;
60 class PHY_IGraphicController;
61 class PHY_IPhysicsEnvironment;
62 class PHY_IPhysicsController;
63 class BL_ActionManager;
64 struct Object;
65 class KX_ObstacleSimulation;
66 struct bAction;
67
68 #ifdef WITH_PYTHON
69 /* utility conversion function */
70 bool ConvertPythonToGameObject(PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix);
71 #endif
72
73 #ifdef USE_MATHUTILS
74 void KX_GameObject_Mathutils_Callback_Init(void);
75 #endif
76
77 /**
78  * KX_GameObject is the main class for dynamic objects.
79  */
80 class KX_GameObject : public SCA_IObject
81 {
82         Py_Header
83 protected:
84
85         bool                                                            m_bDyna;
86         KX_ClientObjectInfo*                            m_pClient_info;
87         STR_String                                                      m_name;
88         STR_String                                                      m_text;
89         int                                                                     m_layer;
90         std::vector<RAS_MeshObject*>            m_meshes;
91         std::vector<RAS_MeshObject*>            m_lodmeshes;
92         int                                 m_currentLodLevel;
93         short                                                           m_previousLodLevel;
94         SG_QList                                                        m_meshSlots;    // head of mesh slots of this 
95         struct Object*                                          m_pBlenderObject;
96         struct Object*                                          m_pBlenderGroupObject;
97         
98         bool                                                            m_bUseObjectColor;
99         bool                                                            m_bIsNegativeScaling;
100         MT_Vector4                                                      m_objectColor;
101
102         // Bit fields for user control over physics collisions
103         short                                                           m_userCollisionGroup;
104         short                                                           m_userCollisionMask;
105
106         // visible = user setting
107         // culled = while rendering, depending on camera
108         bool                                                            m_bVisible; 
109         bool                                                            m_bCulled; 
110         bool                                                            m_bOccluder;
111
112         PHY_IPhysicsController*                         m_pPhysicsController;
113         PHY_IGraphicController*                         m_pGraphicController;
114         STR_String                                                      m_testPropName;
115         bool                                                            m_xray;
116         KX_GameObject*                                          m_pHitObject;
117
118         SG_Node*                                                        m_pSGNode;
119
120         MT_CmMatrix4x4                                          m_OpenGL_4x4Matrix;
121         std::vector<bRigidBodyJointConstraint*> m_constraints;
122
123         KX_ObstacleSimulation*                          m_pObstacleSimulation;
124
125         CListValue*                                                     m_pInstanceObjects;
126         KX_GameObject*                                          m_pDupliGroupObject;
127
128         // The action manager is used to play/stop/update actions
129         BL_ActionManager*                                       m_actionManager;
130
131         BL_ActionManager* GetActionManager();
132         
133         bool                                                            m_bRecordAnimation;
134 public:
135         bool                                                            m_isDeformable;
136
137         /**
138          * Helper function for modules that can't include KX_ClientObjectInfo.h
139          */
140         static KX_GameObject* GetClientObject(KX_ClientObjectInfo* info);
141
142 #ifdef WITH_PYTHON
143         // Python attributes that wont convert into CValue
144         //
145         // there are 2 places attributes can be stored, in the CValue,
146         // where attributes are converted into BGE's CValue types
147         // these can be used with property actuators
148         //
149         // For the python API, For types that cannot be converted into CValues (lists, dicts, GameObjects)
150         // these will be put into "m_attr_dict", logic bricks cannot access them.
151         //
152         // rules for setting attributes.
153         //
154         // * there should NEVER be a CValue and a m_attr_dict attribute with matching names. get/sets make sure of this.
155         // * if CValue conversion fails, use a PyObject in "m_attr_dict"
156         // * when assigning a value, first see if it can be a CValue, if it can remove the "m_attr_dict" and set the CValue
157         //
158         PyObject*                                                       m_attr_dict;
159         PyObject*                                                       m_collisionCallbacks;
160 #endif
161
162         virtual void    /* This function should be virtual - derived classed override it */
163         Relink(
164                 CTR_Map<CTR_HashedPtr, void*> *map
165         );
166
167         /**
168          * Compute an OpenGl compatible 4x4 matrix. Has the
169          * side effect of storing the result internally. The
170          * memory for the matrix remains the property of this class.
171          */ 
172                 double *
173         GetOpenGLMatrix(
174         );
175
176         /**
177          * Return a pointer to a MT_CmMatrix4x4 storing the 
178          * opengl transformation for this object. This is updated
179          * by a call to GetOpenGLMatrix(). This class owns the 
180          * memory for the returned matrix.
181          */
182
183                 MT_CmMatrix4x4 *
184         GetOpenGLMatrixPtr(
185         ) { 
186                 return &m_OpenGL_4x4Matrix;
187         };
188
189         /**
190          * Update the blender object obmat field from the object world position
191          * if blendobj is NULL, update the object pointed by m_pBlenderObject
192          * The user must take action to restore the matrix before leaving the GE.
193          * Used in Armature evaluation
194          */
195                 void
196         UpdateBlenderObjectMatrix(Object* blendobj=NULL);
197
198         /**
199          * Used for constraint replication for group instances.
200          * The list of constraints is filled during data conversion.
201          */
202         void AddConstraint(bRigidBodyJointConstraint *cons);
203         std::vector<bRigidBodyJointConstraint*> GetConstraints();
204         void ClearConstraints();
205
206         /** 
207          * Get a pointer to the game object that is the parent of 
208          * this object. Or NULL if there is no parent. The returned
209          * object is part of a reference counting scheme. Calling
210          * this function ups the reference count on the returned 
211          * object. It is the responsibility of the caller to decrement
212          * the reference count when you have finished with it.
213          */
214                 KX_GameObject*
215         GetParent(
216         );
217
218         /** 
219          * Sets the parent of this object to a game object
220          */
221         void SetParent(KX_Scene *scene, KX_GameObject *obj, bool addToCompound=true, bool ghost=true);
222
223         /** 
224          * Removes the parent of this object to a game object
225          */
226         void RemoveParent(KX_Scene *scene);
227
228         /*********************************
229          * group reference API
230          *********************************/
231
232                 KX_GameObject*
233         GetDupliGroupObject(
234         );
235
236                 CListValue*
237         GetInstanceObjects(
238         );
239
240                 void
241         SetDupliGroupObject(KX_GameObject*
242         );
243
244                 void
245         AddInstanceObjects(KX_GameObject*
246         );
247                 
248                 void 
249         RemoveDupliGroupObject(
250         );
251
252                 void
253         RemoveInstanceObject(KX_GameObject*
254         );
255         /*********************************
256          * Animation API
257          *********************************/
258
259         /**
260          * Adds an action to the object's action manager
261          */
262         bool PlayAction(const char* name,
263                                         float start,
264                                         float end,
265                                         short layer=0,
266                                         short priority=0,
267                                         float blendin=0.f,
268                                         short play_mode=0,
269                                         float layer_weight=0.f,
270                                         short ipo_flags=0,
271                                         float playback_speed=1.f,
272                                         short blend_mode=0);
273
274         /**
275          * Gets the current frame of an action
276          */
277         float GetActionFrame(short layer);
278
279         /**
280          * Sets the current frame of an action
281          */
282         void SetActionFrame(short layer, float frame);
283
284         /**
285          * Gets the currently running action on the given layer
286          */
287         bAction *GetCurrentAction(short layer);
288
289         /**
290          * Sets play mode of the action on the given layer
291          */
292         void SetPlayMode(short layer, short mode);
293
294         /**
295          * Sets the start and end times of the action on the given layer
296          */
297         void SetTimes(short layer, float start, float end);
298
299         /**
300          * Stop playing the action on the given layer
301          */
302         void StopAction(short layer);
303
304         /**
305          * Check if an action has finished playing
306          */
307         bool IsActionDone(short layer);
308
309         /**
310          * Kick the object's action manager
311          */
312         void UpdateActionManager(float curtime);
313
314         /**
315          * Have the action manager update IPOs
316          * note: not thread-safe!
317          */
318         void UpdateActionIPOs();
319
320         /*********************************
321          * End Animation API
322          *********************************/
323
324         /**
325          * Construct a game object. This class also inherits the 
326          * default constructors - use those with care!
327          */
328
329         KX_GameObject(
330                 void* sgReplicationInfo,
331                 SG_Callbacks callbacks
332         );
333
334         virtual 
335         ~KX_GameObject(
336         );
337
338         /** 
339          * \section Stuff which is here due to poor design.
340          * Inherited from CValue and needs an implementation. 
341          * Do not expect these functions do to anything sensible.
342          */
343
344         /**
345          * Inherited from CValue -- does nothing!
346          */
347                 CValue*
348         Calc(
349                 VALUE_OPERATOR op,
350                 CValue *val
351         );
352
353         /**
354          * Inherited from CValue -- does nothing!
355          */
356                 CValue*
357         CalcFinal(
358                 VALUE_DATA_TYPE dtype,
359                 VALUE_OPERATOR op,
360                 CValue *val
361         );
362
363         /**
364          * Inherited from CValue -- does nothing!
365          */
366         const 
367                 STR_String &
368         GetText(
369         );
370
371         /**
372          * Inherited from CValue -- does nothing!
373          */
374                 double
375         GetNumber(
376         );
377
378         /**
379          * \section Inherited from CValue. These are the useful
380          * part of the CValue interface that this class implements. 
381          */
382
383         /**
384          * Inherited from CValue -- returns the name of this object.
385          */
386                 STR_String&
387         GetName(
388         );
389
390         /**
391          * Inherited from CValue -- set the name of this object.
392          */
393                 void
394         SetName(
395                 const char *name
396         );
397
398         /** 
399          * Inherited from CValue -- return a new copy of this
400          * instance allocated on the heap. Ownership of the new 
401          * object belongs with the caller.
402          */
403         virtual CValue*
404         GetReplica(
405         );
406         
407         /**
408          * Inherited from CValue -- Makes sure any internal 
409          * data owned by this class is deep copied. Called internally
410          */
411         virtual void
412         ProcessReplica();
413
414         /** 
415          * Return the linear velocity of the game object.
416          */
417                 MT_Vector3 
418         GetLinearVelocity(
419                 bool local=false
420         );
421
422         /** 
423          * Return the linear velocity of a given point in world coordinate
424          * but relative to center of object ([0,0,0]=center of object)
425          */
426                 MT_Vector3 
427         GetVelocity(
428                 const MT_Point3& position
429         );
430
431         /**
432          * Return the mass of the object
433          */
434                 MT_Scalar
435         GetMass();
436
437         /**
438          * Return the local inertia vector of the object
439          */
440                 MT_Vector3
441         GetLocalInertia();
442
443         /** 
444          * Return the angular velocity of the game object.
445          */
446                 MT_Vector3 
447         GetAngularVelocity(
448                 bool local=false
449         );
450
451         /** 
452          * Align the object to a given normal.
453          */
454                 void 
455         AlignAxisToVect(
456                 const MT_Vector3& vect,
457                 int axis = 2,
458                 float fac = 1.0
459         );
460
461         /** 
462          * Quick'n'dirty obcolor ipo stuff
463          */
464
465                 void
466         SetObjectColor(
467                 const MT_Vector4& rgbavec
468         );
469
470                 const MT_Vector4&
471         GetObjectColor();
472
473
474                 void 
475         ResolveCombinedVelocities(
476                 const MT_Vector3 & lin_vel,
477                 const MT_Vector3 & ang_vel,
478                 bool lin_vel_local,
479                 bool ang_vel_local
480         );
481
482         /**
483          * \return a pointer to the physics controller owned by this class.
484          */
485
486         PHY_IPhysicsController* GetPhysicsController();
487
488         void    SetPhysicsController(PHY_IPhysicsController*    physicscontroller,bool isDynamic)
489         { 
490                 m_bDyna = isDynamic;
491                 m_pPhysicsController = physicscontroller;
492         }
493
494         virtual class RAS_Deformer* GetDeformer()
495         {
496                 return 0;
497         }
498         virtual void    SetDeformer(class RAS_Deformer* deformer)
499         {
500
501         }
502
503         /**
504          * \return a pointer to the graphic controller owner by this class 
505          */
506         PHY_IGraphicController* GetGraphicController()
507         {
508                 return m_pGraphicController;
509         }
510
511         void SetGraphicController(PHY_IGraphicController* graphiccontroller) 
512         { 
513                 m_pGraphicController = graphiccontroller;
514         }
515         /*
516          * @add/remove the graphic controller to the physic system
517          */
518         void ActivateGraphicController(bool recurse);
519
520         void SetUserCollisionGroup(short filter);
521         void SetUserCollisionMask(short mask);
522         /**
523          * Extra broadphase check for user controllable collisions
524          */
525         bool CheckCollision(KX_GameObject *other);
526
527         /**
528          * \section Coordinate system manipulation functions
529          */
530
531         void    NodeSetLocalPosition(const MT_Point3& trans     );
532
533         void    NodeSetLocalOrientation(const MT_Matrix3x3& rot );
534         void    NodeSetGlobalOrientation(const MT_Matrix3x3& rot        );
535
536         void    NodeSetLocalScale(      const MT_Vector3& scale );
537         void    NodeSetWorldScale(      const MT_Vector3& scale );
538
539         void    NodeSetRelativeScale(   const MT_Vector3& scale );
540
541         // adapt local position so that world position is set to desired position
542         void    NodeSetWorldPosition(const MT_Point3& trans);
543
544                 void
545         NodeUpdateGS(
546                 double time
547         );
548
549         const MT_Matrix3x3& NodeGetWorldOrientation(  ) const;
550         const MT_Vector3& NodeGetWorldScaling(  ) const;
551         const MT_Point3& NodeGetWorldPosition(  ) const;
552
553         const MT_Matrix3x3& NodeGetLocalOrientation(  ) const;
554         const MT_Vector3& NodeGetLocalScaling(  ) const;
555         const MT_Point3& NodeGetLocalPosition(  ) const;
556
557         /**
558          * \section scene graph node accessor functions.
559          */
560
561         SG_Node*        GetSGNode(      ) 
562         { 
563                 return m_pSGNode;
564         }
565
566         const   SG_Node* GetSGNode(     ) const
567         { 
568                 return m_pSGNode;
569         }
570
571         /**
572          * \section blender object accessor functions.
573          */
574
575         struct Object* GetBlenderObject( )
576         {
577                 return m_pBlenderObject;
578         }
579
580         void SetBlenderObject(struct Object* obj)
581         {
582                 m_pBlenderObject = obj;
583         }
584
585         struct Object* GetBlenderGroupObject( )
586         {
587                 return m_pBlenderGroupObject;
588         }
589
590         void SetBlenderGroupObject(struct Object* obj)
591         {
592                 m_pBlenderGroupObject = obj;
593         }
594         
595         bool IsDupliGroup()
596         { 
597                 return (m_pBlenderObject &&
598                                 (m_pBlenderObject->transflag & OB_DUPLIGROUP) &&
599                                 m_pBlenderObject->dup_group != NULL) ? true : false;
600         }
601
602         /**
603          * Set the Scene graph node for this game object.
604          * warning - it is your responsibility to make sure
605          * all controllers look at this new node. You must
606          * also take care of the memory associated with the
607          * old node. This class takes ownership of the new
608          * node.
609          */
610                 void    SetSGNode(SG_Node* node )
611                 { 
612                         m_pSGNode = node; 
613                 }
614         
615         //Is it a dynamic/physics object ?
616         bool    IsDynamic() const 
617         { 
618                 return m_bDyna; 
619         }
620
621         bool IsDynamicsSuspended() const;
622
623         /**
624          * Should we record animation for this object?
625          */
626
627         void SetRecordAnimation(bool recordAnimation)
628         {
629                 m_bRecordAnimation = recordAnimation;
630         }
631
632         bool IsRecordAnimation() const
633         {
634                 return m_bRecordAnimation;
635         }
636
637         /**
638          * Check if this object has a vertex parent relationship
639          */
640         bool IsVertexParent( )
641         {
642                 return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
643         }
644
645         bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
646         bool NeedRayCast(KX_ClientObjectInfo* client);
647
648
649         /**
650          * \section Physics accessors for this node.
651          *
652          * All these calls get passed directly to the physics controller 
653          * owned by this object.
654          * This is real interface bloat. Why not just use the physics controller
655          * directly? I think this is because the python interface is in the wrong
656          * place.
657          */
658
659                 void
660         ApplyForce(
661                 const MT_Vector3& force,        bool local
662         );
663
664                 void
665         ApplyTorque(
666                 const MT_Vector3& torque,
667                 bool local
668         );
669
670                 void
671         ApplyRotation(
672                 const MT_Vector3& drot,
673                 bool local
674         );
675
676                 void
677         ApplyMovement(
678                 const MT_Vector3& dloc,
679                 bool local
680         );
681
682                 void
683         addLinearVelocity(
684                 const MT_Vector3& lin_vel,
685                 bool local
686         );
687
688                 void
689         setLinearVelocity(
690                 const MT_Vector3& lin_vel,
691                 bool local
692         );
693
694                 void
695         setAngularVelocity(
696                 const MT_Vector3& ang_vel,
697                 bool local
698         );
699
700         virtual float   getLinearDamping() const;
701         virtual float   getAngularDamping() const;
702         virtual void    setLinearDamping(float damping);
703         virtual void    setAngularDamping(float damping);
704         virtual void    setDamping(float linear, float angular);
705
706         /**
707          * Update the physics object transform based upon the current SG_Node
708          * position.
709          */
710                 void
711         UpdateTransform(
712         );
713
714         static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
715
716         /**
717          * only used for sensor objects
718          */
719         void SynchronizeTransform();
720
721         static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
722
723         /**
724          * Function to set IPO option at start of IPO
725          */ 
726                 void
727         InitIPO(
728                 bool ipo_as_force,
729                 bool ipo_add,
730                 bool ipo_local
731         );
732
733         /**
734          * Odd function to update an ipo. ???
735          */ 
736                 void
737         UpdateIPO(
738                 float curframetime,
739                 bool recurse
740         );
741         /**
742          * Updates Material Ipo data 
743          */
744                 void 
745         UpdateMaterialData(
746                 dword matname_hash,
747                 MT_Vector4 rgba,
748                 MT_Vector3 specrgb,
749                 MT_Scalar hard,
750                 MT_Scalar spec,
751                 MT_Scalar ref,
752                 MT_Scalar emit,
753                 MT_Scalar alpha
754         );
755
756         /**
757          * \section Mesh accessor functions.
758          */
759
760         /**
761          * Update buckets to indicate that there is a new
762          * user of this object's meshes.
763          */
764                 void
765         AddMeshUser(
766         );
767         
768         /**
769          * Update buckets with data about the mesh after
770          * creating or duplicating the object, changing
771          * visibility, object color, .. .
772          */
773                 void
774         UpdateBuckets(
775                 bool recursive
776         );
777
778         /**
779          * Clear the meshes associated with this class
780          * and remove from the bucketing system.
781          * Don't think this actually deletes any of the meshes.
782          */
783                 void
784         RemoveMeshes(
785         );
786
787         /**
788          * Add a mesh to the set of meshes associated with this
789          * node. Meshes added in this way are not deleted by this class.
790          * Make sure you call RemoveMeshes() before deleting the
791          * mesh though,
792          */
793                 void
794         AddMesh(
795                 RAS_MeshObject* mesh
796         ) {
797                 m_meshes.push_back(mesh);
798         }
799
800         /**
801          * Add a level of detail mesh to the object. These should
802          * be added in order.
803          */
804                 void
805         AddLodMesh(
806                 RAS_MeshObject* mesh
807         );
808
809         /**
810          * Updates the current lod level based on distance from camera.
811          */
812                 void
813         UpdateLod(
814                 MT_Vector3 &cam_pos
815         );
816
817         /**
818          * Pick out a mesh associated with the integer 'num'.
819          */
820                 RAS_MeshObject*
821         GetMesh(
822                 int num
823         ) const { 
824                 return m_meshes[num]; 
825         }
826
827         /**
828          * Return the number of meshes currently associated with this
829          * game object.
830          */
831                 int
832         GetMeshCount(
833         ) const { 
834                 return m_meshes.size(); 
835         }
836         
837         /**
838          * Set the debug color of the meshes associated with this
839          * class. Does this still work?
840          */
841                 void
842         SetDebugColor(
843                 unsigned int bgra
844         );
845
846         /** 
847          * Reset the debug color of meshes associated with this class.
848          */
849                 void
850         ResetDebugColor(
851         );
852
853         /**
854          * Was this object marked visible? (only for the explicit
855          * visibility system).
856          */
857                 bool
858         GetVisible(
859                 void
860         );
861
862         /**
863          * Set visibility flag of this object
864          */
865                 void
866         SetVisible(
867                 bool b,
868                 bool recursive
869         );
870
871         /**
872          * Was this object culled?
873          */
874         inline bool
875         GetCulled(
876                 void
877         ) { return m_bCulled; }
878
879         /**
880          * Set culled flag of this object
881          */
882         inline void
883         SetCulled(
884                 bool c
885         ) { m_bCulled = c; }
886         
887         /**
888          * Is this object an occluder?
889          */
890         inline bool
891         GetOccluder(
892                 void
893         ) { return m_bOccluder; }
894
895         /**
896          * Set occluder flag of this object
897          */
898         void
899         SetOccluder(
900                 bool v,
901                 bool recursive
902         );
903         
904         /**
905          * Change the layer of the object (when it is added in another layer
906          * than the original layer)
907          */
908                 void
909         SetLayer(
910                 int l
911         );
912
913         /**
914          * Get the object layer
915          */
916                 int
917         GetLayer(
918                 void
919         );
920                 
921         /**
922          * Get the negative scaling state
923          */
924                 bool
925         IsNegativeScaling(
926                 void
927         ) { return m_bIsNegativeScaling; }
928
929         /**
930          * \section Logic bubbling methods.
931          */
932
933         void RegisterCollisionCallbacks();
934         void UnregisterCollisionCallbacks();
935         void RunCollisionCallbacks(KX_GameObject *collider, const MT_Vector3 &point, const MT_Vector3 &normal);
936         /**
937          * Stop making progress
938          */
939         void Suspend(void);
940
941         /**
942          * Resume making progress
943          */
944         void Resume(void);
945
946         void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
947         {
948                 m_pObstacleSimulation = obstacleSimulation;
949         }
950
951         void UnregisterObstacle()
952         {
953                 m_pObstacleSimulation = NULL;
954         }
955         
956         /**
957          * add debug object to the debuglist.
958          */
959         void SetUseDebugProperties(bool debug, bool recursive);
960
961         KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
962         
963         CListValue* GetChildren();
964         CListValue* GetChildrenRecursive();
965
966         KX_Scene*       GetScene();
967
968 #ifdef WITH_PYTHON
969         /**
970          * \section Python interface functions.
971          */
972         virtual PyObject *py_repr(void)
973         {
974                 return PyUnicode_From_STR_String(GetName());
975         }
976
977         KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
978         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce);
979         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque);
980         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyRotation);
981         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyMovement);
982         KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
983         KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
984         KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
985         KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
986         KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
987         KX_PYMETHOD_VARARGS(KX_GameObject,SetDamping);
988
989         KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
990
991
992         KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
993         KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
994         KX_PYMETHOD_VARARGS(KX_GameObject,SetOcclusion);
995         KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
996         KX_PYMETHOD_O(KX_GameObject,SetState);
997         KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
998         KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
999         KX_PYMETHOD_NOARGS(KX_GameObject,SuspendDynamics);
1000         KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
1001         KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
1002         KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
1003         KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
1004         KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
1005         KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
1006         KX_PYMETHOD_VARARGS(KX_GameObject,SetParent);
1007         KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
1008         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
1009         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
1010         KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
1011         KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
1012         KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
1013         KX_PYMETHOD_VARARGS(KX_GameObject,ReplaceMesh);
1014         KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
1015         KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
1016         KX_PYMETHOD_DOC(KX_GameObject,rayCast);
1017         KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
1018         KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
1019         KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
1020         KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
1021         KX_PYMETHOD_DOC(KX_GameObject, addDebugProperty);
1022
1023         KX_PYMETHOD_DOC(KX_GameObject, playAction);
1024         KX_PYMETHOD_DOC(KX_GameObject, stopAction);
1025         KX_PYMETHOD_DOC(KX_GameObject, getActionFrame);
1026         KX_PYMETHOD_DOC(KX_GameObject, setActionFrame);
1027         KX_PYMETHOD_DOC(KX_GameObject, isPlayingAction);
1028         
1029         /* Dict access */
1030         KX_PYMETHOD_VARARGS(KX_GameObject,get);
1031         
1032         /* attributes */
1033         static PyObject*        pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1034         static PyObject*        pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1035
1036         static PyObject*        pyattr_get_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1037         static PyObject*        pyattr_get_group_members(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1038         static PyObject*        pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1039
1040         static PyObject*        pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1041         static PyObject*        pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1042         static int                      pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1043         static PyObject*        pyattr_get_dynamics_suspended(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1044         static PyObject*        pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1045         static int                      pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1046         static PyObject*        pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1047         static int                      pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1048         static PyObject*        pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1049         static int                      pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1050         static PyObject*        pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1051         static int                      pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1052         static PyObject*        pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1053         static int                      pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1054         static PyObject*        pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1055         static int                      pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1056         static PyObject*        pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1057         static int                      pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1058         static PyObject*        pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1059         static int                      pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1060         static PyObject*        pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1061         static int                      pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1062         static PyObject*        pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1063         static int                      pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1064         static PyObject*        pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1065         static int                      pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1066         static PyObject*        pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1067         static int                      pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1068         static PyObject*        pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1069         static int                      pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1070         static PyObject*        pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1071         static int                      pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1072         static PyObject*        pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1073         static int                      pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1074         static PyObject*        pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1075         static int                      pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1076         static PyObject*        pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1077         static int                      pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1078         static PyObject*        pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1079         static int                      pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1080         static PyObject*        pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1081         static int                      pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1082         static PyObject*        pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1083         static PyObject*        pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1084         static PyObject*        pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1085         static PyObject*        pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1086         static PyObject*        pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1087         static int                      pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1088         static PyObject*        pyattr_get_collisionCallbacks(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1089         static int                      pyattr_set_collisionCallbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1090         static PyObject*        pyattr_get_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1091         static int                      pyattr_set_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1092         static PyObject*        pyattr_get_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1093         static int                      pyattr_set_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1094         static PyObject*        pyattr_get_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1095         static int                      pyattr_set_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1096         static PyObject*        pyattr_get_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1097         static int                      pyattr_set_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1098
1099         /* Experimental! */
1100         static PyObject*        pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1101         static PyObject*        pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1102         static PyObject*        pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1103         
1104         /* getitem/setitem */
1105         static PyMappingMethods Mapping;
1106         static PySequenceMethods        Sequence;
1107 #endif
1108 };
1109
1110
1111
1112 #endif  /* __KX_GAMEOBJECT_H__ */