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