4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
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. The Blender
10 * Foundation also sells licenses for use in proprietary software under
11 * the Blender License. See http://www.blender.org/BL/ for information
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): 2007, Joshua Leung, major recode
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
34 #ifndef DNA_CONSTRAINT_TYPES_H
35 #define DNA_CONSTRAINT_TYPES_H
38 #include "DNA_ipo_types.h"
39 #include "DNA_object_types.h"
47 /* channels reside in Object or Action (ListBase) constraintChannels */
48 typedef struct bConstraintChannel {
49 struct bConstraintChannel *next, *prev;
56 typedef struct bConstraint {
57 struct bConstraint *next, *prev;
58 void *data; /* Constraint data (a valid constraint type) */
59 short type; /* Constraint type */
60 short flag; /* Flag - General Settings */
62 char ownspace; /* Space that owner should be evaluated in */
63 char tarspace; /* Space that target should be evaluated in */
65 char name[30]; /* Constraint name */
67 float enforce; /* Amount of influence exherted by constraint (0.0-1.0) */
71 /* Python Script Constraint */
72 typedef struct bPythonConstraint {
73 Object *tar; /* object to use as target (if required) */
74 char subtarget[32]; /* bone to use as subtarget (if required) */
76 struct Text *text; /* text-buffer (containing script) to execute */
77 IDProperty *prop; /* 'id-properties' used to store custom properties for constraint */
79 int flag; /* general settings/state indicators accessed by bitmapping */
83 /* Single-target subobject constraints --------------------- */
84 /* Inverse-Kinematics (IK) constraint */
85 typedef struct bKinematicConstraint {
87 short iterations; /* Maximum number of iterations to try */
88 short flag; /* Like CONSTRAINT_IK_TIP */
89 int rootbone; /* index to rootbone, if zero go all the way to mother bone */
90 char subtarget[32]; /* String to specify sub-object target */
92 float weight; /* Weight of goal in IK tree */
93 float orientweight; /* Amount of rotation a target applies on chain */
94 float grabtarget[3]; /* for target-less IK */
96 } bKinematicConstraint;
98 /* Track To Constraint */
99 typedef struct bTrackToConstraint {
101 int reserved1; /* I'll be using reserved1 and reserved2 as Track and Up flags, not sure if that's what they were intented for anyway. Not sure either if it would create backward incompatibility if I were to rename them. - theeth*/
106 } bTrackToConstraint;
108 /* Copy Rotation Constraint */
109 typedef struct bRotateLikeConstraint {
114 } bRotateLikeConstraint;
116 /* Copy Location Constraint */
117 typedef struct bLocateLikeConstraint {
122 } bLocateLikeConstraint;
124 /* Floor Constraint */
125 typedef struct bMinMaxConstraint {
130 short sticky, stuck, pad1, pad2; /* for backward compatability */
135 /* Copy Scale Constraint */
136 typedef struct bSizeLikeConstraint {
141 } bSizeLikeConstraint;
143 /* Action Constraint */
144 typedef struct bActionConstraint {
147 short local; /* was used in versions prior to the Constraints recode */
157 /* Locked Axis Tracking constraint */
158 typedef struct bLockTrackConstraint {
163 } bLockTrackConstraint;
165 /* Follow Path constraints */
166 typedef struct bFollowPathConstraint {
167 Object *tar; /* Must be path object */
168 float offset; /* Offset in time on the path (in frame) */
172 } bFollowPathConstraint;
174 /* Stretch to constraint */
175 typedef struct bStretchToConstraint {
182 } bStretchToConstraint;
184 /* Rigid Body constraint */
185 typedef struct bRigidBodyJointConstraint {
202 } bRigidBodyJointConstraint;
204 /* Clamp-To Constraint */
205 typedef struct bClampToConstraint {
206 Object *tar; /* 'target' must be a curve */
207 int flag; /* which axis/plane to compare owner's location on */
208 int flag2; /* for legacy reasons, this is flag2. used for any extra settings */
209 } bClampToConstraint;
211 /* Child Of Constraint */
212 typedef struct bChildOfConstraint {
213 Object *tar; /* object which will act as parent (or target comes from) */
214 int flag; /* settings */
216 float invmat[4][4]; /* parent-inverse matrix to use */
217 char subtarget[32]; /* string to specify a subobject target */
218 } bChildOfConstraint;
220 /* Generic Transform->Transform Constraint */
221 typedef struct bTransformConstraint {
222 Object *tar; /* target (i.e. 'driver' object/bone) */
225 short from, to; /* can be loc(0) , rot(1), or size(2) */
226 char map[3]; /* defines which target-axis deform is copied by each owner-axis */
227 char expo; /* extrapolate motion? if 0, confine to ranges */
229 float from_min[3]; /* from_min/max defines range of target transform */
230 float from_max[3]; /* to map on to to_min/max range. */
232 float to_min[3]; /* range of motion on owner caused by target */
234 } bTransformConstraint;
236 /* transform limiting constraints - zero target ---------------------------- */
237 /* Limit Location Constraint */
238 typedef struct bLocLimitConstraint {
244 } bLocLimitConstraint;
246 /* Limit Rotation Constraint */
247 typedef struct bRotLimitConstraint {
253 } bRotLimitConstraint;
255 /* Limit Scaling Constraint */
256 typedef struct bSizeLimitConstraint {
262 } bSizeLimitConstraint;
264 /* bConstraint.type */
265 #define CONSTRAINT_TYPE_NULL 0
266 #define CONSTRAINT_TYPE_CHILDOF 1 /* Unimplemented non longer :) - during constraints recode, Aligorith */
267 #define CONSTRAINT_TYPE_TRACKTO 2
268 #define CONSTRAINT_TYPE_KINEMATIC 3
269 #define CONSTRAINT_TYPE_FOLLOWPATH 4
270 #define CONSTRAINT_TYPE_ROTLIMIT 5 /* Unimplemented no longer :) - Aligorith */
271 #define CONSTRAINT_TYPE_LOCLIMIT 6 /* Unimplemented no longer :) - Aligorith */
272 #define CONSTRAINT_TYPE_SIZELIMIT 7 /* Unimplemented no longer :) - Aligorith */
273 #define CONSTRAINT_TYPE_ROTLIKE 8
274 #define CONSTRAINT_TYPE_LOCLIKE 9
275 #define CONSTRAINT_TYPE_SIZELIKE 10
276 #define CONSTRAINT_TYPE_PYTHON 11 /* Unimplemented no longer :) - Aligorith. Scripts */
277 #define CONSTRAINT_TYPE_ACTION 12
278 #define CONSTRAINT_TYPE_LOCKTRACK 13 /* New Tracking constraint that locks an axis in place - theeth */
279 #define CONSTRAINT_TYPE_DISTANCELIMIT 14 /* was never properly coded - removed! */
280 #define CONSTRAINT_TYPE_STRETCHTO 15 /* claiming this to be mine :) is in tuhopuu bjornmose */
281 #define CONSTRAINT_TYPE_MINMAX 16 /* floor constraint */
282 #define CONSTRAINT_TYPE_RIGIDBODYJOINT 17 /* rigidbody constraint */
283 #define CONSTRAINT_TYPE_CLAMPTO 18 /* clampto constraint */
284 #define CONSTRAINT_TYPE_TRANSFORM 19 /* transformation constraint */
286 /* bConstraint->flag */
288 #define CONSTRAINT_EXPAND 0x01
289 /* pre-check for illegal object name or bone name */
290 #define CONSTRAINT_DISABLE 0x04
291 /* flags 0x2 and 0x8 were used in past, skip this */
292 /* to indicate which Ipo should be shown, maybe for 3d access later too */
293 #define CONSTRAINT_ACTIVE 0x10
294 /* flag 0x20 was used to indicate that a constraint was evaluated using a 'local' hack for posebones only */
295 /* to indicate that the owner's space should only be changed into ownspace, but not out of it */
296 #define CONSTRAINT_SPACEONCE 0x40
298 /* bConstraint->ownspace/tarspace */
299 /* default for all - worldspace */
300 #define CONSTRAINT_SPACE_WORLD 0
301 /* for objects (relative to parent/without parent influence), for bones (along normals of bone, without parent/restposi) */
302 #define CONSTRAINT_SPACE_LOCAL 1
303 /* for posechannels - pose space */
304 #define CONSTRAINT_SPACE_POSE 2
305 /* for posechannels - local with parent */
306 #define CONSTRAINT_SPACE_PARLOCAL 3
308 /* bConstraintChannel.flag */
309 #define CONSTRAINT_CHANNEL_SELECT 0x01
310 #define CONSTRAINT_CHANNEL_PROTECTED 0x02
313 * The flags for ROTLIKE, LOCLIKE and SIZELIKE should be kept identical
314 * (that is, same effect, different name). It simplifies the Python API access a lot.
317 /* bRotateLikeConstraint.flag */
318 #define ROTLIKE_X 0x01
319 #define ROTLIKE_Y 0x02
320 #define ROTLIKE_Z 0x04
321 #define ROTLIKE_X_INVERT 0x10
322 #define ROTLIKE_Y_INVERT 0x20
323 #define ROTLIKE_Z_INVERT 0x40
324 #define ROTLIKE_OFFSET 0x80
326 /* bLocateLikeConstraint.flag */
327 #define LOCLIKE_X 0x01
328 #define LOCLIKE_Y 0x02
329 #define LOCLIKE_Z 0x04
330 #define LOCLIKE_TIP 0x08
331 #define LOCLIKE_X_INVERT 0x10
332 #define LOCLIKE_Y_INVERT 0x20
333 #define LOCLIKE_Z_INVERT 0x40
334 #define LOCLIKE_OFFSET 0x80
336 /* bSizeLikeConstraint.flag */
337 #define SIZELIKE_X 0x01
338 #define SIZELIKE_Y 0x02
339 #define SIZELIKE_Z 0x04
340 #define SIZELIKE_OFFSET 0x80
354 #define TRACK_nX 0x03
355 #define TRACK_nY 0x04
356 #define TRACK_nZ 0x05
358 /* bTrackToConstraint->flags */
359 #define TARGET_Z_UP 0x01
361 #define VOLUME_XZ 0x00
362 #define VOLUME_X 0x01
363 #define VOLUME_Z 0x02
364 #define NO_VOLUME 0x03
370 /* Clamp-To Constraint ->flag */
371 #define CLAMPTO_AUTO 0
376 /* ClampTo Constraint ->flag2 */
377 #define CLAMPTO_CYCLIC 1
379 /* bKinematicConstraint->flag */
380 #define CONSTRAINT_IK_TIP 1
381 #define CONSTRAINT_IK_ROT 2
382 #define CONSTRAINT_IK_AUTO 4
383 #define CONSTRAINT_IK_TEMP 8
384 #define CONSTRAINT_IK_STRETCH 16
385 #define CONSTRAINT_IK_POS 32
387 /* MinMax (floor) flags */
388 #define MINMAX_STICKY 0x01
389 #define MINMAX_STUCK 0x02
390 #define MINMAX_USEROT 0x04
392 /* transform limiting constraints -> flag */
393 #define LIMIT_XMIN 0x01
394 #define LIMIT_XMAX 0x02
395 #define LIMIT_YMIN 0x04
396 #define LIMIT_YMAX 0x08
397 #define LIMIT_ZMIN 0x10
398 #define LIMIT_ZMAX 0x20
400 #define LIMIT_XROT 0x01
401 #define LIMIT_YROT 0x02
402 #define LIMIT_ZROT 0x04
404 /* not used anymore - for older Limit Location constraints only */
405 #define LIMIT_NOPARENT 0x01
407 /* python constraint -> flag */
408 #define PYCON_USETARGETS 0x01
409 #define PYCON_SCRIPTERROR 0x02
411 /* ChildOf Constraint -> flag */
412 #define CHILDOF_LOCX 0x001
413 #define CHILDOF_LOCY 0x002
414 #define CHILDOF_LOCZ 0x004
415 #define CHILDOF_ROTX 0x008
416 #define CHILDOF_ROTY 0x010
417 #define CHILDOF_ROTZ 0x020
418 #define CHILDOF_SIZEX 0x040
419 #define CHILDOF_SIZEY 0x080
420 #define CHILDOF_SIZEZ 0x100
422 /* Rigid-Body Constraint */
423 #define CONSTRAINT_DRAW_PIVOT 0x40
425 /* important: these defines need to match up with PHY_DynamicTypes headerfile */
426 #define CONSTRAINT_RB_BALL 1
427 #define CONSTRAINT_RB_HINGE 2
428 #define CONSTRAINT_RB_CONETWIST 4
429 #define CONSTRAINT_RB_VEHICLE 11
430 #define CONSTRAINT_RB_GENERIC6DOF 12