|
Blender
V2.59
|
00001 /* 00002 * $Id: BL_ArmatureObject.h 36523 2011-05-06 20:18:42Z blendix $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef BL_ARMATUREOBJECT 00035 #define BL_ARMATUREOBJECT 00036 00037 #include "KX_GameObject.h" 00038 #include "BL_ArmatureConstraint.h" 00039 #include "BL_ArmatureChannel.h" 00040 00041 #include "SG_IObject.h" 00042 #include <vector> 00043 #include <algorithm> 00044 00045 struct bArmature; 00046 struct Bone; 00047 struct bConstraint; 00048 class BL_ActionActuator; 00049 class BL_ArmatureActuator; 00050 class MT_Matrix4x4; 00051 struct Object; 00052 class KX_BlenderSceneConverter; 00053 00054 class BL_ArmatureObject : public KX_GameObject 00055 { 00056 Py_Header; 00057 public: 00058 00059 double GetLastFrame (); 00060 short GetActivePriority(); 00061 virtual void ProcessReplica(); 00062 virtual void ReParentLogic(); 00063 virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map); 00064 virtual bool UnlinkObject(SCA_IObject* clientobj); 00065 00066 class BL_ActionActuator * GetActiveAction(); 00067 00068 BL_ArmatureObject( 00069 void* sgReplicationInfo, 00070 SG_Callbacks callbacks, 00071 Object *armature, 00072 Scene *scene 00073 ); 00074 virtual ~BL_ArmatureObject(); 00075 00076 virtual CValue* GetReplica(); 00077 void GetMRDPose(struct bPose **pose); 00078 void GetPose(struct bPose **pose); 00079 void SetPose (struct bPose *pose); 00080 struct bPose *GetOrigPose() {return m_pose;} // never edit this, only for accessing names 00081 00082 void ApplyPose(); 00083 void RestorePose(); 00084 00085 bool SetActiveAction(class BL_ActionActuator *act, short priority, double curtime); 00086 00087 struct bArmature * GetArmature() { return m_armature; } 00088 const struct bArmature * GetArmature() const { return m_armature; } 00089 const struct Scene * GetScene() const { return m_scene; } 00090 00091 Object* GetArmatureObject() {return m_objArma;} 00092 00093 // for constraint python API 00094 void LoadConstraints(KX_BlenderSceneConverter* converter); 00095 size_t GetConstraintNumber() const { return m_constraintNumber; } 00096 BL_ArmatureConstraint* GetConstraint(const char* posechannel, const char* constraint); 00097 BL_ArmatureConstraint* GetConstraint(const char* posechannelconstraint); 00098 BL_ArmatureConstraint* GetConstraint(int index); 00099 // for pose channel python API 00100 void LoadChannels(); 00101 size_t GetChannelNumber() const { return m_channelNumber; } 00102 BL_ArmatureChannel* GetChannel(bPoseChannel* channel); 00103 BL_ArmatureChannel* GetChannel(const char* channel); 00104 BL_ArmatureChannel* GetChannel(int index); 00105 00108 bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix); 00109 00111 float GetBoneLength(Bone* bone) const; 00112 00113 virtual int GetGameObjectType() { return OBJ_ARMATURE; } 00114 00115 #ifdef WITH_PYTHON 00116 00117 // PYTHON 00118 static PyObject* pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00119 static PyObject* pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00120 KX_PYMETHOD_DOC_NOARGS(BL_ArmatureObject, update); 00121 00122 #endif // WITH_PYTHON 00123 00124 protected: 00125 /* list element: BL_ArmatureConstraint. Use SG_DListHead to have automatic list replication */ 00126 SG_DListHead<BL_ArmatureConstraint> m_controlledConstraints; 00127 /* list element: BL_ArmatureChannel. Use SG_DList to avoid list replication */ 00128 SG_DList m_poseChannels; 00129 Object *m_objArma; 00130 struct bArmature *m_armature; 00131 struct bPose *m_pose; 00132 struct bPose *m_armpose; 00133 struct bPose *m_framePose; 00134 struct Scene *m_scene; // need for where_is_pose 00135 double m_lastframe; 00136 double m_timestep; // delta since last pose evaluation. 00137 class BL_ActionActuator *m_activeAct; 00138 short m_activePriority; 00139 size_t m_constraintNumber; 00140 size_t m_channelNumber; 00141 // store the original armature object matrix 00142 float m_obmat[4][4]; 00143 00144 double m_lastapplyframe; 00145 }; 00146 00147 /* Pose function specific to the game engine */ 00148 void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight/*, short mode*/); /* was blend_poses */ 00149 //void extract_pose_from_pose(struct bPose *pose, const struct bPose *src); 00150 void game_copy_pose(struct bPose **dst, struct bPose *src, int copy_con); 00151 void game_free_pose(struct bPose *pose); 00152 00153 00154 #endif 00155