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