Merge of itasc branch. Project files, scons and cmake should be working. Makefile...
[blender.git] / source / gameengine / Converter / BL_ArmatureObject.h
index e1e1768..3e917e0 100644 (file)
 #define BL_ARMATUREOBJECT
 
 #include "KX_GameObject.h"
+#include "BL_ArmatureConstraint.h"
+#include "BL_ArmatureChannel.h"
 
 #include "SG_IObject.h"
+#include <vector>
+#include <algorithm>
 
 struct bArmature;
 struct Bone;
+struct bConstraint;
 class BL_ActionActuator;
+class BL_ArmatureActuator;
 class MT_Matrix4x4;
 struct Object;
+class KX_BlenderSceneConverter;
 
 class BL_ArmatureObject : public KX_GameObject  
 {
+       Py_Header;
 public:
+
        double GetLastFrame ();
        short GetActivePriority();
        virtual void ProcessReplica();
+       virtual void ReParentLogic();
+       virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
+       virtual bool UnlinkObject(SCA_IObject* clientobj);
+
        class BL_ActionActuator * GetActiveAction();
        
        BL_ArmatureObject(
@@ -60,6 +73,7 @@ public:
        void GetMRDPose(struct bPose **pose);
        void GetPose(struct bPose **pose);
        void SetPose (struct bPose *pose);
+       struct bPose *GetOrigPose() {return m_pose;} // never edit this, only for accessing names
 
        void ApplyPose();
        void RestorePose();
@@ -72,6 +86,19 @@ public:
        
        Object* GetArmatureObject() {return m_objArma;}
 
+       // for constraint python API
+       void LoadConstraints(KX_BlenderSceneConverter* converter);
+       size_t GetConstraintNumber() const { return m_constraintNumber; }
+       BL_ArmatureConstraint* GetConstraint(const char* posechannel, const char* constraint);
+       BL_ArmatureConstraint* GetConstraint(const char* posechannelconstraint);
+       BL_ArmatureConstraint* GetConstraint(int index);
+       // for pose channel python API
+       void LoadChannels();
+       size_t GetChannelNumber() const { return m_constraintNumber; }
+       BL_ArmatureChannel* GetChannel(bPoseChannel* channel);
+       BL_ArmatureChannel* GetChannel(const char* channel);
+       BL_ArmatureChannel* GetChannel(int index);
+
        /// Retrieve the pose matrix for the specified bone.
        /// Returns true on success.
        bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix);
@@ -80,7 +107,17 @@ public:
        float GetBoneLength(Bone* bone) const;
 
        virtual int GetGameObjectType() { return OBJ_ARMATURE; }
+
+       // PYTHON
+       static PyObject* pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+       static PyObject* pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+       KX_PYMETHOD_DOC_NOARGS(BL_ArmatureObject, update);
+
 protected:
+       /* list element: BL_ArmatureConstraint. Use SG_DListHead to have automatic list replication */
+       SG_DListHead<BL_ArmatureConstraint>      m_controlledConstraints;
+       /* list element: BL_ArmatureChannel. Use SG_DList to avoid list replication */
+       SG_DList                        m_poseChannels;
        Object                          *m_objArma;
        struct bArmature        *m_armature;
        struct bPose            *m_pose;
@@ -88,11 +125,30 @@ protected:
        struct bPose            *m_framePose;
        struct Scene            *m_scene; // need for where_is_pose 
        double  m_lastframe;
+       double  m_timestep;             // delta since last pose evaluation.
        class BL_ActionActuator *m_activeAct;
        short   m_activePriority;
+       size_t  m_constraintNumber;
+       size_t  m_channelNumber;
+       // store the original armature object matrix
+       float m_obmat[4][4];
 
        double                  m_lastapplyframe;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+       void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ArmatureObject"); }
+       void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
 };
 
+/* Pose function specific to the game engine */
+void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight/*, short mode*/); /* was blend_poses */
+//void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
+void game_copy_pose(struct bPose **dst, struct bPose *src, int copy_con);
+void game_free_pose(struct bPose *pose);
+
+
 #endif