correct fsf address
[blender.git] / source / gameengine / Converter / BL_ArmatureConstraint.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29 #ifndef __BL_ARMATURECONSTRAINT
30 #define __BL_ARMATURECONSTRAINT
31
32 #include "DNA_constraint_types.h"
33 #include "GEN_HashedPtr.h"
34 #include "GEN_Map.h"
35 #include "PyObjectPlus.h"
36
37 class SCA_IObject;
38 class KX_GameObject;
39 class BL_ArmatureObject;
40 struct bConstraint;
41 struct bPoseChannel;
42 struct Object;
43 struct bPose;
44
45 /**
46  * SG_DList : element of controlled constraint list 
47  *            head = BL_ArmatureObject::m_controlledConstraints
48  * SG_QList : not used
49  */
50 class BL_ArmatureConstraint     : public PyObjectPlus
51 {
52         Py_Header;
53
54 private:
55         struct bConstraint* m_constraint;
56         struct bPoseChannel* m_posechannel;
57         class BL_ArmatureObject* m_armature;
58         char m_name[64];
59         KX_GameObject*  m_target;
60         KX_GameObject*  m_subtarget;
61         struct Object*  m_blendtarget;
62         struct Object*  m_blendsubtarget;
63         float           m_blendmat[4][4];
64         float           m_blendsubmat[4][4];
65         struct bPose*   m_pose;
66         struct bPose*   m_subpose;
67
68 public:
69         BL_ArmatureConstraint(class BL_ArmatureObject *armature, 
70                                                 struct bPoseChannel *posechannel, 
71                                                 struct bConstraint *constraint, 
72                                                 KX_GameObject* target,
73                                                 KX_GameObject* subtarget);
74         virtual ~BL_ArmatureConstraint();
75
76         BL_ArmatureConstraint* GetReplica() const;
77         void ReParent(BL_ArmatureObject* armature);
78         void Relink(GEN_Map<GEN_HashedPtr, void*> *map);
79         bool UnlinkObject(SCA_IObject* clientobj);
80
81         void UpdateTarget();
82         void RestoreTarget();
83
84         bool Match(const char* posechannel, const char* constraint);
85         const char* GetName() { return m_name; }
86
87         void SetConstraintFlag(int flag)
88         {
89                 if (m_constraint)
90                         m_constraint->flag |= flag;
91         }
92         void ClrConstraintFlag(int flag)
93         {
94                 if (m_constraint)
95                         m_constraint->flag &= ~flag;
96         }
97         void SetWeight(float weight)
98         {
99                 if (m_constraint && m_constraint->type == CONSTRAINT_TYPE_KINEMATIC && m_constraint->data) {
100                         bKinematicConstraint* con = (bKinematicConstraint*)m_constraint->data;
101                         con->weight = weight;
102                 }
103         }
104         void SetTarget(KX_GameObject* target);
105         void SetSubtarget(KX_GameObject* subtarget);
106
107 #ifndef DISABLE_PYTHON
108
109         // Python access
110         virtual PyObject* py_repr(void);
111
112         static PyObject* py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
113         static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
114 #endif // DISABLE_PYTHON
115 };
116
117 #endif //__BL_ARMATURECONSTRAINT
118