172272150c0a3a76dcf8f2abc623a1ef7075871f
[blender-staging.git] / source / gameengine / Ketsji / KX_GameObject.h
1 /*
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  * General KX game object.
29  */
30
31 #ifndef __KX_GAMEOBJECT
32 #define __KX_GAMEOBJECT
33
34 #ifdef WIN32
35 // get rid of this stupid "warning 'this' used in initialiser list", generated by VC when including Solid/Sumo
36 #pragma warning (disable : 4355) 
37 #endif 
38
39
40 #include "ListValue.h"
41 #include "SCA_IObject.h"
42 #include "SG_Node.h"
43 #include "MT_Transform.h"
44 #include "MT_CmMatrix4x4.h"
45 #include "GEN_Map.h"
46 #include "GEN_HashedPtr.h"
47 #include "KX_Scene.h"
48 #include "KX_KetsjiEngine.h" /* for m_anim_framerate */
49 #include "KX_IPhysicsController.h" /* for suspend/resume */
50 #include "DNA_object_types.h"
51 #include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
52 #define KX_OB_DYNAMIC 1
53
54
55 //Forward declarations.
56 struct KX_ClientObjectInfo;
57 class KX_RayCast;
58 class RAS_MeshObject;
59 class KX_IPhysicsController;
60 class PHY_IGraphicController;
61 class PHY_IPhysicsEnvironment;
62 struct Object;
63
64 /**
65  * KX_GameObject is the main class for dynamic objects.
66  */
67 class KX_GameObject : public SCA_IObject
68 {
69         Py_Header;
70 protected:
71
72         bool                                                            m_bDyna;
73         KX_ClientObjectInfo*                            m_pClient_info;
74         STR_String                                                      m_name;
75         STR_String                                                      m_text;
76         int                                                                     m_layer;
77         std::vector<RAS_MeshObject*>            m_meshes;
78         struct Object*                                          m_pBlenderObject;
79         struct Object*                                          m_pBlenderGroupObject;
80         
81         bool                                                            m_bSuspendDynamics;
82         bool                                                            m_bUseObjectColor;
83         bool                                                            m_bIsNegativeScaling;
84         MT_Vector4                                                      m_objectColor;
85
86         // visible = user setting
87         // culled = while rendering, depending on camera
88         bool                                                            m_bVisible; 
89         bool                                                            m_bCulled; 
90
91         KX_IPhysicsController*                          m_pPhysicsController1;
92         PHY_IGraphicController*                         m_pGraphicController;
93         // used for ray casting
94         PHY_IPhysicsEnvironment*                        m_pPhysicsEnvironment;
95         STR_String                                                      m_testPropName;
96         bool                                                            m_xray;
97         KX_GameObject*                                          m_pHitObject;
98
99         SG_Node*                                                        m_pSGNode;
100
101         MT_CmMatrix4x4                                          m_OpenGL_4x4Matrix;
102         
103 public:
104         bool                                                            m_isDeformable;
105
106         // Python attributes that wont convert into CValue
107         // 
108         // there are 2 places attributes can be stored, in the CValue,
109         // where attributes are converted into BGE's CValue types
110         // these can be used with property actuators
111         //
112         // For the python API, For types that cannot be converted into CValues (lists, dicts, GameObjects)
113         // these will be put into "m_attrlist", logic bricks cannot access them.
114         // 
115         // rules for setting attributes.
116         // 
117         // * there should NEVER be a CValue and a m_attrlist attribute with matching names. get/sets make sure of this.
118         // * if CValue conversion fails, use a PyObject in "m_attrlist"
119         // * when assigning a value, first see if it can be a CValue, if it can remove the "m_attrlist" and set the CValue
120         // 
121         
122         PyObject*                                                       m_attrlist; 
123
124
125
126         virtual void    /* This function should be virtual - derived classed override it */
127         Relink(
128                 GEN_Map<GEN_HashedPtr, void*> *map
129         );
130
131         /**
132          * Compute an OpenGl compatable 4x4 matrix. Has the
133          * side effect of storing the result internally. The
134          * memory for the matrix remains the property of this class.
135          */ 
136                 double*                                         
137         GetOpenGLMatrix(
138         );
139
140         /**
141          * Return a pointer to a MT_CmMatrix4x4 storing the 
142          * opengl transformation for this object. This is updated
143          * by a call to GetOpenGLMatrix(). This class owns the 
144          * memory for the returned matrix.
145          */
146
147                 MT_CmMatrix4x4*                         
148         GetOpenGLMatrixPtr(
149         ) { 
150                 return &m_OpenGL_4x4Matrix;
151         };
152
153         /** 
154          * Get a pointer to the game object that is the parent of 
155          * this object. Or NULL if there is no parent. The returned
156          * object is part of a reference counting scheme. Calling
157          * this function ups the reference count on the returned 
158          * object. It is the responsibility of the caller to decrement
159          * the reference count when you have finished with it.
160          */
161                 KX_GameObject*                          
162         GetParent(
163         );
164
165         /** 
166          * Sets the parent of this object to a game object
167          */                     
168         void SetParent(KX_Scene *scene, KX_GameObject *obj);
169
170         /** 
171          * Removes the parent of this object to a game object
172          */                     
173         void RemoveParent(KX_Scene *scene);
174
175         /**
176          * Construct a game object. This class also inherits the 
177          * default constructors - use those with care!
178          */
179
180         KX_GameObject(
181                 void* sgReplicationInfo,
182                 SG_Callbacks callbacks,
183                 PyTypeObject* T=&Type
184         );
185
186         virtual 
187         ~KX_GameObject(
188         );
189
190                 CValue*                         
191         AddRef() { 
192                 /* temporarily to find memleaks */ return CValue::AddRef(); 
193         }
194
195         /** 
196          * @section Stuff which is here due to poor design.
197          * Inherited from CValue and needs an implementation. 
198          * Do not expect these functions do to anything sensible.
199          */
200
201         /**
202          * Inherited from CValue -- does nothing!
203          */
204                 CValue*                         
205         Calc(
206                 VALUE_OPERATOR op,
207                 CValue *val
208         );
209
210         /**
211          * Inherited from CValue -- does nothing!
212          */
213                 CValue*                         
214         CalcFinal(
215                 VALUE_DATA_TYPE dtype,
216                 VALUE_OPERATOR op,
217                 CValue *val
218         );
219
220         /**
221          * Inherited from CValue -- does nothing!
222          */
223         const 
224                 STR_String &    
225         GetText(
226         );
227
228         /**
229          * Inherited from CValue -- does nothing!
230          */
231                 double
232         GetNumber(
233         );
234
235         /**
236          * @section Inherited from CValue. These are the useful
237          * part of the CValue interface that this class implements. 
238          */
239
240         /**
241          * Inherited from CValue -- returns the name of this object.
242          */
243                 STR_String                      
244         GetName(
245         );
246
247         /**
248          * Inherited from CValue -- set the name of this object.
249          */
250                 void                            
251         SetName(
252                 STR_String name
253         );
254
255         /**
256          * Inherited from CValue -- does nothing.
257          */
258                 void                            
259         ReplicaSetName(
260                 STR_String name
261         );
262
263         /** 
264          * Inherited from CValue -- return a new copy of this
265          * instance allocated on the heap. Ownership of the new 
266          * object belongs with the caller.
267          */
268         virtual CValue*                         
269         GetReplica(
270         );
271         
272         /**
273          * Inherited from CValue -- Makes sure any internal 
274          * data owned by this class is deep copied. Called internally
275          */
276         virtual void                            
277         ProcessReplica(
278                 KX_GameObject* replica
279         );
280
281         /** 
282          * Return the linear velocity of the game object.
283          */
284                 MT_Vector3 
285         GetLinearVelocity(
286                 bool local=false
287         );
288
289         /** 
290          * Return the linear velocity of a given point in world coordinate
291          * but relative to center of object ([0,0,0]=center of object)
292          */
293                 MT_Vector3 
294         GetVelocity(
295                 const MT_Point3& position
296         );
297
298         /**
299          * Return the mass of the object
300          */
301                 MT_Scalar       
302         GetMass();
303
304         /**
305          * Return the local inertia vector of the object
306          */
307                 MT_Vector3
308         GetLocalInertia();
309
310         /** 
311          * Return the angular velocity of the game object.
312          */
313                 MT_Vector3 
314         GetAngularVelocity(
315                 bool local=false
316         );
317
318         /** 
319          * Align the object to a given normal.
320          */
321                 void 
322         AlignAxisToVect(
323                 const MT_Vector3& vect,
324                 int axis = 2,
325                 float fac = 1.0
326         );
327
328         /** 
329          * Quick'n'dirty obcolor ipo stuff
330          */
331
332                 void                            
333         SetObjectColor(
334                 const MT_Vector4& rgbavec
335         );
336
337
338                 void 
339         ResolveCombinedVelocities(
340                 const MT_Vector3 & lin_vel,
341                 const MT_Vector3 & ang_vel,
342                 bool lin_vel_local,
343                 bool ang_vel_local
344         );
345
346
347         /**
348          * @return a pointer to the physics environment in use during the game, for rayCasting
349          */
350         PHY_IPhysicsEnvironment* GetPhysicsEnvironment()
351         {
352                 return m_pPhysicsEnvironment;
353         }
354
355         void SetPhysicsEnvironment(PHY_IPhysicsEnvironment* physicsEnvironment)
356         {
357                 m_pPhysicsEnvironment = physicsEnvironment;
358         }
359
360         /**
361          * @return a pointer to the physics controller owned by this class.
362          */
363
364         KX_IPhysicsController* GetPhysicsController() ;
365
366         void    SetPhysicsController(KX_IPhysicsController*     physicscontroller,bool isDynamic) 
367         { 
368                 m_bDyna = isDynamic;
369                 m_pPhysicsController1 = physicscontroller;
370         }
371
372         virtual class RAS_Deformer* GetDeformer()
373         {
374                 return 0;
375         }
376         virtual void    SetDeformer(class RAS_Deformer* deformer)
377         {
378
379         }
380
381         /**
382          * @return a pointer to the graphic controller owner by this class 
383          */
384         PHY_IGraphicController* GetGraphicController()
385         {
386                 return m_pGraphicController;
387         }
388
389         void SetGraphicController(PHY_IGraphicController* graphiccontroller) 
390         { 
391                 m_pGraphicController = graphiccontroller;
392         }
393
394         /**
395          * @section Coordinate system manipulation functions
396          */
397
398         void    NodeSetLocalPosition(const MT_Point3& trans     );
399
400         void    NodeSetLocalOrientation(const MT_Matrix3x3& rot );
401
402         void    NodeSetLocalScale(      const MT_Vector3& scale );
403
404         void    NodeSetRelativeScale(   const MT_Vector3& scale );
405
406         // adapt local position so that world position is set to desired position
407         void    NodeSetWorldPosition(const MT_Point3& trans);
408
409                 void                                            
410         NodeUpdateGS(
411                 double time
412         );
413
414         const 
415                 MT_Matrix3x3&                   
416         NodeGetWorldOrientation(
417         ) const;
418
419         const 
420                 MT_Vector3&                     
421         NodeGetWorldScaling(
422         ) const;
423
424         const 
425                 MT_Point3&                      
426         NodeGetWorldPosition(
427         ) const;
428
429
430         /**
431          * @section scene graph node accessor functions.
432          */
433
434         SG_Node*        GetSGNode(      ) 
435         { 
436                 return m_pSGNode;
437         }
438
439         const   SG_Node* GetSGNode(     ) const 
440         { 
441                 return m_pSGNode;
442         }
443
444         /**
445          * @section blender object accessor functions.
446          */
447
448         struct Object* GetBlenderObject( )
449         {
450                 return m_pBlenderObject;
451         }
452
453         void SetBlenderObject( struct Object* obj)
454         {
455                 m_pBlenderObject = obj;
456         }
457
458         struct Object* GetBlenderGroupObject( )
459         {
460                 return m_pBlenderGroupObject;
461         }
462
463         void SetBlenderGroupObject( struct Object* obj)
464         {
465                 m_pBlenderGroupObject = obj;
466         }
467         
468         bool IsDupliGroup()
469         { 
470                 return (m_pBlenderObject &&
471                                 (m_pBlenderObject->transflag & OB_DUPLIGROUP) &&
472                                 m_pBlenderObject->dup_group != NULL) ? true : false;
473         }
474
475         /**
476          * Set the Scene graph node for this game object.
477          * warning - it is your responsibility to make sure
478          * all controllers look at this new node. You must
479          * also take care of the memory associated with the
480          * old node. This class takes ownership of the new
481          * node.
482          */
483                 void    SetSGNode(SG_Node* node )
484                 { 
485                         m_pSGNode = node; 
486                 }
487         
488         //Is it a dynamic/physics object ?
489         bool    IsDynamic() const 
490         { 
491                 return m_bDyna; 
492         }
493
494         /**
495          * Check if this object has a vertex parent relationship
496          */
497         bool IsVertexParent( )
498         {
499                 return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
500         }
501
502         bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
503         bool NeedRayCast(KX_ClientObjectInfo* client);
504
505
506         /**
507          * @section Physics accessors for this node.
508          *
509          * All these calls get passed directly to the physics controller 
510          * owned by this object.
511          * This is real interface bloat. Why not just use the physics controller
512          * directly? I think this is because the python interface is in the wrong
513          * place.
514          */
515
516                 void                                            
517         ApplyForce(
518                 const MT_Vector3& force,        bool local
519         );
520
521                 void                                            
522         ApplyTorque(
523                 const MT_Vector3& torque,
524                 bool local
525         );
526
527                 void                                            
528         ApplyRotation(
529                 const MT_Vector3& drot,
530                 bool local
531         );
532
533                 void                                            
534         ApplyMovement(
535                 const MT_Vector3& dloc,
536                 bool local
537         );
538
539                 void                                            
540         addLinearVelocity(
541                 const MT_Vector3& lin_vel,
542                 bool local
543         );
544
545                 void                                            
546         setLinearVelocity(
547                 const MT_Vector3& lin_vel,
548                 bool local
549         );
550
551                 void                                            
552         setAngularVelocity(
553                 const MT_Vector3& ang_vel,
554                 bool local
555         );
556
557         /**     
558          * Update the physics object transform based upon the current SG_Node
559          * position.
560          */
561                 void
562         UpdateTransform(
563         );
564
565         static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
566
567         /**
568          * Function to set IPO option at start of IPO
569          */ 
570                 void    
571         InitIPO(
572                 bool ipo_as_force,
573                 bool ipo_add,
574                 bool ipo_local
575         );
576
577         /**
578          * Odd function to update an ipo. ???
579          */ 
580                 void    
581         UpdateIPO(
582                 float curframetime,
583                 bool recurse
584         );
585         /**
586          * Updates Material Ipo data 
587          */
588                 void 
589         UpdateMaterialData(
590                 dword matname_hash,
591                 MT_Vector4 rgba,
592                 MT_Vector3 specrgb,
593                 MT_Scalar hard,
594                 MT_Scalar spec,
595                 MT_Scalar ref,
596                 MT_Scalar emit,
597                 MT_Scalar alpha
598         );
599
600         /**
601          * @section Mesh accessor functions.
602          */
603
604         /**     
605          * Update buckets to indicate that there is a new
606          * user of this object's meshes.
607          */
608                 void                                            
609         AddMeshUser(
610         );
611         
612         /**     
613          * Update buckets with data about the mesh after
614          * creating or duplicating the object, changing
615          * visibility, object color, .. .
616          */
617                 void                                            
618         UpdateBuckets(
619                 bool recursive
620         );
621
622         /**
623          * Clear the meshes associated with this class
624          * and remove from the bucketing system.
625          * Don't think this actually deletes any of the meshes.
626          */
627                 void                                            
628         RemoveMeshes(
629         );
630
631         /**
632          * Add a mesh to the set of meshes associated with this
633          * node. Meshes added in this way are not deleted by this class.
634          * Make sure you call RemoveMeshes() before deleting the
635          * mesh though,
636          */
637                 void                                            
638         AddMesh(
639                 RAS_MeshObject* mesh
640         ){ 
641                 m_meshes.push_back(mesh);
642         }
643
644         /**
645          * Pick out a mesh associated with the integer 'num'.
646          */
647                 RAS_MeshObject*                         
648         GetMesh(
649                 int num
650         ) const { 
651                 return m_meshes[num]; 
652         }
653
654         /**
655          * Return the number of meshes currently associated with this
656          * game object.
657          */
658                 int                                                     
659         GetMeshCount(
660         ) const { 
661                 return m_meshes.size(); 
662         }
663         
664         /**     
665          * Set the debug color of the meshes associated with this
666          * class. Does this still work?
667          */
668                 void                                            
669         SetDebugColor(
670                 unsigned int bgra
671         );
672
673         /** 
674          * Reset the debug color of meshes associated with this class.
675          */
676                 void                                            
677         ResetDebugColor(
678         );
679
680         /**
681          * Was this object marked visible? (only for the explicit
682          * visibility system).
683          */
684                 bool
685         GetVisible(
686                 void
687         );
688
689         /**
690          * Set visibility flag of this object
691          */
692                 void
693         SetVisible(
694                 bool b,
695                 bool recursive
696         );
697
698         /**
699          * Was this object culled?
700          */
701                 bool
702         GetCulled(
703                 void
704         );
705
706         /**
707          * Set culled flag of this object
708          */
709                 void
710         SetCulled(
711                 bool c
712         );
713
714         /**
715          * Change the layer of the object (when it is added in another layer
716          * than the original layer)
717          */
718                 void
719         SetLayer(
720                 int l
721         );
722
723         /**
724          * Get the object layer
725          */
726                 int
727         GetLayer(
728                 void
729         );
730                 
731         /**
732          * Get the negative scaling state
733          */
734                 bool
735         IsNegativeScaling(
736                 void
737         ) { return m_bIsNegativeScaling; }
738
739         /**
740          * Is this a light?
741          */
742                 virtual bool
743         IsLight(
744                 void
745         ) { return false; }
746
747         /**
748          * @section Logic bubbling methods.
749          */
750
751         /**
752          * Stop making progress
753          */
754         void Suspend(void);
755
756         /**
757          * Resume making progress
758          */
759         void Resume(void);
760         
761         void SuspendDynamics(void) {
762                 if (m_bSuspendDynamics)
763                 {
764                         return;
765                 }
766         
767                 if (m_pPhysicsController1)
768                 {
769                         m_pPhysicsController1->SuspendDynamics();
770                 }
771                 m_bSuspendDynamics = true;
772         }
773         
774         void RestoreDynamics(void) {    
775                 if (!m_bSuspendDynamics)
776                 {
777                         return;
778                 }
779         
780                 if (m_pPhysicsController1)
781                 {
782                         m_pPhysicsController1->RestoreDynamics();
783                 }
784                 m_bSuspendDynamics = false;
785         }
786         
787         KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
788         /**
789          * @section Python interface functions.
790          */
791         
792         virtual PyObject* py_getattro(PyObject *attr);
793         virtual int py_setattro(PyObject *attr, PyObject *value);               // py_setattro method
794         virtual PyObject* py_repr(void) { return PyString_FromString(GetName().ReadPtr()); }
795         
796         /* we need our own getattr and setattr types */
797         /* See m_attrlist definition for rules on how this works */
798         static PyObject *py_base_getattro_gameobject(PyObject * self, PyObject *attr)
799         {
800                 PyObject *object= ((KX_GameObject *) self)->py_getattro(attr);
801                 
802                 if (object==NULL && ((KX_GameObject *) self)->m_attrlist) {
803                         /* backup the exception incase the attr doesnt exist in the dict either */
804                         PyObject *err_type, *err_value, *err_tb;
805                         PyErr_Fetch(&err_type, &err_value, &err_tb);
806                         
807                         object= PyDict_GetItem(((KX_GameObject *) self)->m_attrlist, attr);
808                         if (object) {
809                                 Py_INCREF(object);
810                                 
811                                 PyErr_Clear();
812                                 Py_XDECREF( err_type );
813                                 Py_XDECREF( err_value );
814                                 Py_XDECREF( err_tb );
815                         }
816                         else {
817                                 PyErr_Restore(err_type, err_value, err_tb); /* use the error from the parent function */
818                         }
819                 }
820                 return object;
821         }
822         
823         static int py_base_setattro_gameobject(PyObject * self, PyObject *attr, PyObject *value)
824         {
825                 int ret;
826                 
827                 /* Delete the item */
828                 if (value==NULL)
829                 {
830                         ret= ((PyObjectPlus*) self)->py_delattro(attr);
831                         
832                         if (ret != 0) /* CValue attribute failed, try KX_GameObject m_attrlist dict */
833                         {
834                                 if (((KX_GameObject *) self)->m_attrlist)
835                                 {
836                                         /* backup the exception incase the attr doesnt exist in the dict either */
837                                         PyObject *err_type, *err_value, *err_tb;
838                                         PyErr_Fetch(&err_type, &err_value, &err_tb);
839                                         
840                                         if (PyDict_DelItem(((KX_GameObject *) self)->m_attrlist, attr) == 0)
841                                         {
842                                                 ret= 0;
843                                                 PyErr_Clear();
844                                                 Py_XDECREF( err_type );
845                                                 Py_XDECREF( err_value );
846                                                 Py_XDECREF( err_tb );
847                                         }
848                                         else { 
849                                                 PyErr_Restore(err_type, err_value, err_tb); /* use the error from the parent function */
850                                         }
851                                 }
852                         }
853                         return ret;
854                 }
855                 
856                 
857                 ret= ((PyObjectPlus*) self)->py_setattro(attr, value);
858                 
859                 if (ret==PY_SET_ATTR_SUCCESS) {
860                         /* remove attribute in our own dict to avoid double ups */
861                         if (((KX_GameObject *) self)->m_attrlist) {
862                                 if (PyDict_DelItem(((KX_GameObject *) self)->m_attrlist, attr) != 0)
863                                         PyErr_Clear();
864                         }
865                 }
866                 
867                 if (ret==PY_SET_ATTR_COERCE_FAIL) {
868                         /* CValue attribute exists, remove and add dict value */
869                         ((KX_GameObject *) self)->RemoveProperty(STR_String(PyString_AsString(attr)));
870                         ret= PY_SET_ATTR_MISSING;
871                 }
872                 
873                 if (ret==PY_SET_ATTR_MISSING) {
874                         /* Lazy initialization */
875                         if (((KX_GameObject *) self)->m_attrlist==NULL)
876                                 ((KX_GameObject *) self)->m_attrlist = PyDict_New();
877                         
878                         if (PyDict_SetItem(((KX_GameObject *) self)->m_attrlist, attr, value)==0) {
879                                 PyErr_Clear();
880                                 ret= PY_SET_ATTR_SUCCESS;
881                         }
882                         else {
883                                 PyErr_Format(PyExc_AttributeError, "failed assigning value to KX_GameObject internal dictionary");
884                                 ret= PY_SET_ATTR_FAIL;
885                         }
886                 }
887                 
888                 return ret;
889         }
890         
891         
892         
893         KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition);
894         KX_PYMETHOD_O(KX_GameObject,SetPosition);
895         KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
896         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce);
897         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque);
898         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyRotation);
899         KX_PYMETHOD_VARARGS(KX_GameObject, ApplyMovement);
900         KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
901         KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
902         KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
903         KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
904         KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
905         KX_PYMETHOD_NOARGS(KX_GameObject,GetMass);
906         KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
907         KX_PYMETHOD_NOARGS(KX_GameObject,GetOrientation);
908         KX_PYMETHOD_O(KX_GameObject,SetOrientation);
909         KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
910         KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
911         KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
912         KX_PYMETHOD_O(KX_GameObject,SetState);
913         KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
914         KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
915         KX_PYMETHOD_NOARGS(KX_GameObject,SuspendDynamics);
916         KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
917         KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
918         KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
919         KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
920         KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
921         KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
922         KX_PYMETHOD_O(KX_GameObject,SetParent);
923         KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
924         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);  
925         KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
926         KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
927         KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
928         KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
929         KX_PYMETHOD_O(KX_GameObject,ReplaceMesh);
930         KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
931         KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
932         KX_PYMETHOD_DOC(KX_GameObject,rayCast);
933         KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
934         KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
935         KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
936         /* attributes */
937         static PyObject*        pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
938         static PyObject*        pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
939
940         static PyObject*        pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
941         static int                      pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
942         static PyObject*        pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
943         static int                      pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
944         static PyObject*        pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
945         static int                      pyattr_set_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
946         static PyObject*        pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
947         static int                      pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
948         static PyObject*        pyattr_get_orientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
949         static int                      pyattr_set_orientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
950         static PyObject*        pyattr_get_scaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
951         static int                      pyattr_set_scaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
952         static PyObject*        pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
953         static int                      pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
954         static PyObject*        pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
955         static int                      pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
956         static PyObject*        pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
957         
958         /* for dir(), python3 uses __dir__() */
959         static PyObject*        pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
960         
961         /* Experemental! */
962         static PyObject*        pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
963         static PyObject*        pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
964         static PyObject*        pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
965         
966         /* getitem/setitem */
967         static Py_ssize_t                       Map_Len(PyObject* self);
968         static PyMappingMethods Mapping;
969         static PyObject*                        Map_GetItem(PyObject *self_v, PyObject *item);
970         static int                                      Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val);
971         
972         
973 private :
974
975         /**     
976          * Random internal function to convert python function arguments
977          * to 2 vectors.
978          * @return true if conversion was possible.
979          */
980
981                 bool                                            
982         ConvertPythonVectorArgs(
983                 PyObject* args,
984                 MT_Vector3& pos,
985                 MT_Vector3& pos2
986         );      
987
988 };
989
990 /* utility conversion function */
991 bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok);
992
993 #endif //__KX_GAMEOBJECT
994