Blender  V2.59
BL_ArmatureConstraint.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BL_ArmatureConstraint.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_ARMATURECONSTRAINT
00035 #define __BL_ARMATURECONSTRAINT
00036 
00037 #include "DNA_constraint_types.h"
00038 #include "CTR_HashedPtr.h"
00039 #include "CTR_Map.h"
00040 #include "PyObjectPlus.h"
00041 
00042 class SCA_IObject;
00043 class KX_GameObject;
00044 class BL_ArmatureObject;
00045 struct bConstraint;
00046 struct bPoseChannel;
00047 struct Object;
00048 struct bPose;
00049 
00055 class BL_ArmatureConstraint     : public PyObjectPlus
00056 {
00057         Py_Header;
00058 
00059 private:
00060         struct bConstraint* m_constraint;
00061         struct bPoseChannel* m_posechannel;
00062         class BL_ArmatureObject* m_armature;
00063         char m_name[64];
00064         KX_GameObject*  m_target;
00065         KX_GameObject*  m_subtarget;
00066         struct Object*  m_blendtarget;
00067         struct Object*  m_blendsubtarget;
00068         float           m_blendmat[4][4];
00069         float           m_blendsubmat[4][4];
00070         struct bPose*   m_pose;
00071         struct bPose*   m_subpose;
00072 
00073 public:
00074         BL_ArmatureConstraint(class BL_ArmatureObject *armature, 
00075                                                 struct bPoseChannel *posechannel, 
00076                                                 struct bConstraint *constraint, 
00077                                                 KX_GameObject* target,
00078                                                 KX_GameObject* subtarget);
00079         virtual ~BL_ArmatureConstraint();
00080 
00081         BL_ArmatureConstraint* GetReplica() const;
00082         void ReParent(BL_ArmatureObject* armature);
00083         void Relink(CTR_Map<CTR_HashedPtr, void*> *map);
00084         bool UnlinkObject(SCA_IObject* clientobj);
00085 
00086         void UpdateTarget();
00087         void RestoreTarget();
00088 
00089         bool Match(const char* posechannel, const char* constraint);
00090         const char* GetName() { return m_name; }
00091 
00092         void SetConstraintFlag(int flag)
00093         {
00094                 if (m_constraint)
00095                         m_constraint->flag |= flag;
00096         }
00097         void ClrConstraintFlag(int flag)
00098         {
00099                 if (m_constraint)
00100                         m_constraint->flag &= ~flag;
00101         }
00102         void SetWeight(float weight)
00103         {
00104                 if (m_constraint && m_constraint->type == CONSTRAINT_TYPE_KINEMATIC && m_constraint->data) {
00105                         bKinematicConstraint* con = (bKinematicConstraint*)m_constraint->data;
00106                         con->weight = weight;
00107                 }
00108         }
00109         void SetTarget(KX_GameObject* target);
00110         void SetSubtarget(KX_GameObject* subtarget);
00111 
00112 #ifdef WITH_PYTHON
00113 
00114         // Python access
00115         virtual PyObject* py_repr(void);
00116 
00117         static PyObject* py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
00118         static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
00119 #endif // WITH_PYTHON
00120 };
00121 
00122 #endif //__BL_ARMATURECONSTRAINT
00123