BGE: Added 'ghost' arg to KX_GameObject.suspendDynamics() method
[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         unsigned short                                          m_userCollisionGroup;
104         unsigned 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         /** Set the object's collison group
521          * \param filter The group bitfield
522          */
523         void SetUserCollisionGroup(unsigned short filter);
524
525         /** Set the object's collison mask
526          * \param filter The mask bitfield
527          */
528         void SetUserCollisionMask(unsigned short mask);
529         unsigned short GetUserCollisionGroup();
530         unsigned short GetUserCollisionMask();
531         /**
532          * Extra broadphase check for user controllable collisions
533          */
534         bool CheckCollision(KX_GameObject *other);
535
536         /**
537          * \section Coordinate system manipulation functions
538          */
539
540         void    NodeSetLocalPosition(const MT_Point3& trans     );
541
542         void    NodeSetLocalOrientation(const MT_Matrix3x3& rot );
543         void    NodeSetGlobalOrientation(const MT_Matrix3x3& rot        );
544
545         void    NodeSetLocalScale(      const MT_Vector3& scale );
546         void    NodeSetWorldScale(      const MT_Vector3& scale );
547
548         void    NodeSetRelativeScale(   const MT_Vector3& scale );
549
550         // adapt local position so that world position is set to desired position
551         void    NodeSetWorldPosition(const MT_Point3& trans);
552
553                 void
554         NodeUpdateGS(
555                 double time
556         );
557
558         const MT_Matrix3x3& NodeGetWorldOrientation(  ) const;
559         const MT_Vector3& NodeGetWorldScaling(  ) const;
560         const MT_Point3& NodeGetWorldPosition(  ) const;
561
562         const MT_Matrix3x3& NodeGetLocalOrientation(  ) const;
563         const MT_Vector3& NodeGetLocalScaling(  ) const;
564         const MT_Point3& NodeGetLocalPosition(  ) const;
565
566         /**
567          * \section scene graph node accessor functions.
568          */
569
570         SG_Node*        GetSGNode(      ) 
571         { 
572                 return m_pSGNode;
573         }
574
575         const   SG_Node* GetSGNode(     ) const
576         { 
577                 return m_pSGNode;
578         }
579
580         /**
581          * \section blender object accessor functions.
582          */
583
584         struct Object* GetBlenderObject( )
585         {
586                 return m_pBlenderObject;
587         }
588
589         void SetBlenderObject(struct Object* obj)
590         {
591                 m_pBlenderObject = obj;
592         }
593
594         struct Object* GetBlenderGroupObject( )
595         {
596                 return m_pBlenderGroupObject;
597         }
598
599         void SetBlenderGroupObject(struct Object* obj)
600         {
601                 m_pBlenderGroupObject = obj;
602         }
603         
604         bool IsDupliGroup()
605         { 
606                 return (m_pBlenderObject &&
607                                 (m_pBlenderObject->transflag & OB_DUPLIGROUP) &&
608                                 m_pBlenderObject->dup_group != NULL) ? true : false;
609         }
610
611         /**
612          * Set the Scene graph node for this game object.
613          * warning - it is your responsibility to make sure
614          * all controllers look at this new node. You must
615          * also take care of the memory associated with the
616          * old node. This class takes ownership of the new
617          * node.
618          */
619                 void    SetSGNode(SG_Node* node )
620                 { 
621                         m_pSGNode = node; 
622                 }
623         
624         //Is it a dynamic/physics object ?
625         bool    IsDynamic() const 
626         { 
627                 return m_bDyna; 
628         }
629
630         bool IsDynamicsSuspended() const;
631
632         /**
633          * Should we record animation for this object?
634          */
635
636         void SetRecordAnimation(bool recordAnimation)
637         {
638                 m_bRecordAnimation = recordAnimation;
639         }
640
641         bool IsRecordAnimation() const
642         {
643                 return m_bRecordAnimation;
644         }
645
646         /**
647          * Check if this object has a vertex parent relationship
648          */
649         bool IsVertexParent( )
650         {
651                 return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
652         }
653
654         bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
655         bool NeedRayCast(KX_ClientObjectInfo* client);
656
657
658         /**
659          * \section Physics accessors for this node.
660          *
661          * All these calls get passed directly to the physics controller 
662          * owned by this object.
663          * This is real interface bloat. Why not just use the physics controller
664          * directly? I think this is because the python interface is in the wrong
665          * place.
666          */
667
668                 void
669         ApplyForce(
670                 const MT_Vector3& force,        bool local
671         );
672
673                 void
674         ApplyTorque(
675                 const MT_Vector3& torque,
676                 bool local
677         );
678
679                 void
680         ApplyRotation(
681                 const MT_Vector3& drot,
682                 bool local
683         );
684
685                 void
686         ApplyMovement(
687                 const MT_Vector3& dloc,
688                 bool local
689         );
690
691                 void
692         addLinearVelocity(
693                 const MT_Vector3& lin_vel,
694                 bool local
695         );
696
697                 void
698         setLinearVelocity(
699                 const MT_Vector3& lin_vel,
700                 bool local
701         );
702
703                 void
704         setAngularVelocity(
705                 const MT_Vector3& ang_vel,
706                 bool local
707         );
708
709         virtual float   getLinearDamping() const;
710         virtual float   getAngularDamping() const;
711         virtual void    setLinearDamping(float damping);
712         virtual void    setAngularDamping(float damping);
713         virtual void    setDamping(float linear, float angular);
714
715         /**
716          * Update the physics object transform based upon the current SG_Node
717          * position.
718          */
719                 void
720         UpdateTransform(
721         );
722
723         static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
724
725         /**
726          * only used for sensor objects
727          */
728         void SynchronizeTransform();
729
730         static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
731
732         /**
733          * Function to set IPO option at start of IPO
734          */ 
735                 void
736         InitIPO(
737                 bool ipo_as_force,
738                 bool ipo_add,
739                 bool ipo_local
740         );
741
742         /**
743          * Odd function to update an ipo. ???
744          */ 
745                 void
746         UpdateIPO(
747                 float curframetime,
748                 bool recurse
749         );
750         /**
751          * Updates Material Ipo data 
752          */
753                 void 
754         UpdateMaterialData(
755                 dword matname_hash,
756                 MT_Vector4 rgba,
757                 MT_Vector3 specrgb,
758                 MT_Scalar hard,
759                 MT_Scalar spec,
760                 MT_Scalar ref,
761                 MT_Scalar emit,
762                 MT_Scalar alpha
763         );
764
765         /**
766          * \section Mesh accessor functions.
767          */
768
769         /**
770          * Update buckets to indicate that there is a new
771          * user of this object's meshes.
772          */
773                 void
774         AddMeshUser(
775         );
776         
777         /**
778          * Update buckets with data about the mesh after
779          * creating or duplicating the object, changing
780          * visibility, object color, .. .
781          */
782                 void
783         UpdateBuckets(
784                 bool recursive
785         );
786
787         /**
788          * Clear the meshes associated with this class
789          * and remove from the bucketing system.
790          * Don't think this actually deletes any of the meshes.
791          */
792                 void
793         RemoveMeshes(
794         );
795
796         /**
797          * Add a mesh to the set of meshes associated with this
798          * node. Meshes added in this way are not deleted by this class.
799          * Make sure you call RemoveMeshes() before deleting the
800          * mesh though,
801          */
802                 void
803         AddMesh(
804                 RAS_MeshObject* mesh
805         ) {
806                 m_meshes.push_back(mesh);
807         }
808
809         /**
810          * Add a level of detail mesh to the object. These should
811          * be added in order.
812          */
813                 void
814         AddLodMesh(
815                 RAS_MeshObject* mesh
816         );
817
818         /**
819          * Updates the current lod level based on distance from camera.
820          */
821                 void
822         UpdateLod(
823                 MT_Vector3 &cam_pos
824         );
825
826         /**
827          * Pick out a mesh associated with the integer 'num'.
828          */
829                 RAS_MeshObject*
830         GetMesh(
831                 int num
832         ) const { 
833                 return m_meshes[num]; 
834         }
835
836         /**
837          * Return the number of meshes currently associated with this
838          * game object.
839          */
840                 int
841         GetMeshCount(
842         ) const { 
843                 return m_meshes.size(); 
844         }
845         
846         /**
847          * Set the debug color of the meshes associated with this
848          * class. Does this still work?
849          */
850                 void
851         SetDebugColor(
852                 unsigned int bgra
853         );
854
855         /** 
856          * Reset the debug color of meshes associated with this class.
857          */
858                 void
859         ResetDebugColor(
860         );
861
862         /**
863          * Was this object marked visible? (only for the explicit
864          * visibility system).
865          */
866                 bool
867         GetVisible(
868                 void
869         );
870
871         /**
872          * Set visibility flag of this object
873          */
874                 void
875         SetVisible(
876                 bool b,
877                 bool recursive
878         );
879
880         /**
881          * Was this object culled?
882          */
883         inline bool
884         GetCulled(
885                 void
886         ) { return m_bCulled; }
887
888         /**
889          * Set culled flag of this object
890          */
891         inline void
892         SetCulled(
893                 bool c
894         ) { m_bCulled = c; }
895         
896         /**
897          * Is this object an occluder?
898          */
899         inline bool
900         GetOccluder(
901                 void
902         ) { return m_bOccluder; }
903
904         /**
905          * Set occluder flag of this object
906          */
907         void
908         SetOccluder(
909                 bool v,
910                 bool recursive
911         );
912         
913         /**
914          * Change the layer of the object (when it is added in another layer
915          * than the original layer)
916          */
917         virtual void
918         SetLayer(
919                 int l
920         );
921
922         /**
923          * Get the object layer
924          */
925                 int
926         GetLayer(
927                 void
928         );
929                 
930         /**
931          * Get the negative scaling state
932          */
933                 bool
934         IsNegativeScaling(
935                 void
936         ) { return m_bIsNegativeScaling; }
937
938         /**
939          * \section Logic bubbling methods.
940          */
941
942         void RegisterCollisionCallbacks();
943         void UnregisterCollisionCallbacks();
944         void RunCollisionCallbacks(KX_GameObject *collider, const MT_Vector3 &point, const MT_Vector3 &normal);
945         /**
946          * Stop making progress
947          */
948         void Suspend(void);
949
950         /**
951          * Resume making progress
952          */
953         void Resume(void);
954
955         void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
956         {
957                 m_pObstacleSimulation = obstacleSimulation;
958         }
959
960         void UnregisterObstacle()
961         {
962                 m_pObstacleSimulation = NULL;
963         }
964         
965         /**
966          * add debug object to the debuglist.
967          */
968         void SetUseDebugProperties(bool debug, bool recursive);
969
970         KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
971         
972         CListValue* GetChildren();
973         CListValue* GetChildrenRecursive();
974
975         KX_Scene*       GetScene();
976
977 #ifdef WITH_PYTHON
978         /**
979          * \section Python interface functions.
980          */
981         virtual PyObject *py_repr(void)
982         {
983                 return PyUnicode_From_STR_String(GetName());
984         }
985
986         KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
987         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce);
988         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque);
989         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyRotation);
990         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyMovement);
991         KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
992         KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
993         KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
994         KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
995         KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
996         KX_PYMETHOD_VARARGS(KX_GameObject,SetDamping);
997
998         KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
999
1000
1001         KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
1002         KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
1003         KX_PYMETHOD_VARARGS(KX_GameObject,SetOcclusion);
1004         KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
1005         KX_PYMETHOD_O(KX_GameObject,SetState);
1006         KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
1007         KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
1008         KX_PYMETHOD_VARARGS(KX_GameObject,SuspendDynamics);
1009         KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
1010         KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
1011         KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
1012         KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
1013         KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
1014         KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
1015         KX_PYMETHOD_VARARGS(KX_GameObject,SetParent);
1016         KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
1017         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
1018         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
1019         KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
1020         KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
1021         KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
1022         KX_PYMETHOD_VARARGS(KX_GameObject,ReplaceMesh);
1023         KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
1024         KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
1025         KX_PYMETHOD_DOC(KX_GameObject,rayCast);
1026         KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
1027         KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
1028         KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
1029         KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
1030         KX_PYMETHOD_DOC(KX_GameObject, addDebugProperty);
1031
1032         KX_PYMETHOD_DOC(KX_GameObject, playAction);
1033         KX_PYMETHOD_DOC(KX_GameObject, stopAction);
1034         KX_PYMETHOD_DOC(KX_GameObject, getActionFrame);
1035         KX_PYMETHOD_DOC(KX_GameObject, setActionFrame);
1036         KX_PYMETHOD_DOC(KX_GameObject, isPlayingAction);
1037         
1038         /* Dict access */
1039         KX_PYMETHOD_VARARGS(KX_GameObject,get);
1040         
1041         /* attributes */
1042         static PyObject*        pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1043         static PyObject*        pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1044
1045         static PyObject*        pyattr_get_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1046         static PyObject*        pyattr_get_group_members(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1047         static PyObject*        pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1048
1049         static PyObject*        pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1050         static PyObject*        pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1051         static int                      pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1052         static PyObject*        pyattr_get_is_suspend_dynamics(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1053         static PyObject*        pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1054         static int                      pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1055         static PyObject*        pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1056         static int                      pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1057         static PyObject*        pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1058         static int                      pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1059         static PyObject*        pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1060         static int                      pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1061         static PyObject*        pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1062         static int                      pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1063         static PyObject*        pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1064         static int                      pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1065         static PyObject*        pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1066         static int                      pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1067         static PyObject*        pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1068         static int                      pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1069         static PyObject*        pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1070         static int                      pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1071         static PyObject*        pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1072         static int                      pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1073         static PyObject*        pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1074         static int                      pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1075         static PyObject*        pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1076         static int                      pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1077         static PyObject*        pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1078         static int                      pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1079         static PyObject*        pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1080         static int                      pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1081         static PyObject*        pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1082         static int                      pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1083         static PyObject*        pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1084         static int                      pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1085         static PyObject*        pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1086         static int                      pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1087         static PyObject*        pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1088         static int                      pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1089         static PyObject*        pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1090         static int                      pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1091         static PyObject*        pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1092         static PyObject*        pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1093         static PyObject*        pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1094         static PyObject*        pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1095         static PyObject*        pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1096         static int                      pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1097         static PyObject*        pyattr_get_collisionCallbacks(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1098         static int                      pyattr_set_collisionCallbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1099         static PyObject*        pyattr_get_collisionGroup(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1100         static int                      pyattr_set_collisionGroup(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1101         static PyObject*        pyattr_get_collisionMask(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1102         static int                      pyattr_set_collisionMask(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1103         static PyObject*        pyattr_get_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1104         static int                      pyattr_set_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1105         static PyObject*        pyattr_get_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1106         static int                      pyattr_set_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1107         static PyObject*        pyattr_get_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1108         static int                      pyattr_set_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1109         static PyObject*        pyattr_get_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1110         static int                      pyattr_set_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1111
1112         /* Experimental! */
1113         static PyObject*        pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1114         static PyObject*        pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1115         static PyObject*        pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1116         
1117         /* getitem/setitem */
1118         static PyMappingMethods Mapping;
1119         static PySequenceMethods        Sequence;
1120 #endif
1121 };
1122
1123
1124
1125 #endif  /* __KX_GAMEOBJECT_H__ */