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