Fix build error on Windows 32 bit.
[blender-staging.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(SCA_LogicManager *logicmgr, 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
115         SG_Node*                                                        m_pSGNode;
116
117         MT_CmMatrix4x4                                          m_OpenGL_4x4Matrix;
118         std::vector<bRigidBodyJointConstraint*> m_constraints;
119
120         KX_ObstacleSimulation*                          m_pObstacleSimulation;
121
122         CListValue*                                                     m_pInstanceObjects;
123         KX_GameObject*                                          m_pDupliGroupObject;
124
125         // The action manager is used to play/stop/update actions
126         BL_ActionManager*                                       m_actionManager;
127
128         BL_ActionManager* GetActionManager();
129         
130         bool                                                            m_bRecordAnimation;
131
132 public:
133         bool                                                            m_isDeformable;
134
135         /**
136          * KX_GameObject custom infos for ray cast, it contains property name,
137          * collision mask, xray flag and hited object.
138          * This structure is created during ray cast and passed as argument 
139          * "data" to functions KX_GameObject::NeedRayCast and KX_GameObject::RayHit.
140          */
141         struct RayCastData;
142
143         /**
144          * Helper function for modules that can't include KX_ClientObjectInfo.h
145          */
146         static KX_GameObject* GetClientObject(KX_ClientObjectInfo* info);
147
148 #ifdef WITH_PYTHON
149         // Python attributes that wont convert into CValue
150         //
151         // there are 2 places attributes can be stored, in the CValue,
152         // where attributes are converted into BGE's CValue types
153         // these can be used with property actuators
154         //
155         // For the python API, For types that cannot be converted into CValues (lists, dicts, GameObjects)
156         // these will be put into "m_attr_dict", logic bricks cannot access them.
157         //
158         // rules for setting attributes.
159         //
160         // * there should NEVER be a CValue and a m_attr_dict attribute with matching names. get/sets make sure of this.
161         // * if CValue conversion fails, use a PyObject in "m_attr_dict"
162         // * when assigning a value, first see if it can be a CValue, if it can remove the "m_attr_dict" and set the CValue
163         //
164         PyObject*                                                       m_attr_dict;
165         PyObject*                                                       m_collisionCallbacks;
166 #endif
167
168         virtual void    /* This function should be virtual - derived classed override it */
169         Relink(
170                 CTR_Map<CTR_HashedPtr, void*> *map
171         );
172
173         /**
174          * Compute an OpenGl compatible 4x4 matrix. Has the
175          * side effect of storing the result internally. The
176          * memory for the matrix remains the property of this class.
177          */ 
178                 float *
179         GetOpenGLMatrix(
180         );
181
182         /**
183          * Return a pointer to a MT_CmMatrix4x4 storing the 
184          * opengl transformation for this object. This is updated
185          * by a call to GetOpenGLMatrix(). This class owns the 
186          * memory for the returned matrix.
187          */
188
189                 MT_CmMatrix4x4 *
190         GetOpenGLMatrixPtr(
191         ) { 
192                 return &m_OpenGL_4x4Matrix;
193         };
194
195         /**
196          * Update the blender object obmat field from the object world position
197          * if blendobj is NULL, update the object pointed by m_pBlenderObject
198          * The user must take action to restore the matrix before leaving the GE.
199          * Used in Armature evaluation
200          */
201                 void
202         UpdateBlenderObjectMatrix(Object* blendobj=NULL);
203
204         /**
205          * Used for constraint replication for group instances.
206          * The list of constraints is filled during data conversion.
207          */
208         void AddConstraint(bRigidBodyJointConstraint *cons);
209         std::vector<bRigidBodyJointConstraint*> GetConstraints();
210         void ClearConstraints();
211
212         /** 
213          * Get a pointer to the game object that is the parent of 
214          * this object. Or NULL if there is no parent. The returned
215          * object is part of a reference counting scheme. Calling
216          * this function ups the reference count on the returned 
217          * object. It is the responsibility of the caller to decrement
218          * the reference count when you have finished with it.
219          */
220                 KX_GameObject*
221         GetParent(
222         );
223
224         /** 
225          * Sets the parent of this object to a game object
226          */
227         void SetParent(KX_Scene *scene, KX_GameObject *obj, bool addToCompound=true, bool ghost=true);
228
229         /** 
230          * Removes the parent of this object to a game object
231          */
232         void RemoveParent(KX_Scene *scene);
233
234         /*********************************
235          * group reference API
236          *********************************/
237
238                 KX_GameObject*
239         GetDupliGroupObject(
240         );
241
242                 CListValue*
243         GetInstanceObjects(
244         );
245
246                 void
247         SetDupliGroupObject(KX_GameObject*
248         );
249
250                 void
251         AddInstanceObjects(KX_GameObject*
252         );
253                 
254                 void 
255         RemoveDupliGroupObject(
256         );
257
258                 void
259         RemoveInstanceObject(KX_GameObject*
260         );
261         /*********************************
262          * Animation API
263          *********************************/
264
265         /**
266          * Adds an action to the object's action manager
267          */
268         bool PlayAction(const char* name,
269                                         float start,
270                                         float end,
271                                         short layer=0,
272                                         short priority=0,
273                                         float blendin=0.f,
274                                         short play_mode=0,
275                                         float layer_weight=0.f,
276                                         short ipo_flags=0,
277                                         float playback_speed=1.f,
278                                         short blend_mode=0);
279
280         /**
281          * Gets the current frame of an action
282          */
283         float GetActionFrame(short layer);
284
285         /**
286          * Gets the name of the current action
287          */
288         const char *GetActionName(short layer);
289
290         /**
291          * Sets the current frame of an action
292          */
293         void SetActionFrame(short layer, float frame);
294
295         /**
296          * Gets the currently running action on the given layer
297          */
298         bAction *GetCurrentAction(short layer);
299
300         /**
301          * Sets play mode of the action on the given layer
302          */
303         void SetPlayMode(short layer, short mode);
304
305         /**
306          * Sets the start and end times of the action on the given layer
307          */
308         void SetTimes(short layer, float start, float end);
309
310         /**
311          * Stop playing the action on the given layer
312          */
313         void StopAction(short layer);
314
315         /**
316          * Remove playing tagged actions.
317          */
318         void RemoveTaggedActions();
319
320         /**
321          * Check if an action has finished playing
322          */
323         bool IsActionDone(short layer);
324
325         /**
326          * Kick the object's action manager
327          */
328         void UpdateActionManager(float curtime);
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         /// \see KX_RayCast
665         bool RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, RayCastData *rayData);
666         /// \see KX_RayCast
667         bool NeedRayCast(KX_ClientObjectInfo *client, RayCastData *rayData);
668
669
670         /**
671          * \section Physics accessors for this node.
672          *
673          * All these calls get passed directly to the physics controller 
674          * owned by this object.
675          * This is real interface bloat. Why not just use the physics controller
676          * directly? I think this is because the python interface is in the wrong
677          * place.
678          */
679
680                 void
681         ApplyForce(
682                 const MT_Vector3& force,        bool local
683         );
684
685                 void
686         ApplyTorque(
687                 const MT_Vector3& torque,
688                 bool local
689         );
690
691                 void
692         ApplyRotation(
693                 const MT_Vector3& drot,
694                 bool local
695         );
696
697                 void
698         ApplyMovement(
699                 const MT_Vector3& dloc,
700                 bool local
701         );
702
703                 void
704         addLinearVelocity(
705                 const MT_Vector3& lin_vel,
706                 bool local
707         );
708
709                 void
710         setLinearVelocity(
711                 const MT_Vector3& lin_vel,
712                 bool local
713         );
714
715                 void
716         setAngularVelocity(
717                 const MT_Vector3& ang_vel,
718                 bool local
719         );
720
721         virtual float   getLinearDamping() const;
722         virtual float   getAngularDamping() const;
723         virtual void    setLinearDamping(float damping);
724         virtual void    setAngularDamping(float damping);
725         virtual void    setDamping(float linear, float angular);
726
727         /**
728          * Update the physics object transform based upon the current SG_Node
729          * position.
730          */
731                 void
732         UpdateTransform(
733         );
734
735         static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
736
737         /**
738          * only used for sensor objects
739          */
740         void SynchronizeTransform();
741
742         static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
743
744         /**
745          * Function to set IPO option at start of IPO
746          */ 
747                 void
748         InitIPO(
749                 bool ipo_as_force,
750                 bool ipo_add,
751                 bool ipo_local
752         );
753
754         /**
755          * Odd function to update an ipo. ???
756          */ 
757                 void
758         UpdateIPO(
759                 float curframetime,
760                 bool recurse
761         );
762         /**
763          * Updates Material Ipo data 
764          */
765                 void 
766         UpdateMaterialData(
767                 dword matname_hash,
768                 MT_Vector4 rgba,
769                 MT_Vector3 specrgb,
770                 MT_Scalar hard,
771                 MT_Scalar spec,
772                 MT_Scalar ref,
773                 MT_Scalar emit,
774                 MT_Scalar alpha
775         );
776
777         /**
778          * \section Mesh accessor functions.
779          */
780
781         /**
782          * Update buckets to indicate that there is a new
783          * user of this object's meshes.
784          */
785                 void
786         AddMeshUser(
787         );
788         
789         /**
790          * Update buckets with data about the mesh after
791          * creating or duplicating the object, changing
792          * visibility, object color, .. .
793          */
794                 void
795         UpdateBuckets(
796                 bool recursive
797         );
798
799         /**
800          * Clear the meshes associated with this class
801          * and remove from the bucketing system.
802          * Don't think this actually deletes any of the meshes.
803          */
804                 void
805         RemoveMeshes(
806         );
807
808         /**
809          * Add a mesh to the set of meshes associated with this
810          * node. Meshes added in this way are not deleted by this class.
811          * Make sure you call RemoveMeshes() before deleting the
812          * mesh though,
813          */
814                 void
815         AddMesh(
816                 RAS_MeshObject* mesh
817         ) {
818                 m_meshes.push_back(mesh);
819         }
820
821         /**
822          * Add a level of detail mesh to the object. These should
823          * be added in order.
824          */
825                 void
826         AddLodMesh(
827                 RAS_MeshObject* mesh
828         );
829
830         /**
831          * Updates the current lod level based on distance from camera.
832          */
833                 void
834         UpdateLod(
835                 MT_Vector3 &cam_pos
836         );
837
838         /**
839          * Pick out a mesh associated with the integer 'num'.
840          */
841                 RAS_MeshObject*
842         GetMesh(
843                 int num
844         ) const { 
845                 return m_meshes[num]; 
846         }
847
848         /**
849          * Return the number of meshes currently associated with this
850          * game object.
851          */
852                 int
853         GetMeshCount(
854         ) const { 
855                 return m_meshes.size(); 
856         }
857         
858         /**
859          * Set the debug color of the meshes associated with this
860          * class. Does this still work?
861          */
862                 void
863         SetDebugColor(
864                 unsigned int bgra
865         );
866
867         /** 
868          * Reset the debug color of meshes associated with this class.
869          */
870                 void
871         ResetDebugColor(
872         );
873
874         /**
875          * Was this object marked visible? (only for the explicit
876          * visibility system).
877          */
878                 bool
879         GetVisible(
880                 void
881         );
882
883         /**
884          * Set visibility flag of this object
885          */
886                 void
887         SetVisible(
888                 bool b,
889                 bool recursive
890         );
891
892         /**
893          * Was this object culled?
894          */
895         inline bool
896         GetCulled(
897                 void
898         ) { return m_bCulled; }
899
900         /**
901          * Set culled flag of this object
902          */
903         inline void
904         SetCulled(
905                 bool c
906         ) { m_bCulled = c; }
907         
908         /**
909          * Is this object an occluder?
910          */
911         inline bool
912         GetOccluder(
913                 void
914         ) { return m_bOccluder; }
915
916         /**
917          * Set occluder flag of this object
918          */
919         void
920         SetOccluder(
921                 bool v,
922                 bool recursive
923         );
924         
925         /**
926          * Change the layer of the object (when it is added in another layer
927          * than the original layer)
928          */
929         virtual void
930         SetLayer(
931                 int l
932         );
933
934         /**
935          * Get the object layer
936          */
937                 int
938         GetLayer(
939                 void
940         );
941                 
942         /**
943          * Get the negative scaling state
944          */
945                 bool
946         IsNegativeScaling(
947                 void
948         ) { return m_bIsNegativeScaling; }
949
950         /**
951          * \section Logic bubbling methods.
952          */
953
954         void RegisterCollisionCallbacks();
955         void UnregisterCollisionCallbacks();
956         void RunCollisionCallbacks(KX_GameObject *collider, const MT_Vector3 &point, const MT_Vector3 &normal);
957         /**
958          * Stop making progress
959          */
960         void Suspend(void);
961
962         /**
963          * Resume making progress
964          */
965         void Resume(void);
966
967         void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
968         {
969                 m_pObstacleSimulation = obstacleSimulation;
970         }
971
972         void UnregisterObstacle()
973         {
974                 m_pObstacleSimulation = NULL;
975         }
976         
977         /**
978          * add debug object to the debuglist.
979          */
980         void SetUseDebugProperties(bool debug, bool recursive);
981
982         KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
983         
984         CListValue* GetChildren();
985         CListValue* GetChildrenRecursive();
986
987         KX_Scene*       GetScene();
988
989 #ifdef WITH_PYTHON
990         /**
991          * \section Python interface functions.
992          */
993         virtual PyObject *py_repr(void)
994         {
995                 return PyUnicode_From_STR_String(GetName());
996         }
997
998         KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
999         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce);
1000         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque);
1001         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyRotation);
1002         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyMovement);
1003         KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
1004         KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
1005         KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
1006         KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
1007         KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
1008         KX_PYMETHOD_VARARGS(KX_GameObject,SetDamping);
1009
1010         KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
1011
1012
1013         KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
1014         KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
1015         KX_PYMETHOD_VARARGS(KX_GameObject,SetOcclusion);
1016         KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
1017         KX_PYMETHOD_O(KX_GameObject,SetState);
1018         KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
1019         KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
1020         KX_PYMETHOD_VARARGS(KX_GameObject,SuspendDynamics);
1021         KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
1022         KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
1023         KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
1024         KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
1025         KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
1026         KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
1027         KX_PYMETHOD_VARARGS(KX_GameObject,SetParent);
1028         KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
1029         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
1030         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
1031         KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
1032         KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
1033         KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
1034         KX_PYMETHOD_VARARGS(KX_GameObject,ReplaceMesh);
1035         KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
1036         KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
1037         KX_PYMETHOD_DOC(KX_GameObject,rayCast);
1038         KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
1039         KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
1040         KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
1041         KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
1042         KX_PYMETHOD_DOC(KX_GameObject, addDebugProperty);
1043
1044         KX_PYMETHOD_DOC(KX_GameObject, playAction);
1045         KX_PYMETHOD_DOC(KX_GameObject, stopAction);
1046         KX_PYMETHOD_DOC(KX_GameObject, getActionFrame);
1047         KX_PYMETHOD_DOC(KX_GameObject, getActionName);
1048         KX_PYMETHOD_DOC(KX_GameObject, setActionFrame);
1049         KX_PYMETHOD_DOC(KX_GameObject, isPlayingAction);
1050         
1051         /* Dict access */
1052         KX_PYMETHOD_VARARGS(KX_GameObject,get);
1053         
1054         /* attributes */
1055         static PyObject*        pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1056         static PyObject*        pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1057
1058         static PyObject*        pyattr_get_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1059         static PyObject*        pyattr_get_group_members(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1060         static PyObject*        pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1061
1062         static PyObject*        pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1063         static PyObject*        pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1064         static int                      pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1065         static PyObject*        pyattr_get_is_suspend_dynamics(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1066         static PyObject*        pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1067         static int                      pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1068         static PyObject*        pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1069         static int                      pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1070         static PyObject*        pyattr_get_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1071         static int                      pyattr_set_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1072         static PyObject*        pyattr_get_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1073         static int                      pyattr_set_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1074         static PyObject*        pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1075         static int                      pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1076         static PyObject*        pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1077         static int                      pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1078         static PyObject*        pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1079         static int                      pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1080         static PyObject*        pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1081         static int                      pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1082         static PyObject*        pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1083         static int                      pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1084         static PyObject*        pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1085         static int                      pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1086         static PyObject*        pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1087         static int                      pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1088         static PyObject*        pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1089         static int                      pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1090         static PyObject*        pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1091         static int                      pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1092         static PyObject*        pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1093         static int                      pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1094         static PyObject*        pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1095         static int                      pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1096         static PyObject*        pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1097         static int                      pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1098         static PyObject*        pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1099         static int                      pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1100         static PyObject*        pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1101         static int                      pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1102         static PyObject*        pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1103         static int                      pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1104         static PyObject*        pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1105         static int                      pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1106         static PyObject*        pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1107         static int                      pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1108         static PyObject*        pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1109         static PyObject*        pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1110         static PyObject*        pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1111         static PyObject*        pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1112         static PyObject*        pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1113         static int                      pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1114         static PyObject*        pyattr_get_collisionCallbacks(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1115         static int                      pyattr_set_collisionCallbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1116         static PyObject*        pyattr_get_collisionGroup(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1117         static int                      pyattr_set_collisionGroup(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1118         static PyObject*        pyattr_get_collisionMask(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
1119         static int                      pyattr_set_collisionMask(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1120         static PyObject*        pyattr_get_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1121         static int                      pyattr_set_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1122         static PyObject*        pyattr_get_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1123         static int                      pyattr_set_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1124         static PyObject*        pyattr_get_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1125         static int                      pyattr_set_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1126         static PyObject*        pyattr_get_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1127         static int                      pyattr_set_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
1128
1129         /* Experimental! */
1130         static PyObject*        pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1131         static PyObject*        pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1132         static PyObject*        pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
1133         
1134         /* getitem/setitem */
1135         static PyMappingMethods Mapping;
1136         static PySequenceMethods        Sequence;
1137 #endif
1138 };
1139
1140
1141
1142 #endif  /* __KX_GAMEOBJECT_H__ */