2 * KX_ConstraintActuator.h
6 * ***** BEGIN GPL LICENSE BLOCK *****
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * The Original Code is: all of this file.
27 * Contributor(s): none yet.
29 * ***** END GPL LICENSE BLOCK *****
32 #ifndef __KX_CONSTRAINTACTUATOR
33 #define __KX_CONSTRAINTACTUATOR
35 #include "SCA_IActuator.h"
36 #include "MT_Scalar.h"
37 #include "MT_Vector3.h"
38 #include "KX_ClientObjectInfo.h"
43 class KX_ConstraintActuator : public SCA_IActuator
54 // sinus of minimum angle
56 // sinus of maximum angle
58 // reference direction
59 float m_refDirection[3];
60 MT_Vector3 m_refDirVector; // same as m_refDirection
61 // locrotxyz choice (pick one): only one choice allowed at a time!
63 // active time of actuator
69 STR_String m_property;
71 KX_GameObject* m_hitObject;
74 * Clamp <var> to <min>, <max>. Borders are included (in as far as
75 * float comparisons are good for equality...).
77 void Clamp(MT_Scalar &var, float min, float max);
82 enum KX_CONSTRAINTTYPE {
83 KX_ACT_CONSTRAINT_NODEF = 0,
84 KX_ACT_CONSTRAINT_LOCX,
85 KX_ACT_CONSTRAINT_LOCY,
86 KX_ACT_CONSTRAINT_LOCZ,
87 KX_ACT_CONSTRAINT_ROTX,
88 KX_ACT_CONSTRAINT_ROTY,
89 KX_ACT_CONSTRAINT_ROTZ,
90 KX_ACT_CONSTRAINT_DIRPX,
91 KX_ACT_CONSTRAINT_DIRPY,
92 KX_ACT_CONSTRAINT_DIRPZ,
93 KX_ACT_CONSTRAINT_DIRNX,
94 KX_ACT_CONSTRAINT_DIRNY,
95 KX_ACT_CONSTRAINT_DIRNZ,
96 KX_ACT_CONSTRAINT_ORIX,
97 KX_ACT_CONSTRAINT_ORIY,
98 KX_ACT_CONSTRAINT_ORIZ,
99 KX_ACT_CONSTRAINT_FHPX,
100 KX_ACT_CONSTRAINT_FHPY,
101 KX_ACT_CONSTRAINT_FHPZ,
102 KX_ACT_CONSTRAINT_FHNX,
103 KX_ACT_CONSTRAINT_FHNY,
104 KX_ACT_CONSTRAINT_FHNZ,
105 KX_ACT_CONSTRAINT_MAX
107 // match ACT_CONST_... values from BIF_interface.h
108 enum KX_CONSTRAINTOPT {
109 KX_ACT_CONSTRAINT_NORMAL = 64,
110 KX_ACT_CONSTRAINT_MATERIAL = 128,
111 KX_ACT_CONSTRAINT_PERMANENT = 256,
112 KX_ACT_CONSTRAINT_DISTANCE = 512,
113 KX_ACT_CONSTRAINT_LOCAL = 1024,
114 KX_ACT_CONSTRAINT_DOROTFH = 2048
116 bool IsValidMode(KX_CONSTRAINTTYPE m);
117 bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
118 bool NeedRayCast(KX_ClientObjectInfo*);
120 KX_ConstraintActuator(SCA_IObject* gameobj,
130 PyTypeObject* T=&Type);
131 virtual ~KX_ConstraintActuator();
132 virtual CValue* GetReplica() {
133 KX_ConstraintActuator* replica = new KX_ConstraintActuator(*this);
134 replica->ProcessReplica();
135 // this will copy properties and so on...
136 CValue::AddDataToReplica(replica);
140 virtual bool Update(double curtime, bool frame);
142 /* --------------------------------------------------------------------- */
143 /* Python interface ---------------------------------------------------- */
144 /* --------------------------------------------------------------------- */
146 virtual PyObject* py_getattro(PyObject *attr);
147 virtual int py_setattro(PyObject *attr, PyObject* value);
149 static int pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
150 static int pyattr_check_min(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
152 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDamp);
153 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDamp);
154 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetRotDamp);
155 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetRotDamp);
156 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDirection);
157 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDirection);
158 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetOption);
159 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetOption);
160 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetTime);
161 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetTime);
162 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetProperty);
163 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetProperty);
164 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMin);
165 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMin);
166 static const char SetDistance_doc[];
167 static const char GetDistance_doc[];
168 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMax);
169 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMax);
170 static const char SetRayLength_doc[];
171 static const char GetRayLength_doc[];
172 KX_PYMETHOD_DOC(KX_ConstraintActuator,SetLimit);
173 KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetLimit);
176 #endif //__KX_CONSTRAINTACTUATOR