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