Transform goodies;

- Added icons for the Widgets to blenderbuttons pic
- Added in header - if widget in use - three buttons to choose widget type
  (hold shift for combo widgets)
- Hotkey CTRL+space now switches widgets on/off

I also noticed negative scaling doesn't work satisfying yet;
- for scale widget, using center didn't work correct anymore (fixed)
- negative scaling didn't even get applied! (fixed)
- but; scaling somethig negative now flips back to positive... ????

Last one i need Martin P for! Note that I had to change Mat3ToSize....
This commit is contained in:
Ton Roosendaal 2005-03-27 18:17:48 +00:00
parent 642012064b
commit b8d59ccb69
10 changed files with 1387 additions and 1279 deletions

@ -2261,13 +2261,15 @@ void Mat3ToSize( float mat[][3], float *size)
{
float vec[3];
VecCopyf(vec, mat[0]);
size[0]= Normalise(vec);
if(vec[0]<0.0) size[0]= -size[0];
VecCopyf(vec, mat[1]);
size[1]= Normalise(vec);
if(vec[1]<0.0) size[1]= -size[1];
VecCopyf(vec, mat[2]);
size[2]= Normalise(vec);
if(vec[2]<0.0) size[2]= -size[2];
}

@ -280,7 +280,29 @@ typedef enum {
ICON_BLANK60,
ICON_BLANK61,
#define BIFICONID_LAST (ICON_BLANK61)
ICON_BLANK65,
ICON_BLANK66,
ICON_BLANK67,
ICON_MANIPUL,
ICON_MAN_TRANS,
ICON_MAN_ROT,
ICON_MAN_SCALE,
ICON_BLANK68,
ICON_BLANK69,
ICON_BLANK70,
ICON_BLANK71,
ICON_BLANK72,
ICON_BLANK73,
ICON_BLANK74,
ICON_BLANK75,
ICON_BLANK76,
ICON_BLANK77,
ICON_BLANK78,
ICON_BLANK79,
ICON_BLANK80,
ICON_BLANK81,
#define BIFICONID_LAST (ICON_BLANK81)
#define BIFNICONIDS (BIFICONID_LAST-BIFICONID_FIRST + 1)
} BIFIconID;

@ -217,6 +217,9 @@
#define B_SEL_VERT 158
#define B_SEL_EDGE 159
#define B_SEL_FACE 160
#define B_MAN_TRANS 161
#define B_MAN_ROT 162
#define B_MAN_SCALE 163
/* IPO: 200 */
#define B_IPOHOME 201

File diff suppressed because it is too large Load Diff

@ -1188,7 +1188,7 @@ void screenmain(void)
}
else if (event==SPACEKEY) {
if((G.obedit && G.obedit->type==OB_FONT && g_activearea->spacetype==SPACE_VIEW3D)||g_activearea->spacetype==SPACE_TEXT||g_activearea->spacetype==SPACE_SCRIPT);
else {
else if(G.qual==0) {
if(val) toolbox_n();
towin= 0;
}

@ -3741,6 +3741,22 @@ void do_view3d_buttons(short event)
EM_selectmode_set();
allqueue(REDRAWVIEW3D, 1);
break;
case B_MAN_TRANS:
if( (G.qual & LR_SHIFTKEY)==0 || G.vd->twtype==0)
G.vd->twtype= V3D_MANIPULATOR_TRANSLATE;
allqueue(REDRAWVIEW3D, 1);
break;
case B_MAN_ROT:
if( (G.qual & LR_SHIFTKEY)==0 || G.vd->twtype==0)
G.vd->twtype= V3D_MANIPULATOR_ROTATE;
allqueue(REDRAWVIEW3D, 1);
break;
case B_MAN_SCALE:
if( (G.qual & LR_SHIFTKEY)==0 || G.vd->twtype==0)
G.vd->twtype= V3D_MANIPULATOR_SCALE;
allqueue(REDRAWVIEW3D, 1);
break;
default:
@ -3972,11 +3988,21 @@ void view3d_buttons(void)
xco+= XIC+8;
uiDefIconButS(block, TOG|BIT|0, B_REDR, ICON_OBJECT,
xco,0,XIC,YIC,
&G.vd->twflag, 0, 0, 0, 0, "Use 3d transform widgets");
/* Transform widget / manipulators */
uiBlockBeginAlign(block);
uiDefIconButS(block, TOG|BIT|0, B_REDR, ICON_MANIPUL,xco,0,XIC,YIC, &G.vd->twflag, 0, 0, 0, 0, "Use 3d transform widgets");
xco+= XIC;
xco+= XIC+8;
if(G.vd->twflag & V3D_USE_MANIPULATOR) {
uiDefIconButS(block, TOG|BIT|0, B_MAN_TRANS, ICON_MAN_TRANS, xco,0,XIC,YIC, &G.vd->twtype, 1.0, 0.0, 0, 0, "Translate widget mode");
xco+= XIC;
uiDefIconButS(block, TOG|BIT|1, B_MAN_ROT, ICON_MAN_ROT, xco,0,XIC,YIC, &G.vd->twtype, 1.0, 0.0, 0, 0, "Rotate widget mode");
xco+= XIC;
uiDefIconButS(block, TOG|BIT|2, B_MAN_SCALE, ICON_MAN_SCALE, xco,0,XIC,YIC, &G.vd->twtype, 1.0, 0.0, 0, 0, "Scale widget mode");
xco+= XIC;
}
uiBlockEndAlign(block);
xco+= 8;
/* LAYERS */
if(G.vd->localview==0) {

@ -229,6 +229,26 @@ static void def_icon(ImBuf *bbuf, GLuint texid, BIFIconID icon, int xidx, int yi
/***/
static void clear_transp_rect_soft(unsigned char *transp, unsigned char *rect, int w, int h, int rowstride)
{
int x,y;
for (y=0; y<h; y++) {
unsigned char *row= &rect[y*rowstride];
for (x=0; x<w; x++) {
unsigned char *pxl= &row[x*4];
if (*((unsigned int*) pxl)==*((unsigned int*) transp)) {
pxl[3]= 0;
}
else if( abs(pxl[0]-transp[0])<10 && abs(pxl[1]-transp[1])<10 && abs(pxl[2]-transp[2])<10) {
pxl[3]= 40;
}
}
}
}
static void clear_transp_rect(unsigned char *transp, unsigned char *rect, int w, int h, int rowstride)
{
int x,y;
@ -252,7 +272,7 @@ void BIF_resources_init(void)
common_icons_arr= MEM_mallocN(sizeof(*common_icons_arr)*BIFNICONIDS, "common_icons");
/* hack! */
for (y=0; y<11; y++) {
for (y=0; y<12; y++) {
for (x=0; x<21; x++) {
int rowstride= bbuf->x*4;
unsigned char *start= ((char*) bbuf->rect) + (y*21 + 3)*rowstride + (x*20 + 3)*4;
@ -262,7 +282,7 @@ void BIF_resources_init(void)
transp[1]= start[1];
transp[2]= start[2];
transp[3]= start[3];
clear_transp_rect(transp, start, 20, 21, rowstride);
clear_transp_rect_soft(transp, start, 20, 21, rowstride);
/* this sets outside of icon to zero alpha */
start= ((char*) bbuf->rect) + (y*21)*rowstride + (x*20)*4;
@ -275,7 +295,7 @@ void BIF_resources_init(void)
// texid= init_icon_texture(bbuf);
/* hack! */
for (y=0; y<11; y++) {
for (y=0; y<12; y++) {
for (x=0; x<21; x++) {
if (x==11 && y==6) {
def_icon(bbuf, texid, ICON_BEVELBUT_HLT, x, y, 7, 13, 4, 2);

@ -1057,6 +1057,11 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
do_layer_buttons(11); break;
case ACCENTGRAVEKEY:
do_layer_buttons(-1); break;
case SPACEKEY:
G.vd->twflag ^= V3D_USE_MANIPULATOR;
doredraw= 1;
break;
case AKEY:
if(G.qual & LR_CTRLKEY) apply_object(); // also with shift!

@ -2058,10 +2058,11 @@ int Resize(TransInfo *t, short mval[2])
float dy= (float)(t->center2d[1] - mval[1]);
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
}
/* flip scale, but not for manipulator center handle */
if ((t->center2d[0] - mval[0]) * (t->center2d[0] - t->imval[0]) < 0)
ratio *= -1.0f;
}
if ((t->center2d[0] - mval[0]) * (t->center2d[0] - t->imval[0]) < 0)
ratio *= -1.0f;
size[0] = size[1] = size[2] = ratio;
@ -2123,7 +2124,6 @@ int Resize(TransInfo *t, short mval[2])
TransDataIpokey *tdi= td->tdi;
/* calculate delta size (equal for size and dsize) */
// commented out for now
vec[0]= (tdi->oldsize[0])*(fsize[0] -1.0f) * td->factor;
vec[1]= (tdi->oldsize[1])*(fsize[1] -1.0f) * td->factor;
vec[2]= (tdi->oldsize[2])*(fsize[2] -1.0f) * td->factor;
@ -2134,9 +2134,9 @@ int Resize(TransInfo *t, short mval[2])
}
else {
td->ext->size[0] = td->ext->isize[0] + td->ext->isize[0] * (fsize[0] - 1.0f) * td->factor;
td->ext->size[1] = td->ext->isize[1] + td->ext->isize[1] * (fsize[1] - 1.0f) * td->factor;
td->ext->size[2] = td->ext->isize[2] + td->ext->isize[2] * (fsize[2] - 1.0f) * td->factor;
td->ext->size[0] = td->ext->isize[0] * (fsize[0]) * td->factor;
td->ext->size[1] = td->ext->isize[1] * (fsize[1]) * td->factor;
td->ext->size[2] = td->ext->isize[2] * (fsize[2]) * td->factor;
}
}
}
@ -2459,6 +2459,7 @@ int Rotation(TransInfo *t, short mval[2])
//printf("Axis %f %f %f\n", axis[0], axis[1], axis[2]);
VecRotToMat3(axis, final * td->factor, mat);
t->val = final; // used in manipulator
Mat3CpyMat3(t->mat, mat); // used in manipulator
applyRotation(t, final, axis);

@ -124,7 +124,7 @@ typedef struct TransInfo {
TransDataExtension *ext; /* transformed data extension (array) */
TransCon con; /* transformed constraint */
NumInput num; /* numerical input */
float val; /* init value for some transformations */
float val; /* init value for some transformations (and rotation angle) */
float fac; /* factor for distance based transform */
float viewmat[4][4]; /* copy from G.vd, prevents feedback */