BGE: Added getActionName() function to KX_GameObject()
[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 "EXP_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          * Gets the name of the current action
281          */
282         const char *GetActionName(short layer);
283
284         /**
285          * Sets the current frame of an action
286          */
287         void SetActionFrame(short layer, float frame);
288
289         /**
290          * Gets the currently running action on the given layer
291          */
292         bAction *GetCurrentAction(short layer);
293
294         /**
295          * Sets play mode of the action on the given layer
296          */
297         void SetPlayMode(short layer, short mode);
298
299         /**
300          * Sets the start and end times of the action on the given layer
301          */
302         void SetTimes(short layer, float start, float end);
303
304         /**
305          * Stop playing the action on the given layer
306          */
307         void StopAction(short layer);
308
309         /**
310          * Remove playing tagged actions.
311          */
312         void RemoveTaggedActions();
313
314         /**
315          * Check if an action has finished playing
316          */
317         bool IsActionDone(short layer);
318
319         /**
320          * Kick the object's action manager
321          */
322         void UpdateActionManager(float curtime);
323
324         /**
325          * Have the action manager update IPOs
326          * note: not thread-safe!
327          */
328         void UpdateActionIPOs();
329
330         /*********************************
331          * End Animation API
332          *********************************/
333
334         /**
335          * Construct a game object. This class also inherits the 
336          * default constructors - use those with care!
337          */
338
339         KX_GameObject(
340                 void* sgReplicationInfo,
341                 SG_Callbacks callbacks
342         );
343
344         virtual 
345         ~KX_GameObject(
346         );
347
348         /** 
349          * \section Stuff which is here due to poor design.
350          * Inherited from CValue and needs an implementation. 
351          * Do not expect these functions do to anything sensible.
352          */
353
354         /**
355          * Inherited from CValue -- does nothing!
356          */
357                 CValue*
358         Calc(
359                 VALUE_OPERATOR op,
360                 CValue *val
361         );
362
363         /**
364          * Inherited from CValue -- does nothing!
365          */
366                 CValue*
367         CalcFinal(
368                 VALUE_DATA_TYPE dtype,
369                 VALUE_OPERATOR op,
370                 CValue *val
371         );
372
373         /**
374          * Inherited from CValue -- does nothing!
375          */
376         const 
377                 STR_String &
378         GetText(
379         );
380
381         /**
382          * Inherited from CValue -- does nothing!
383          */
384                 double
385         GetNumber(
386         );
387
388         /**
389          * \section Inherited from CValue. These are the useful
390          * part of the CValue interface that this class implements. 
391          */
392
393         /**
394          * Inherited from CValue -- returns the name of this object.
395          */
396                 STR_String&
397         GetName(
398         );
399
400         /**
401          * Inherited from CValue -- set the name of this object.
402          */
403                 void
404         SetName(
405                 const char *name
406         );
407
408         /** 
409          * Inherited from CValue -- return a new copy of this
410          * instance allocated on the heap. Ownership of the new 
411          * object belongs with the caller.
412          */
413         virtual CValue*
414         GetReplica(
415         );
416         
417         /**
418          * Inherited from CValue -- Makes sure any internal 
419          * data owned by this class is deep copied. Called internally
420          */
421         virtual void
422         ProcessReplica();
423
424         /** 
425          * Return the linear velocity of the game object.
426          */
427                 MT_Vector3 
428         GetLinearVelocity(
429                 bool local=false
430         );
431
432         /** 
433          * Return the linear velocity of a given point in world coordinate
434          * but relative to center of object ([0,0,0]=center of object)
435          */
436                 MT_Vector3 
437         GetVelocity(
438                 const MT_Point3& position
439         );
440
441         /**
442          * Return the mass of the object
443          */
444                 MT_Scalar
445         GetMass();
446
447         /**
448          * Return the local inertia vector of the object
449          */
450                 MT_Vector3
451         GetLocalInertia();
452
453         /** 
454          * Return the angular velocity of the game object.
455          */
456                 MT_Vector3 
457         GetAngularVelocity(
458                 bool local=false
459         );
460
461         /** 
462          * Align the object to a given normal.
463          */
464                 void 
465         AlignAxisToVect(
466                 const MT_Vector3& vect,
467                 int axis = 2,
468                 float fac = 1.0
469         );
470
471         /** 
472          * Quick'n'dirty obcolor ipo stuff
473          */
474
475                 void
476         SetObjectColor(
477                 const MT_Vector4& rgbavec
478         );
479
480                 const MT_Vector4&
481         GetObjectColor();
482
483
484                 void 
485         ResolveCombinedVelocities(
486                 const MT_Vector3 & lin_vel,
487                 const MT_Vector3 & ang_vel,
488                 bool lin_vel_local,
489                 bool ang_vel_local
490         );
491
492         /**
493          * \return a pointer to the physics controller owned by this class.
494          */
495
496         PHY_IPhysicsController* GetPhysicsController();
497
498         void    SetPhysicsController(PHY_IPhysicsController*    physicscontroller,bool isDynamic)
499         { 
500                 m_bDyna = isDynamic;
501                 m_pPhysicsController = physicscontroller;
502         }
503
504         virtual class RAS_Deformer* GetDeformer()
505         {
506                 return 0;
507         }
508         virtual void    SetDeformer(class RAS_Deformer* deformer)
509         {
510
511         }
512
513         /**
514          * \return a pointer to the graphic controller owner by this class 
515          */
516         PHY_IGraphicController* GetGraphicController()
517         {
518                 return m_pGraphicController;
519         }
520
521         void SetGraphicController(PHY_IGraphicController* graphiccontroller) 
522         { 
523                 m_pGraphicController = graphiccontroller;
524         }
525         /*
526          * @add/remove the graphic controller to the physic system
527          */
528         void ActivateGraphicController(bool recurse);
529
530         /** Set the object's collison group
531          * \param filter The group bitfield
532          */
533         void SetUserCollisionGroup(unsigned short filter);
534
535         /** Set the object's collison mask
536          * \param filter The mask bitfield
537          */
538         void SetUserCollisionMask(unsigned short mask);
539         unsigned short GetUserCollisionGroup();
540         unsigned short GetUserCollisionMask();
541         /**
542          * Extra broadphase check for user controllable collisions
543          */
544         bool CheckCollision(KX_GameObject *other);
545
546         /**
547          * \section Coordinate system manipulation functions
548          */
549
550         void    NodeSetLocalPosition(const MT_Point3& trans     );
551
552         void    NodeSetLocalOrientation(const MT_Matrix3x3& rot );
553         void    NodeSetGlobalOrientation(const MT_Matrix3x3& rot        );
554
555         void    NodeSetLocalScale(      const MT_Vector3& scale );
556         void    NodeSetWorldScale(      const MT_Vector3& scale );
557
558         void    NodeSetRelativeScale(   const MT_Vector3& scale );
559
560         // adapt local position so that world position is set to desired position
561         void    NodeSetWorldPosition(const MT_Point3& trans);
562
563                 void
564         NodeUpdateGS(
565                 double time
566         );
567
568         const MT_Matrix3x3& NodeGetWorldOrientation(  ) const;
569         const MT_Vector3& NodeGetWorldScaling(  ) const;
570         const MT_Point3& NodeGetWorldPosition(  ) const;
571
572         const MT_Matrix3x3& NodeGetLocalOrientation(  ) const;
573         const MT_Vector3& NodeGetLocalScaling(  ) const;
574         const MT_Point3& NodeGetLocalPosition(  ) const;
575
576         /**
577          * \section scene graph node accessor functions.
578          */
579
580         SG_Node*        GetSGNode(      ) 
581         { 
582                 return m_pSGNode;
583         }
584
585         const   SG_Node* GetSGNode(     ) const
586         { 
587                 return m_pSGNode;
588         }
589
590         /**
591          * \section blender object accessor functions.
592          */
593
594         struct Object* GetBlenderObject( )
595         {
596                 return m_pBlenderObject;
597         }
598
599         void SetBlenderObject(struct Object* obj)
600         {
601                 m_pBlenderObject = obj;
602         }
603
604         struct Object* GetBlenderGroupObject( )
605         {
606                 return m_pBlenderGroupObject;
607         }
608
609         void SetBlenderGroupObject(struct Object* obj)
610         {
611                 m_pBlenderGroupObject = obj;
612         }
613         
614         bool IsDupliGroup()
615         { 
616                 return (m_pBlenderObject &&
617                                 (m_pBlenderObject->transflag & OB_DUPLIGROUP) &&
618                                 m_pBlenderObject->dup_group != NULL) ? true : false;
619         }
620
621         /**
622          * Set the Scene graph node for this game object.
623          * warning - it is your responsibility to make sure
624          * all controllers look at this new node. You must
625          * also take care of the memory associated with the
626          * old node. This class takes ownership of the new
627          * node.
628          */
629                 void    SetSGNode(SG_Node* node )
630                 { 
631                         m_pSGNode = node; 
632                 }
633         
634         //Is it a dynamic/physics object ?
635         bool    IsDynamic() const 
636         { 
637                 return m_bDyna; 
638         }
639
640         bool IsDynamicsSuspended() const;
641
642         /**
643          * Should we record animation for this object?
644          */
645
646         void SetRecordAnimation(bool recordAnimation)
647         {
648                 m_bRecordAnimation = recordAnimation;
649         }
650
651         bool IsRecordAnimation() const
652         {
653                 return m_bRecordAnimation;
654         }
655
656         /**
657          * Check if this object has a vertex parent relationship
658          */
659         bool IsVertexParent( )
660         {
661                 return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
662         }
663
664         bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
665         bool NeedRayCast(KX_ClientObjectInfo* client);
666
667
668         /**
669          * \section Physics accessors for this node.
670          *
671          * All these calls get passed directly to the physics controller 
672          * owned by this object.
673          * This is real interface bloat. Why not just use the physics controller
674          * directly? I think this is because the python interface is in the wrong
675          * place.
676          */
677
678                 void
679         ApplyForce(
680                 const MT_Vector3& force,        bool local
681         );
682
683                 void
684         ApplyTorque(
685                 const MT_Vector3& torque,
686                 bool local
687         );
688
689                 void
690         ApplyRotation(
691                 const MT_Vector3& drot,
692                 bool local
693         );
694
695                 void
696         ApplyMovement(
697                 const MT_Vector3& dloc,
698                 bool local
699         );
700
701                 void
702         addLinearVelocity(
703                 const MT_Vector3& lin_vel,
704                 bool local
705         );
706
707                 void
708         setLinearVelocity(
709                 const MT_Vector3& lin_vel,
710                 bool local
711         );
712
713                 void
714         setAngularVelocity(
715                 const MT_Vector3& ang_vel,
716                 bool local
717         );
718
719         virtual float   getLinearDamping() const;
720         virtual float   getAngularDamping() const;
721         virtual void    setLinearDamping(float damping);
722         virtual void    setAngularDamping(float damping);
723         virtual void    setDamping(float linear, float angular);
724
725         /**
726          * Update the physics object transform based upon the current SG_Node
727          * position.
728          */
729                 void
730         UpdateTransform(
731         );
732
733         static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
734
735         /**
736          * only used for sensor objects
737          */
738         void SynchronizeTransform();
739
740         static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
741
742         /**
743          * Function to set IPO option at start of IPO
744          */ 
745                 void
746         InitIPO(
747                 bool ipo_as_force,
748                 bool ipo_add,
749                 bool ipo_local
750         );
751
752         /**
753          * Odd function to update an ipo. ???
754          */ 
755                 void
756         UpdateIPO(
757                 float curframetime,
758                 bool recurse
759         );
760         /**
761          * Updates Material Ipo data 
762          */
763                 void 
764         UpdateMaterialData(
765                 dword matname_hash,
766                 MT_Vector4 rgba,
767                 MT_Vector3 specrgb,
768                 MT_Scalar hard,
769                 MT_Scalar spec,
770                 MT_Scalar ref,
771                 MT_Scalar emit,
772                 MT_Scalar alpha
773         );
774
775         /**
776          * \section Mesh accessor functions.
777          */
778
779         /**
780          * Update buckets to indicate that there is a new
781          * user of this object's meshes.
782          */
783                 void
784         AddMeshUser(
785         );
786         
787         /**
788          * Update buckets with data about the mesh after
789          * creating or duplicating the object, changing
790          * visibility, object color, .. .
791          */
792                 void
793         UpdateBuckets(
794                 bool recursive
795         );
796
797         /**
798          * Clear the meshes associated with this class
799          * and remove from the bucketing system.
800          * Don't think this actually deletes any of the meshes.
801          */
802                 void
803         RemoveMeshes(
804         );
805
806         /**
807          * Add a mesh to the set of meshes associated with this
808          * node. Meshes added in this way are not deleted by this class.
809          * Make sure you call RemoveMeshes() before deleting the
810          * mesh though,
811          */
812                 void
813         AddMesh(
814                 RAS_MeshObject* mesh
815         ) {
816                 m_meshes.push_back(mesh);
817         }
818
819         /**
820          * Add a level of detail mesh to the object. These should
821          * be added in order.
822          */
823                 void
824         AddLodMesh(
825                 RAS_MeshObject* mesh
826         );
827
828         /**
829          * Updates the current lod level based on distance from camera.
830          */
831                 void
832         UpdateLod(
833                 MT_Vector3 &cam_pos
834         );
835
836         /**
837          * Pick out a mesh associated with the integer 'num'.
838          */
839                 RAS_MeshObject*
840         GetMesh(
841                 int num
842         ) const { 
843                 return m_meshes[num]; 
844         }
845
846         /**
847          * Return the number of meshes currently associated with this
848          * game object.
849          */
850                 int
851         GetMeshCount(
852         ) const { 
853                 return m_meshes.size(); 
854         }
855         
856         /**
857          * Set the debug color of the meshes associated with this
858          * class. Does this still work?
859          */
860                 void
861         SetDebugColor(
862                 unsigned int bgra
863         );
864
865         /** 
866          * Reset the debug color of meshes associated with this class.
867          */
868                 void
869         ResetDebugColor(
870         );
871
872         /**
873          * Was this object marked visible? (only for the explicit
874          * visibility system).
875          */
876                 bool
877         GetVisible(
878                 void
879         );
880
881         /**
882          * Set visibility flag of this object
883          */
884                 void
885         SetVisible(
886                 bool b,
887                 bool recursive
888         );
889
890         /**
891          * Was this object culled?
892          */
893         inline bool
894         GetCulled(
895                 void
896         ) { return m_bCulled; }
897
898         /**
899          * Set culled flag of this object
900          */
901         inline void
902         SetCulled(
903                 bool c
904         ) { m_bCulled = c; }
905         
906         /**
907          * Is this object an occluder?
908          */
909         inline bool
910         GetOccluder(
911                 void
912         ) { return m_bOccluder; }
913
914         /**
915          * Set occluder flag of this object
916          */
917         void
918         SetOccluder(
919                 bool v,
920                 bool recursive
921         );
922         
923         /**
924          * Change the layer of the object (when it is added in another layer
925          * than the original layer)
926          */
927         virtual void
928         SetLayer(
929                 int l
930         );
931
932         /**
933          * Get the object layer
934          */
935                 int
936         GetLayer(
937                 void
938         );
939                 
940         /**
941          * Get the negative scaling state
942          */
943                 bool
944         IsNegativeScaling(
945                 void
946         ) { return m_bIsNegativeScaling; }
947
948         /**
949          * \section Logic bubbling methods.
950          */
951
952         void RegisterCollisionCallbacks();
953         void UnregisterCollisionCallbacks();
954         void RunCollisionCallbacks(KX_GameObject *collider, const MT_Vector3 &point, const MT_Vector3 &normal);
955         /**
956          * Stop making progress
957          */
958         void Suspend(void);
959
960         /**
961          * Resume making progress
962          */
963         void Resume(void);
964
965         void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
966         {
967                 m_pObstacleSimulation = obstacleSimulation;
968         }
969
970         void UnregisterObstacle()
971         {
972                 m_pObstacleSimulation = NULL;
973         }
974         
975         /**
976          * add debug object to the debuglist.
977          */
978         void SetUseDebugProperties(bool debug, bool recursive);
979
980         KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
981         
982         CListValue* GetChildren();
983         CListValue* GetChildrenRecursive();
984
985         KX_Scene*       GetScene();
986
987 #ifdef WITH_PYTHON
988         /**
989          * \section Python interface functions.
990          */
991         virtual PyObject *py_repr(void)
992         {
993                 return PyUnicode_From_STR_String(GetName());
994         }
995
996         KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
997         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce);
998         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque);
999         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyRotation);
1000         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyMovement);
1001         KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
1002         KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
1003         KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
1004         KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
1005         KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
1006         KX_PYMETHOD_VARARGS(KX_GameObject,SetDamping);
1007
1008         KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
1009
1010
1011         KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
1012         KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
1013         KX_PYMETHOD_VARARGS(KX_GameObject,SetOcclusion);
1014         KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
1015         KX_PYMETHOD_O(KX_GameObject,SetState);
1016         KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
1017         KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
1018         KX_PYMETHOD_VARARGS(KX_GameObject,SuspendDynamics);
1019         KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
1020         KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
1021         KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
1022         KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
1023         KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
1024         KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
1025         KX_PYMETHOD_VARARGS(KX_GameObject,SetParent);
1026         KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
1027         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
1028         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
1029         KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
1030         KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
1031         KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
1032         KX_PYMETHOD_VARARGS(KX_GameObject,ReplaceMesh);
1033         KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
1034         KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
1035         KX_PYMETHOD_DOC(KX_GameObject,rayCast);
1036         KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
1037         KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
1038         KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
1039         KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
1040         KX_PYMETHOD_DOC(KX_GameObject, addDebugProperty);
1041
1042         KX_PYMETHOD_DOC(KX_GameObject, playAction);
1043         KX_PYMETHOD_DOC(KX_GameObject, stopAction);
1044         KX_PYMETHOD_DOC(KX_GameObject, getActionFrame);
1045         KX_PYMETHOD_DOC(KX_GameObject, getActionName);
1046         KX_PYMETHOD_DOC(KX_GameObject, setActionFrame);
1047         KX_PYMETHOD_DOC(KX_GameObject, isPlayingAction);
1048         
1049         /* Dict access */
1050         KX_PYMETHOD_VARARGS(KX_GameObject,get);
1051         
1052         /* attributes */
1053         static PyObject*        pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1054         static PyObject*        pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1055
1056         static PyObject*        pyattr_get_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1057         static PyObject*        pyattr_get_group_members(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1058         static PyObject*        pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1059
1060         static PyObject*        pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1061         static PyObject*        pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1062         static int                      pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1063         static PyObject*        pyattr_get_is_suspend_dynamics(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1064         static PyObject*        pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1065         static int                      pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1066         static PyObject*        pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1067         static int                      pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1068         static PyObject*        pyattr_get_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1069         static int                      pyattr_set_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1070         static PyObject*        pyattr_get_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1071         static int                      pyattr_set_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1072         static PyObject*        pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1073         static int                      pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1074         static PyObject*        pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1075         static int                      pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1076         static PyObject*        pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1077         static int                      pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1078         static PyObject*        pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1079         static int                      pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1080         static PyObject*        pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1081         static int                      pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1082         static PyObject*        pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1083         static int                      pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1084         static PyObject*        pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1085         static int                      pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1086         static PyObject*        pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1087         static int                      pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1088         static PyObject*        pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1089         static int                      pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1090         static PyObject*        pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1091         static int                      pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1092         static PyObject*        pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1093         static int                      pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1094         static PyObject*        pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1095         static int                      pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1096         static PyObject*        pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1097         static int                      pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1098         static PyObject*        pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1099         static int                      pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1100         static PyObject*        pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1101         static int                      pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1102         static PyObject*        pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1103         static int                      pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1104         static PyObject*        pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1105         static int                      pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1106         static PyObject*        pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1107         static PyObject*        pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1108         static PyObject*        pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1109         static PyObject*        pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1110         static PyObject*        pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1111         static int                      pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1112         static PyObject*        pyattr_get_collisionCallbacks(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1113         static int                      pyattr_set_collisionCallbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1114         static PyObject*        pyattr_get_collisionGroup(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1115         static int                      pyattr_set_collisionGroup(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1116         static PyObject*        pyattr_get_collisionMask(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1117         static int                      pyattr_set_collisionMask(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1118         static PyObject*        pyattr_get_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1119         static int                      pyattr_set_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1120         static PyObject*        pyattr_get_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1121         static int                      pyattr_set_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1122         static PyObject*        pyattr_get_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1123         static int                      pyattr_set_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1124         static PyObject*        pyattr_get_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1125         static int                      pyattr_set_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1126
1127         /* Experimental! */
1128         static PyObject*        pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1129         static PyObject*        pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1130         static PyObject*        pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1131         
1132         /* getitem/setitem */
1133         static PyMappingMethods Mapping;
1134         static PySequenceMethods        Sequence;
1135 #endif
1136 };
1137
1138
1139
1140 #endif  /* __KX_GAMEOBJECT_H__ */