| 
									
										
										
										
											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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-04-10 18:33:19 +00:00
										 |  |  | struct NumInput; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct NumInput { | 
					
						
							|  |  |  |     short  idx; | 
					
						
							|  |  |  |     short  idx_max; | 
					
						
							|  |  |  |     short  flag;        /* Different flags to indicate different behaviors                                */ | 
					
						
							|  |  |  |     float  val[3];       /* Direct value of the input                                                      */ | 
					
						
							|  |  |  |     short  ctrl[3];      /* Control to indicate what to do with the numbers that are typed                 */ | 
					
						
							|  |  |  | } NumInput ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  | 	The ctrl value has different meaning: | 
					
						
							|  |  |  | 		0			: No value has been typed | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		otherwise, |value| - 1 is where the cursor is located after the period | 
					
						
							|  |  |  | 		Positive	: number is positive | 
					
						
							|  |  |  | 		Negative	: number is negative | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2005-02-19 16:37:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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                  */ | 
					
						
							| 
									
										
										
										
											2005-03-17 02:34:25 +00:00
										 |  |  | 	short imval[2];	     /* initial mouse value for visual calculation                                */ | 
					
						
							|  |  |  | 	                     /* the one in TransInfo is not garanty to stay the same (Rotates change it)  */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     int   mode;          /* Mode flags of the Constraint                                              */ | 
					
						
							| 
									
										
											  
											
												+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
											
										 
											2005-03-08 03:51:45 +00:00
										 |  |  | 	void  (*drawExtra)(struct TransInfo *); | 
					
						
							|  |  |  | 						 /* For constraints that needs to draw differently from the other
 | 
					
						
							|  |  |  | 							uses this instead of the generic draw function							  */ | 
					
						
							|  |  |  |     void  (*applyVec)(struct TransInfo *, struct TransData *, float *, float *, float *); | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |                          /* Apply function pointer for linear vectorial transformation                */ | 
					
						
							| 
									
										
											  
											
												+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
											
										 
											2005-03-08 03:51:45 +00:00
										 |  |  |                          /* The last three parameters are pointers to the in/out/printable 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 */   | 
					
						
							|  |  |  | 	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 { | 
					
						
							| 
									
										
										
										
											2005-03-27 23:13:52 +00:00
										 |  |  | 	float  dist;         /* Distance needed to affect element (for Proportionnal Editing)                  */ | 
					
						
							|  |  |  | 	float  rdist;        /* Distance to the nearest element (for Proportionnal Editing)                    */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 	float  factor;       /* Factor of the transformation (for Proportionnal Editing)                       */ | 
					
						
							|  |  |  |     float *loc;          /* Location of the data to transform                                              */ | 
					
						
							|  |  |  |     float  iloc[3];      /* Initial location                                                               */ | 
					
						
							| 
									
										
										
										
											2005-03-16 21:55:57 +00:00
										 |  |  | 	float *val;          /* Value pointer for special transforms */ | 
					
						
							|  |  |  | 	float  ival;         /* Old value*/ | 
					
						
							| 
									
										
											  
											
												+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
											
										 
											2005-03-08 03:51:45 +00:00
										 |  |  |     float  center[3];	 /* Individual data center                                                         */ | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  |     float  mtx[3][3];    /* Transformation matrix from data space to global space                          */ | 
					
						
							|  |  |  |     float  smtx[3][3];   /* Transformation matrix from global space to data space                          */ | 
					
						
							| 
									
										
											  
											
												+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
											
										 
											2005-03-08 03:51:45 +00:00
										 |  |  | 	float  axismtx[3][3];/* Axis orientation matrix of the data                                            */ | 
					
						
							| 
									
										
										
										
											2005-02-23 02:23:50 +00:00
										 |  |  | 	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                         */ | 
					
						
							| 
									
										
										
										
											2005-05-10 04:21:11 +00:00
										 |  |  | 	short		state;			/* current state (running, canceled,...)*/ | 
					
						
							| 
									
										
										
										
											2005-03-27 21:25:15 +00:00
										 |  |  |     int         context;        /* current context                      */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     int       (*transform)(struct TransInfo *, short *); | 
					
						
							|  |  |  |                                 /* transform function pointer           */ | 
					
						
							|  |  |  |     char        redraw;         /* redraw flag                          */ | 
					
						
							| 
									
										
										
										
											2005-05-10 04:21:11 +00:00
										 |  |  |     int	        flag;           /* generic flags for special behaviors  */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     int         total;          /* total number of transformed data     */ | 
					
						
							|  |  |  | 	float		propsize;		/* proportional circle radius           */ | 
					
						
							|  |  |  | 	char		proptext[20];	/* proportional falloff text			*/ | 
					
						
							|  |  |  |     float       center[3];      /* center of transformation             */ | 
					
						
							| 
									
										
										
										
											2005-06-05 13:50:21 +00:00
										 |  |  |     int         center2d[2];    /* center in screen coordinates         */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     short       imval[2];       /* initial mouse position               */ | 
					
						
							| 
									
										
										
										
											2005-03-25 11:17:59 +00:00
										 |  |  | 	short		shiftmval[2];	/* mouse position when shift was pressed */ | 
					
						
							| 
									
										
										
										
											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)             */ | 
					
						
							| 
									
										
											  
											
												+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
											
										 
											2005-03-08 03:51:45 +00:00
										 |  |  | 	TransDataExtension *ext;	/* transformed data extension (array)   */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     TransCon    con;            /* transformed constraint               */ | 
					
						
							|  |  |  |     NumInput    num;            /* numerical input                      */ | 
					
						
							| 
									
										
										
										
											2005-03-27 18:17:48 +00:00
										 |  |  |     float       val;            /* init value for some transformations (and rotation angle)  */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  |     float       fac;            /* factor for distance based transform  */ | 
					
						
							| 
									
										
											  
											
												So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
  while-hold-move-release
- Implemented now: Translation Widget, which allows:
  - four hotspots for axis grab or view-aligned grab
  - center defined by 'around' setting
  - SHIFT+LMB gives planar constraint on other 2 axes
  - works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
											
										 
											2005-03-17 21:31:49 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2005-03-24 18:47:09 +00:00
										 |  |  | 	float		viewmat[4][4];	/* copy from G.vd, prevents feedback    */ | 
					
						
							|  |  |  | 	float		viewinv[4][4]; | 
					
						
							|  |  |  | 	float		persinv[4][4]; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
											  
											
												So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
  while-hold-move-release
- Implemented now: Translation Widget, which allows:
  - four hotspots for axis grab or view-aligned grab
  - center defined by 'around' setting
  - SHIFT+LMB gives planar constraint on other 2 axes
  - works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
											
										 
											2005-03-17 21:31:49 +00:00
										 |  |  | 	float		vec[3];			/* translation, to show for widget   	*/ | 
					
						
							|  |  |  | 	float		mat[3][3];		/* rot/rescale, to show for widget   	*/ | 
					
						
							| 
									
										
										
										
											2005-05-08 12:00:28 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	char		*undostr;		/* if set, uses this string for undo */ | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | } TransInfo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ******************** Macros & Prototypes *********************** */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-31 21:02:35 +00:00
										 |  |  | /* NUMINPUT FLAGS */ | 
					
						
							|  |  |  | #define NUM_NULL_ONE		2
 | 
					
						
							|  |  |  | #define NUM_NO_NEGATIVE		4
 | 
					
						
							|  |  |  | #define	NUM_NO_ZERO			8
 | 
					
						
							|  |  |  | #define NUM_NO_FRACTION		16
 | 
					
						
							|  |  |  | #define	NUM_AFFECT_ALL		32
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-10 04:21:11 +00:00
										 |  |  | /* transinfo->state */ | 
					
						
							|  |  |  | #define TRANS_RUNNING	0
 | 
					
						
							|  |  |  | #define TRANS_CONFIRM	1
 | 
					
						
							|  |  |  | #define TRANS_CANCEL	2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-11 01:33:43 +00:00
										 |  |  | /* transinfo->flag */ | 
					
						
							|  |  |  | #define T_OBJECT		1
 | 
					
						
							|  |  |  | #define T_EDIT			2
 | 
					
						
							|  |  |  | #define T_POSE			4
 | 
					
						
							|  |  |  | #define T_TEXTURE		8
 | 
					
						
							| 
									
										
										
										
											2005-03-24 21:32:52 +00:00
										 |  |  | #define T_CAMERA		16
 | 
					
						
							| 
									
										
										
										
											2005-03-25 11:17:59 +00:00
										 |  |  | 		// when shift pressed, higher resolution transform. cannot rely on G.qual, need event!
 | 
					
						
							|  |  |  | #define T_SHIFT_MOD		32
 | 
					
						
							| 
									
										
										
										
											2005-03-19 12:17:06 +00:00
										 |  |  | 		// for manipulator exceptions, like scaling using center point, drawing help lines
 | 
					
						
							|  |  |  | #define T_USES_MANIPULATOR	128
 | 
					
						
							| 
									
										
										
										
											2005-03-11 01:33:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-31 21:02:35 +00:00
										 |  |  | /* restrictions flags */ | 
					
						
							|  |  |  | #define T_ALL_RESTRICTIONS	(256|512|1024)
 | 
					
						
							|  |  |  | #define T_NO_CONSTRAINT	256
 | 
					
						
							|  |  |  | #define T_NULL_ONE		512
 | 
					
						
							|  |  |  | #define T_NO_ZERO		1024
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-07 18:28:41 +00:00
										 |  |  | #define T_PROP_EDIT		 2048
 | 
					
						
							|  |  |  | #define T_PROP_CONNECTED 4096
 | 
					
						
							| 
									
										
										
										
											2005-04-01 18:39:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-10 04:21:11 +00:00
										 |  |  | /* if MMB is pressed or not */ | 
					
						
							|  |  |  | #define	T_MMB_PRESSED	8192
 | 
					
						
							| 
									
										
										
										
											2005-03-11 01:33:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 12:17:06 +00:00
										 |  |  | /* transinfo->con->mode */ | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							| 
									
										
											  
											
												+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
											
										 
											2005-03-08 03:51:45 +00:00
										 |  |  | #define CON_NOFLIP		32	/* does not reorient vector to face viewport when on */
 | 
					
						
							| 
									
										
										
										
											2005-05-07 21:04:55 +00:00
										 |  |  | #define CON_LOCAL		64
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-04-11 19:31:05 +00:00
										 |  |  | #define TD_NOTCONNECTED		8
 | 
					
						
							|  |  |  | #define TD_SINGLESIZE		16	/* used for scaling of MetaElem->rad */
 | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-15 05:44:11 +00:00
										 |  |  | void checkFirstTime(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-08 17:29:33 +00:00
										 |  |  | void initWarp(TransInfo *t); | 
					
						
							|  |  |  | int Warp(TransInfo *t, short mval[2]); | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-13 20:17:39 +00:00
										 |  |  | void initShrinkFatten(TransInfo *t); | 
					
						
							|  |  |  | int ShrinkFatten(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-16 21:55:57 +00:00
										 |  |  | void initTilt(TransInfo *t); | 
					
						
							|  |  |  | int Tilt(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 12:17:06 +00:00
										 |  |  | void initTrackball(TransInfo *t); | 
					
						
							|  |  |  | int Trackball(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-31 22:18:08 +00:00
										 |  |  | void initPushPull(TransInfo *t); | 
					
						
							|  |  |  | int PushPull(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-04 23:37:15 +00:00
										 |  |  | void initCrease(TransInfo *t); | 
					
						
							|  |  |  | int Crease(TransInfo *t, short mval[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-20 09:45:54 +00:00
										 |  |  | /* exported from transform.c */ | 
					
						
							|  |  |  | struct ListBase; | 
					
						
							| 
									
										
										
										
											2005-04-10 18:33:19 +00:00
										 |  |  | void count_bone_select(TransInfo *t, struct ListBase *lb, int *counter); | 
					
						
							| 
									
										
										
										
											2005-03-20 09:45:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Added the new Timeline Window, copied from Tuhopuu, coded by Matt Ebb.
Main change is that it's an own Space type now, not part of the Audio
window... the audio window should restrict to own options. This way
functionality is nicely separated.
Since it's the first time I added a new space (since long!) I've made an
extensive tutorial as well. You can find that here:
http://www.blender3d.org/cms/Adding_new_Space_Window.557.0.html
Notes for using timewindow;
- Add time markers with MKey
- CTRL+M gives option to name Marker
- Markers cannot be moved yet...
- Pageup-Pagedown keys moves current frame to next-prev Marker
- Xkey removes Markers
- If an object has Ipos or an Action, it draws key lines
- CTRL+Pageup-Pagedown moves current frame to next-prev Key
- Press S or E to set start/end frame for playback
Notes about the implementation in Tuhopuu:
- Add new Marker now selects new, deselects others
- Selecting Marker didn't work like elsewhere in Blender, on click it
  should deselect all, except the indicated Marker. Not when holding SHIFT
  of course
- Not exported functions are static now
- Removed unused defines (MARKER_NONE NEXT_AVAIL)
- Drawing order was confusing, doing too many matrix calls
- Removed not needed scrollbar, added new function to draw time values.
  (Has advantage the MMB scroll works not confusing on a scrollbar)
- Added proper support for 'frame mapping'
- The string button (name Marker) had a bug (checked str[64] while str
  was only 64 long)
- String button itself didn't allow "OK on enter"
- Made frame buttons in header larger, the arrows overlapped
- Removed support for negative frame values, that won't work so simple!
											
										 
											2005-05-05 17:19:21 +00:00
										 |  |  | /*********************** exported from transform_manipulator.c ********** */ | 
					
						
							| 
									
										
										
										
											2005-03-23 11:49:54 +00:00
										 |  |  | struct ScrArea; | 
					
						
							|  |  |  | void draw_manipulator_ext(struct ScrArea *sa, int type, char axis, int col, float vec[3], float mat[][3]); | 
					
						
							| 
									
										
											  
											
												Added the new Timeline Window, copied from Tuhopuu, coded by Matt Ebb.
Main change is that it's an own Space type now, not part of the Audio
window... the audio window should restrict to own options. This way
functionality is nicely separated.
Since it's the first time I added a new space (since long!) I've made an
extensive tutorial as well. You can find that here:
http://www.blender3d.org/cms/Adding_new_Space_Window.557.0.html
Notes for using timewindow;
- Add time markers with MKey
- CTRL+M gives option to name Marker
- Markers cannot be moved yet...
- Pageup-Pagedown keys moves current frame to next-prev Marker
- Xkey removes Markers
- If an object has Ipos or an Action, it draws key lines
- CTRL+Pageup-Pagedown moves current frame to next-prev Key
- Press S or E to set start/end frame for playback
Notes about the implementation in Tuhopuu:
- Add new Marker now selects new, deselects others
- Selecting Marker didn't work like elsewhere in Blender, on click it
  should deselect all, except the indicated Marker. Not when holding SHIFT
  of course
- Not exported functions are static now
- Removed unused defines (MARKER_NONE NEXT_AVAIL)
- Drawing order was confusing, doing too many matrix calls
- Removed not needed scrollbar, added new function to draw time values.
  (Has advantage the MMB scroll works not confusing on a scrollbar)
- Added proper support for 'frame mapping'
- The string button (name Marker) had a bug (checked str[64] while str
  was only 64 long)
- String button itself didn't allow "OK on enter"
- Made frame buttons in header larger, the arrows overlapped
- Removed support for negative frame values, that won't work so simple!
											
										 
											2005-05-05 17:19:21 +00:00
										 |  |  | int calc_manipulator_stats(struct ScrArea *sa); | 
					
						
							| 
									
										
										
										
											2005-03-23 11:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Added the new Timeline Window, copied from Tuhopuu, coded by Matt Ebb.
Main change is that it's an own Space type now, not part of the Audio
window... the audio window should restrict to own options. This way
functionality is nicely separated.
Since it's the first time I added a new space (since long!) I've made an
extensive tutorial as well. You can find that here:
http://www.blender3d.org/cms/Adding_new_Space_Window.557.0.html
Notes for using timewindow;
- Add time markers with MKey
- CTRL+M gives option to name Marker
- Markers cannot be moved yet...
- Pageup-Pagedown keys moves current frame to next-prev Marker
- Xkey removes Markers
- If an object has Ipos or an Action, it draws key lines
- CTRL+Pageup-Pagedown moves current frame to next-prev Key
- Press S or E to set start/end frame for playback
Notes about the implementation in Tuhopuu:
- Add new Marker now selects new, deselects others
- Selecting Marker didn't work like elsewhere in Blender, on click it
  should deselect all, except the indicated Marker. Not when holding SHIFT
  of course
- Not exported functions are static now
- Removed unused defines (MARKER_NONE NEXT_AVAIL)
- Drawing order was confusing, doing too many matrix calls
- Removed not needed scrollbar, added new function to draw time values.
  (Has advantage the MMB scroll works not confusing on a scrollbar)
- Added proper support for 'frame mapping'
- The string button (name Marker) had a bug (checked str[64] while str
  was only 64 long)
- String button itself didn't allow "OK on enter"
- Made frame buttons in header larger, the arrows overlapped
- Removed support for negative frame values, that won't work so simple!
											
										 
											2005-05-05 17:19:21 +00:00
										 |  |  | /*********************** TransData Creation and General Handling *********** */ | 
					
						
							| 
									
										
										
										
											2005-04-10 18:33:19 +00:00
										 |  |  | void createTransData(TransInfo *t); | 
					
						
							|  |  |  | void sort_trans_data_dist(TransInfo *t); | 
					
						
							|  |  |  | void clear_trans_object_base_flags(void); | 
					
						
							|  |  |  | void add_tdi_poin(float *poin, float *old, float delta); | 
					
						
							| 
									
										
										
										
											2005-05-04 12:53:35 +00:00
										 |  |  | void special_aftertrans_update(char mode, int flip, short canceled, int keyflags); | 
					
						
							| 
									
										
										
										
											2005-03-20 09:45:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-10 18:33:19 +00:00
										 |  |  | /*********************** Constraints *****************************/ | 
					
						
							|  |  |  | void getConstraintMatrix(TransInfo *t); | 
					
						
							|  |  |  | void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]); | 
					
						
							|  |  |  | void setLocalConstraint(TransInfo *t, int mode, const char text[]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void constraintNumInput(TransInfo *t, float vec[3]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //void drawConstraint(TransCon *t);
 | 
					
						
							|  |  |  | void drawConstraint(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //void drawPropCircle(TransInfo *t);
 | 
					
						
							|  |  |  | void drawPropCircle(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-29 09:21:34 +00:00
										 |  |  | int isLockConstraint(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-10 18:33:19 +00:00
										 |  |  | void initConstraint(TransInfo *t); | 
					
						
							|  |  |  | void startConstraint(TransInfo *t); | 
					
						
							|  |  |  | void stopConstraint(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void getConstraintMatrix(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-24 01:18:13 +00:00
										 |  |  | void initSelectConstraint(TransInfo *t, float mtx[3][3]); | 
					
						
							| 
									
										
										
										
											2005-04-10 18:33:19 +00:00
										 |  |  | void selectConstraint(TransInfo *t); | 
					
						
							|  |  |  | void postSelectConstraint(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int getConstraintSpaceDimension(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void setNearestAxis(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-10 04:21:11 +00:00
										 |  |  | char constraintModeToChar(TransInfo *t); | 
					
						
							| 
									
										
										
										
											2005-04-10 18:33:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*********************** Generics ********************************/ | 
					
						
							|  |  |  | void recalcData(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initTransModeFlags(TransInfo *t, int mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void drawLine(float *center, float *dir, char axis, short options); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* DRAWLINE options flags */ | 
					
						
							|  |  |  | #define DRAWLIGHT	1
 | 
					
						
							|  |  |  | #define DRAWDASHED	2
 | 
					
						
							|  |  |  | #define DRAWBOLD	4
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void applyTransObjects(TransInfo *t); | 
					
						
							|  |  |  | void restoreTransObjects(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initTrans(TransInfo *t); | 
					
						
							|  |  |  | void postTrans (TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void calculateCenterBound(TransInfo *t); | 
					
						
							|  |  |  | void calculateCenterMedian(TransInfo *t); | 
					
						
							|  |  |  | void calculateCenterCursor(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void calculateCenter(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void calculatePropRatio(TransInfo *t); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void snapGrid(TransInfo *t, float *val); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void getViewVector(float coord[3], float vec[3]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TransInfo * BIF_GetTransInfo(void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*********************** NumInput ********************************/ | 
					
						
							|  |  |  | void outputNumInput(NumInput *n, char *str); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | short hasNumInput(NumInput *n); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void applyNumInput(NumInput *n, float *vec); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | char handleNumInput(NumInput *n, unsigned short event); | 
					
						
							| 
									
										
										
										
											2005-02-14 02:53:36 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 |