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