| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * $Id$ | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. The Blender | 
					
						
							|  |  |  |  * Foundation also sells licenses for use in proprietary software under | 
					
						
							|  |  |  |  * the Blender License.  See http://www.blender.org/BL/ for information
 | 
					
						
							|  |  |  |  * about this. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): none yet. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef TRANSFORM_H
 | 
					
						
							|  |  |  | #define TRANSFORM_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "transform_numinput.h"
 | 
					
						
							| 
									
										
										
										
											2005-02-20 01:25:10 +00:00
										 |  |  | #include "BIF_transform.h"
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************** Types ***************************** */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-19 16:37:48 +00:00
										 |  |  | struct TransInfo; | 
					
						
							|  |  |  | struct TransData; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | typedef struct TransCon { | 
					
						
							|  |  |  |     char  text[50];      /* Description of the Constraint for header_print                            */ | 
					
						
							|  |  |  |     float mtx[3][3];     /* Matrix of the Constraint space                                            */ | 
					
						
							|  |  |  |     float imtx[3][3];    /* Inverse Matrix of the Constraint space                                    */ | 
					
						
							| 
									
										
										
										
											2005-03-04 00:07:16 +00:00
										 |  |  |     float pmtx[3][3];    /* Projection Constraint Matrix (same as imtx with some axis == 0)           */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     float center[3];     /* transformation centre to define where to draw the view widget             
 | 
					
						
							|  |  |  |                             ALWAYS in global space. Unlike the transformation center                  */ | 
					
						
							|  |  |  |     int   mode;          /* Mode flags of the Constraint                                              */ | 
					
						
							|  |  |  |     void  (*applyVec)(struct TransInfo *, struct TransData *, float *, float *); | 
					
						
							|  |  |  |                          /* Apply function pointer for linear vectorial transformation                */ | 
					
						
							|  |  |  |                          /* The last two parameters are pointers to the in/out vectors                */ | 
					
						
							| 
									
										
										
										
											2005-03-04 00:07:16 +00:00
										 |  |  |     void  (*applySize)(struct TransInfo *, struct TransData *, float [3][3]); | 
					
						
							|  |  |  |                          /* Apply function pointer for rotation transformation (prototype will change */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     void  (*applyRot)(struct TransInfo *, struct TransData *, float [3]); | 
					
						
							|  |  |  |                          /* Apply function pointer for rotation transformation (prototype will change */ | 
					
						
							|  |  |  | } TransCon; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-25 11:35:24 +00:00
										 |  |  | typedef struct TransDataIpokey { | 
					
						
							|  |  |  | 	int flag;					/* which keys */ | 
					
						
							|  |  |  | 	float *locx, *locy, *locz;	/* channel pointers */ | 
					
						
							|  |  |  | 	float *rotx, *roty, *rotz; | 
					
						
							|  |  |  | 	float *quatx, *quaty, *quatz, *quatw; | 
					
						
							|  |  |  | 	float *sizex, *sizey, *sizez; | 
					
						
							|  |  |  | 	float oldloc[9];			/* storage old values */ | 
					
						
							|  |  |  | 	float oldrot[9]; | 
					
						
							|  |  |  | 	float oldsize[9]; | 
					
						
							|  |  |  | 	float oldquat[12]; | 
					
						
							|  |  |  | } TransDataIpokey; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  | typedef struct TransDataExtension { | 
					
						
							| 
									
										
										
										
											2005-02-25 11:35:24 +00:00
										 |  |  | 	float drot[3];		 /* Initial object drot */ | 
					
						
							|  |  |  | 	float dsize[3];		 /* Initial object dsize */ | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  |     float *rot;          /* Rotation of the data to transform (Faculative)                                 */ | 
					
						
							|  |  |  |     float  irot[3];      /* Initial rotation                                                               */ | 
					
						
							|  |  |  |     float *quat;         /* Rotation quaternion of the data to transform (Faculative)                      */ | 
					
						
							|  |  |  |     float  iquat[4];	 /* Initial rotation quaternion                                                    */ | 
					
						
							|  |  |  |     float *size;         /* Size of the data to transform (Faculative)                                     */ | 
					
						
							|  |  |  |     float  isize[3];	 /* Initial size                                                                   */ | 
					
						
							| 
									
										
										
										
											2005-02-25 11:35:24 +00:00
										 |  |  | 	float  obmat[3][3];	 /* Object matrix */   | 
					
						
							| 
									
										
										
										
											2005-02-23 14:19:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-25 11:35:24 +00:00
										 |  |  | 	void *bone;			/* ARGH! old transform demanded it, added for now (ton) */ | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  | } TransDataExtension; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | typedef struct TransData { | 
					
						
							|  |  |  | 	float  dist;         /* Distance to the nearest element (for Proportionnal Editing)                    */ | 
					
						
							|  |  |  | 	float  factor;       /* Factor of the transformation (for Proportionnal Editing)                       */ | 
					
						
							|  |  |  |     float *loc;          /* Location of the data to transform                                              */ | 
					
						
							|  |  |  |     float  iloc[3];      /* Initial location                                                               */ | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  |     float  center[3]; | 
					
						
							|  |  |  |     float  mtx[3][3];    /* Transformation matrix from data space to global space                          */ | 
					
						
							|  |  |  |     float  smtx[3][3];   /* Transformation matrix from global space to data space                          */ | 
					
						
							|  |  |  | 	struct Object *ob; | 
					
						
							| 
									
										
										
										
											2005-02-25 11:35:24 +00:00
										 |  |  | 	TransDataExtension *ext;	/* for objects, poses. 1 single malloc per TransInfo! */ | 
					
						
							|  |  |  | 	TransDataIpokey *tdi;		/* for objects, ipo keys. per transdata a malloc */ | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  |     int    flag;         /* Various flags */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | } TransData; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct TransInfo { | 
					
						
							|  |  |  |     int         mode;           /* current mode                         */ | 
					
						
							|  |  |  |     int       (*transform)(struct TransInfo *, short *); | 
					
						
							|  |  |  |                                 /* transform function pointer           */ | 
					
						
							|  |  |  |     char        redraw;         /* redraw flag                          */ | 
					
						
							|  |  |  |     int	        flags;          /* generic flags for special behaviors  */ | 
					
						
							|  |  |  |     int         total;          /* total number of transformed data     */ | 
					
						
							|  |  |  | 	float		propsize;		/* proportional circle radius           */ | 
					
						
							|  |  |  | 	char		proptext[20];	/* proportional falloff text			*/ | 
					
						
							|  |  |  |     float       center[3];      /* center of transformation             */ | 
					
						
							|  |  |  |     short       center2d[2];    /* center in screen coordinates         */ | 
					
						
							|  |  |  |     short       imval[2];       /* initial mouse position               */ | 
					
						
							| 
									
										
										
										
											2005-03-04 00:07:16 +00:00
										 |  |  | 	short       idx_max; | 
					
						
							|  |  |  | 	float		snap[3];		/* Snapping Gears						*/ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     TransData  *data;           /* transformed data (array)             */ | 
					
						
							|  |  |  |     TransCon    con;            /* transformed constraint               */ | 
					
						
							|  |  |  |     NumInput    num;            /* numerical input                      */ | 
					
						
							|  |  |  |     float       val;            /* init value for some transformations  */ | 
					
						
							|  |  |  |     float       fac;            /* factor for distance based transform  */ | 
					
						
							|  |  |  | } TransInfo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ******************** Macros & Prototypes *********************** */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* MODE AND NUMINPUT FLAGS */ | 
					
						
							|  |  |  | #define NOCONSTRAINT	1
 | 
					
						
							|  |  |  | #define NULLONE			2
 | 
					
						
							|  |  |  | #define NONEGATIVE		4
 | 
					
						
							|  |  |  | #define	NOZERO			8
 | 
					
						
							|  |  |  | #define NOFRACTION		16
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-22 16:50:04 +00:00
										 |  |  | /* transinfo->mode */ | 
					
						
							| 
									
										
										
										
											2005-02-20 01:25:10 +00:00
										 |  |  | #define TFM_REPEAT			0
 | 
					
						
							|  |  |  | #define TFM_TRANSLATION		1
 | 
					
						
							|  |  |  | #define TFM_ROTATION		2
 | 
					
						
							|  |  |  | #define TFM_RESIZE			3
 | 
					
						
							|  |  |  | #define TFM_TOSPHERE		4
 | 
					
						
							|  |  |  | #define TFM_SHEAR			5
 | 
					
						
							|  |  |  | #define TFM_LAMP_ENERGY		6
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-01 19:22:29 +00:00
										 |  |  | #define CON_APPLY		1
 | 
					
						
							|  |  |  | #define CON_AXIS0		2
 | 
					
						
							|  |  |  | #define CON_AXIS1		4
 | 
					
						
							|  |  |  | #define CON_AXIS2		8
 | 
					
						
							|  |  |  | #define CON_SELECT		16
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define PROP_SHARP		0
 | 
					
						
							|  |  |  | #define PROP_SMOOTH		1
 | 
					
						
							|  |  |  | #define PROP_ROOT		2
 | 
					
						
							|  |  |  | #define PROP_LIN		3
 | 
					
						
							|  |  |  | #define PROP_CONST		4
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-22 16:50:04 +00:00
										 |  |  | /* transdata->flag */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | #define TD_SELECTED		1
 | 
					
						
							|  |  |  | #define	TD_NOACTION		2
 | 
					
						
							| 
									
										
										
										
											2005-02-22 16:50:04 +00:00
										 |  |  | #define	TD_USEQUAT		4
 | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  | #define TD_OBJECT		8
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Transform(int mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initWrap(TransInfo *t); | 
					
						
							|  |  |  | int Wrap(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initShear(TransInfo *t); | 
					
						
							|  |  |  | int Shear(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initResize(TransInfo *t); | 
					
						
							|  |  |  | int Resize(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initTranslation(TransInfo *t); | 
					
						
							|  |  |  | int Translation(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initToSphere(TransInfo *t); | 
					
						
							|  |  |  | int ToSphere(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initRotation(TransInfo *t); | 
					
						
							|  |  |  | int Rotation(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 |