Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00032 #ifndef __BL_ARMATURECONSTRAINT 00033 #define __BL_ARMATURECONSTRAINT 00034 00035 #include "DNA_constraint_types.h" 00036 #include "CTR_HashedPtr.h" 00037 #include "CTR_Map.h" 00038 #include "PyObjectPlus.h" 00039 00040 class SCA_IObject; 00041 class KX_GameObject; 00042 class BL_ArmatureObject; 00043 struct bConstraint; 00044 struct bPoseChannel; 00045 struct Object; 00046 struct bPose; 00047 00053 class BL_ArmatureConstraint : public PyObjectPlus 00054 { 00055 Py_Header 00056 00057 private: 00058 struct bConstraint* m_constraint; 00059 struct bPoseChannel* m_posechannel; 00060 class BL_ArmatureObject* m_armature; 00061 char m_name[64]; 00062 KX_GameObject* m_target; 00063 KX_GameObject* m_subtarget; 00064 struct Object* m_blendtarget; 00065 struct Object* m_blendsubtarget; 00066 float m_blendmat[4][4]; 00067 float m_blendsubmat[4][4]; 00068 struct bPose* m_pose; 00069 struct bPose* m_subpose; 00070 00071 public: 00072 BL_ArmatureConstraint(class BL_ArmatureObject *armature, 00073 struct bPoseChannel *posechannel, 00074 struct bConstraint *constraint, 00075 KX_GameObject* target, 00076 KX_GameObject* subtarget); 00077 virtual ~BL_ArmatureConstraint(); 00078 00079 BL_ArmatureConstraint* GetReplica() const; 00080 void ReParent(BL_ArmatureObject* armature); 00081 void Relink(CTR_Map<CTR_HashedPtr, void*> *map); 00082 bool UnlinkObject(SCA_IObject* clientobj); 00083 00084 void UpdateTarget(); 00085 void RestoreTarget(); 00086 00087 bool Match(const char* posechannel, const char* constraint); 00088 const char* GetName() { return m_name; } 00089 00090 void SetConstraintFlag(int flag) 00091 { 00092 if (m_constraint) 00093 m_constraint->flag |= flag; 00094 } 00095 void ClrConstraintFlag(int flag) 00096 { 00097 if (m_constraint) 00098 m_constraint->flag &= ~flag; 00099 } 00100 void SetWeight(float weight) 00101 { 00102 if (m_constraint && m_constraint->type == CONSTRAINT_TYPE_KINEMATIC && m_constraint->data) { 00103 bKinematicConstraint* con = (bKinematicConstraint*)m_constraint->data; 00104 con->weight = weight; 00105 } 00106 } 00107 void SetTarget(KX_GameObject* target); 00108 void SetSubtarget(KX_GameObject* subtarget); 00109 00110 #ifdef WITH_PYTHON 00111 00112 // Python access 00113 virtual PyObject* py_repr(void); 00114 00115 static PyObject* py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00116 static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00117 #endif // WITH_PYTHON 00118 }; 00119 00120 #endif //__BL_ARMATURECONSTRAINT 00121