diff options
author | Johnny Matthews <johnny.matthews@gmail.com> | 2004-07-06 23:07:13 +0400 |
---|---|---|
committer | Johnny Matthews <johnny.matthews@gmail.com> | 2004-07-06 23:07:13 +0400 |
commit | 9c94728d893655d378004a5c39d9c5b51da07259 (patch) | |
tree | e99906bd787209afa26397a6c37b676baf052e95 | |
parent | 5b09bb1eb173e07c21b33af9df19df072db11bde (diff) |
This is the initial commit of a revamp of the sweep effects that goofster committed that was originally a sequence plugin from sirdude.
The changes from the original include the ability to add a blurred edge with a selectable width to the wipe and to rotate the effect.
Has these sweep types included already
-single
-double
-iris
These still need to be coded
-box
-cross
-clock
-rw-r--r-- | source/blender/include/BSE_sequence.h | 13 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_sequence_types.h | 4 | ||||
-rw-r--r-- | source/blender/src/drawseq.c | 8 | ||||
-rw-r--r-- | source/blender/src/sequence.c | 331 |
4 files changed, 218 insertions, 138 deletions
diff --git a/source/blender/include/BSE_sequence.h b/source/blender/include/BSE_sequence.h index f4d7c99ec02..c8bbedd2fbb 100644 --- a/source/blender/include/BSE_sequence.h +++ b/source/blender/include/BSE_sequence.h @@ -96,15 +96,10 @@ void do_mul_effect(float facf0, float facf1, unsigned int *rect1, unsigned int *rect2, unsigned int *out); /* Sweep effect */ -enum {DO_LEFT_RIGHT, DO_RIGHT_LEFT, DO_DOWN_UP, DO_UP_DOWN, - DO_LOWER_LEFT_UPPER_RIGHT, DO_UPPER_RIGHT_LOWER_LEFT, - DO_UPPER_LEFT_LOWER_RIGHT, DO_LOWER_RIGHT_UPPER_LEFT, - DO_HORZ_OUT, DO_HORZ_IN, DO_VERT_OUT, DO_VERT_IN, - DO_HORZ_VERT_OUT, DO_HORZ_VERT_IN, DO_LEFT_DOWN_RIGHT_UP_OUT, - DO_LEFT_DOWN_RIGHT_UP_IN, DO_LEFT_UP_RIGHT_DOWN_OUT, - DO_LEFT_UP_RIGHT_DOWN_IN, DO_DIAG_OUT, DO_DIAG_IN, DO_DIAG_OUT_2, - DO_DIAG_IN_2}; -int check_zone(int x, int y, int xo, int yo, struct Sequence *seq, float facf0); +enum {DO_SINGLE_WIPE, DO_DOUBLE_WIPE, DO_BOX_WIPE, DO_CROSS_WIPE, + DO_IRIS_WIPE}; +float in_band(float width,float dist, float perc,int side,int dir); +float check_zone(int x, int y, int xo, int yo, struct Sequence *seq, float facf0); void init_sweep_effect(struct Sequence *seq); void do_sweep_effect(struct Sequence *seq, float facf0, float facf1, int x, int y, unsigned int *rect1, unsigned int *rect2, unsigned int *out); diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index ec9f276bb84..fad745b5b7e 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -140,6 +140,10 @@ typedef struct Editing { /* ************* Effect Variable Structs ********* */ typedef struct SweepVars { + float edgeWidth,angle; + short forward,spad1,spad2,spad3; + int ipad1; + float fpad1,fpad2; short sweeptype; } SweepVars; diff --git a/source/blender/src/drawseq.c b/source/blender/src/drawseq.c index 6e49c9958c5..24c44e100fc 100644 --- a/source/blender/src/drawseq.c +++ b/source/blender/src/drawseq.c @@ -713,10 +713,12 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES if(last_seq->type==SEQ_SWEEP){ SweepVars *sweep = (SweepVars *)last_seq->effectdata; char formatstring[1024]; - - strcpy(formatstring, "Select Sweep Type %t|Left to Right %x0|Right to Left %x1|Bottom to Top %x2|Top to Bottom %x3|Top left to Bottom right%x4|Bottom right to Top left %x5|Bottom left to Top right %x6|Top right to Bottom left %x7|Horizontal out %x8|Horizontal in %x9|Vertical out %x10|Vertical in %x11|Hor/Vert out %x12|Hor/Vert in %x13|Bottom left to Top right out %x14|Top left to Bottom right in %x15|Top left to Bottom right out %x16|Bottom left to Top right in %x17|Diagonal out %x18|Diagonal in %x19|Diagonal out 2 %x20|Diagonal in 2 %x21|"); - + strcpy(formatstring, "Select Sweep Type %t|Single Wipe%x0|Double Wipe %x1|Iris Wipe %x4"); uiDefButS(block, MENU,SEQ_BUT_EFFECT, formatstring, 10,90,220,22, &sweep->sweeptype, 0, 0, 0, 0, "What type of sweep should be performed"); + uiDefButF(block, NUM,SEQ_BUT_EFFECT,"Blur:", 10,65,220,22, &sweep->edgeWidth,0.0,1.0, 1, 2, "The percent width of the blur edge"); + if(sweep->sweeptype != DO_IRIS_WIPE) + uiDefButF(block, NUM,SEQ_BUT_EFFECT,"Angle:", 10,40,220,22, &sweep->angle,-90.0,90.0, 1, 2, "The Angle of the Edge"); + uiDefButS(block, TOG,SEQ_BUT_EFFECT,"Wipe In", 10,15,220,22, &sweep->forward,0,0, 0, 0, "Controls Primary Direction of Sweep"); } else if(last_seq->type==SEQ_GLOW){ GlowVars *glow = (GlowVars *)last_seq->effectdata; diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c index 5a5b74724c2..39c23f1cf78 100644 --- a/source/blender/src/sequence.c +++ b/source/blender/src/sequence.c @@ -956,136 +956,215 @@ void do_mul_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, } } +// This function calculates the blur band for the wipe effects +float in_band(float width,float dist, float perc,int side,int dir){ + + float t1,t2,alpha,percwidth; + if(width == 0) + return (float)side; + if(side == 1) + percwidth = width * perc; + else + percwidth = width * (1 - perc); + + if(width < dist) + return side; + + t1 = dist / width; //percentange of width that is + t2 = 1 / width; //amount of alpha per % point + + if(side == 1) + alpha = (t1*t2*100) + (1-perc); // add point's alpha contrib to current position in wipe + else + alpha = (1-perc) - (t1*t2*100); + + if(dir == 0) + alpha = 1-alpha; + return alpha; +} +float check_zone(int x, int y, int xo, int yo, Sequence *seq, float facf0) { -int check_zone(int x, int y, int xo, int yo, Sequence *seq, float facf0) { - - float posx, posy; + float posx, posy,hyp,hyp2,angle,hwidth,b1,b2,b3,pointdist; + /*some future stuff + float hyp3,hyp4,b4,b5 + */ + float temp1,temp2; //some placeholder variables float halfx = xo/2; float halfy = yo/2; + float output=0; SweepVars *sweep = (SweepVars *)seq->effectdata; + int width,invert = 0; - //printf("facf0: %f xo: %d\n", facf0, x); - posx = facf0 * xo; - posy = facf0 * yo; + angle = sweep->angle; + if(angle < 0){ + x = xo-x; + //y = yo-y + } + angle = pow(fabs(angle)/45,log(xo,2)); + posy = facf0 * yo; + if(sweep->forward){ + posx = facf0 * xo; + posy = facf0 * yo; + } else{ + posx = xo - facf0 * xo; + posy = yo - facf0 * yo; + } switch (sweep->sweeptype) { - case DO_LEFT_RIGHT: - if (x > posx) return 1; - return 0; - break; - case DO_RIGHT_LEFT: - if (x < (xo - posx)) return 1; - return 0; - break; - case DO_DOWN_UP: - if (y > posy ) return 1; - return 0; - break; - case DO_UP_DOWN: - if (y < (yo - posy)) return 1; - return 0; - break; - case DO_LOWER_LEFT_UPPER_RIGHT: - if (posy < posx) posx = posy; - if ((x + yo - y) < posx*2) return 0; - return 1; - break; - case DO_UPPER_RIGHT_LOWER_LEFT: - if (posy < posx) posx = posy; - if ((xo - x + y) < posx*2) return 0; - return 1; - break; - case DO_UPPER_LEFT_LOWER_RIGHT: - if (posy < posx) posx = posy; - if ((x + y) < posx*2 ) return 0; - return 1; - break; - case DO_LOWER_RIGHT_UPPER_LEFT: - if (posy < posx) posx = posy; - if ((xo - x + yo - y) < posx*2) return 0; - return 1; - break; - case DO_HORZ_OUT: - if ((x < (halfx - (posx/2)) ) || (x > (halfx + posx/2) )) return 1; - return 0; - break; - case DO_HORZ_IN: - if ((x >posx/2) && (x < (xo - posx/2))) return 1; - return 0; - break; - case DO_VERT_OUT: - if ((y < (halfy - posy/2)) || (y > (halfy + posy/2))) return 1; - return 0; - break; - case DO_VERT_IN: - if ((y >posy/2) && (y < (yo - posy/2))) return 1; - return 0; - break; - case DO_HORZ_VERT_OUT: - if (posy < posx) posx = posy; - if (((x > (halfx - posx/2)) && (x < (halfx + posx/2))) || - ((y > (halfy - posx/2)) && (y < (halfy + posx/2)))) return 0; - return 1; - break; - case DO_HORZ_VERT_IN: - if (posy < posx) posx = posy; - if ((x <posx/2) || ((xo - x) < posx/2) || (y < posx/2) || - ((yo - y) < posx/2)) return 0; - return 1; - break; - case DO_LEFT_DOWN_RIGHT_UP_OUT: - if (posy < posx) posx = posy; - if (((x - halfx + y - halfy) < posx) && - ((halfx -x + halfy -y ) < posx)) return 0; - return 1; - break; - case DO_LEFT_DOWN_RIGHT_UP_IN: - if (posy < posx) posx = posy; - if (((y + xo - x) < posx) || ((yo - y + x) < posx)) return 0; - return 1; - break; - case DO_LEFT_UP_RIGHT_DOWN_OUT: - if (posy < posx) posx = posy; - if (((x - halfx + yo - y - halfy) < posx) && - ((halfx - x + halfy - yo + y ) < posx)) return 0; - return 1; - break; - case DO_LEFT_UP_RIGHT_DOWN_IN: - if (posy < posx) posx = posy; - if (((x+ y) < posx) || ((xo -x + yo - y) < posx )) return 0; - return 1; - break; - case DO_DIAG_OUT: - if (posy < posx) posx = posy; - if ((((x - halfx + y - halfy) < posx) && - ((halfx -x + halfy -y ) < posx)) && - (((x - halfx + yo - y - halfy) < posx)) && - ((halfx -x + halfy -yo + y) < posx)) return 0; - return 1; + case DO_SINGLE_WIPE: + width = (int)(sweep->edgeWidth*((xo+yo)/2.0)); + hwidth = (float)width/2.0; + + if (angle == 0.0)angle = 0.000001; + b1 = posy - (-angle)*posx; + b2 = y - (-angle)*x; + hyp = abs(angle*x+y+(-posy-angle*posx))/sqrt(angle*angle+1); + if(angle < 0){ + temp1 = b1; + b1 = b2; + b2 = temp1; + } + if(sweep->forward){ + if(b1 < b2) + output = in_band(width,hyp,facf0,1,1); + else + output = in_band(width,hyp,facf0,0,1); + } + else{ + if(b1 < b2) + output = in_band(width,hyp,facf0,0,1); + else + output = in_band(width,hyp,facf0,1,1); + } + break; + + + case DO_DOUBLE_WIPE: + if(!sweep->forward)facf0 = 1-facf0; // Go the other direction + + width = (int)(sweep->edgeWidth*((xo+yo)/2.0)); // calculate the blur width + hwidth = (float)width/2.0; + if (angle == 0)angle = 0.000001; + b1 = posy/2 - (-angle)*posx/2; + b3 = (yo-posy/2) - (-angle)*(xo-posx/2); + b2 = y - (-angle)*x; + + hyp = abs(angle*x+y+(-posy/2-angle*posx/2))/sqrt(angle*angle+1); + hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))/sqrt(angle*angle+1); + + temp1 = xo*(1-facf0/2)-xo*facf0/2; + temp2 = yo*(1-facf0/2)-yo*facf0/2; + pointdist = sqrt(temp1*temp1 + temp2*temp2); + + if(b2 < b1 && b2 < b3 ){ + if(hwidth < pointdist) + output = in_band(hwidth,hyp,facf0,0,1); + } + else if(b2 > b1 && b2 > b3 ){ + if(hwidth < pointdist) + output = in_band(hwidth,hyp2,facf0,0,1); + } + else{ + if( hyp < hwidth && hyp2 > hwidth ) + output = in_band(hwidth,hyp,facf0,1,1); + else if( hyp > hwidth && hyp2 < hwidth ) + output = in_band(hwidth,hyp2,facf0,1,1); + else + output = in_band(hwidth,hyp2,facf0,1,1) * in_band(hwidth,hyp,facf0,1,1); + } + if(!sweep->forward)output = 1-output; + break; + /* BOX WIPE IS NOT WORKING YET */ + /* case DO_CROSS_WIPE: */ + /* BOX WIPE IS NOT WORKING YET */ + /* case DO_BOX_WIPE: + if(invert)facf0 = 1-facf0; + + width = (int)(sweep->edgeWidth*((xo+yo)/2.0)); + hwidth = (float)width/2.0; + if (angle == 0)angle = 0.000001; + b1 = posy/2 - (-angle)*posx/2; + b3 = (yo-posy/2) - (-angle)*(xo-posx/2); + b2 = y - (-angle)*x; + + hyp = abs(angle*x+y+(-posy/2-angle*posx/2))/sqrt(angle*angle+1); + hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))/sqrt(angle*angle+1); + + temp1 = xo*(1-facf0/2)-xo*facf0/2; + temp2 = yo*(1-facf0/2)-yo*facf0/2; + pointdist = sqrt(temp1*temp1 + temp2*temp2); + + if(b2 < b1 && b2 < b3 ){ + if(hwidth < pointdist) + output = in_band(hwidth,hyp,facf0,0,1); + } + else if(b2 > b1 && b2 > b3 ){ + if(hwidth < pointdist) + output = in_band(hwidth,hyp2,facf0,0,1); + } + else{ + if( hyp < hwidth && hyp2 > hwidth ) + output = in_band(hwidth,hyp,facf0,1,1); + else if( hyp > hwidth && hyp2 < hwidth ) + output = in_band(hwidth,hyp2,facf0,1,1); + else + output = in_band(hwidth,hyp2,facf0,1,1) * in_band(hwidth,hyp,facf0,1,1); + } + if(invert)facf0 = 1-facf0; + angle = -1/angle; + b1 = posy/2 - (-angle)*posx/2; + b3 = (yo-posy/2) - (-angle)*(xo-posx/2); + b2 = y - (-angle)*x; + + hyp = abs(angle*x+y+(-posy/2-angle*posx/2))/sqrt(angle*angle+1); + hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))/sqrt(angle*angle+1); + + if(b2 < b1 && b2 < b3 ){ + if(hwidth < pointdist) + output *= in_band(hwidth,hyp,facf0,0,1); + } + else if(b2 > b1 && b2 > b3 ){ + if(hwidth < pointdist) + output *= in_band(hwidth,hyp2,facf0,0,1); + } + else{ + if( hyp < hwidth && hyp2 > hwidth ) + output *= in_band(hwidth,hyp,facf0,1,1); + else if( hyp > hwidth && hyp2 < hwidth ) + output *= in_band(hwidth,hyp2,facf0,1,1); + else + output *= in_band(hwidth,hyp2,facf0,1,1) * in_band(hwidth,hyp,facf0,1,1); + } + + break;*/ + case DO_IRIS_WIPE: + if(xo > yo) yo = xo; + else xo = yo; + + if(!sweep->forward) + facf0 = 1-facf0; + + width = (int)(sweep->edgeWidth*((xo+yo)/2.0)); + hwidth = (float)width/2.0; + + temp1 = (halfx-(halfx)*facf0); + pointdist = sqrt(temp1*temp1 + temp1*temp1); + + temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); + if(temp2 > pointdist) + output = in_band(hwidth,fabs(temp2-pointdist),facf0,0,1); + else + output = in_band(hwidth,fabs(temp2-pointdist),facf0,1,1); + + if(!sweep->forward) + output = 1-output; + break; - case DO_DIAG_IN: - if (posy < posx) posx = posy; - if ((x + y) < posx || ((xo -x + yo - y) < posx) || - ((x + yo -y) < posx) || ((y + xo - x) < posx)) return 0; - return 1; - break; - case DO_DIAG_OUT_2: - if (posy < posx) posx = posy; - if ((((x - halfx + y - halfy) < posx/2) && - ((halfx -x + halfy -y ) < posx/2)) || - ((((x - halfx + yo - y - halfy) < posx/2)) && - ((halfx - x + halfy - yo + y) < posx/2))) return 0; - return 1; - break; - case DO_DIAG_IN_2: - if (posy < posx) posx = posy; - if ((((y + xo - x) < posx) || ((yo - y + x) < posx)) && - (((x+ y) < posx) || ((xo -x + yo - y) < posx ))) return 0; - return 1; - break; } - return 0; + if (output < 0) output = 0; + else if(output > 1) output = 1; + return output; } void init_sweep_effect(Sequence *seq) @@ -1107,13 +1186,13 @@ void do_sweep_effect(Sequence *seq, float facf0, float facf1, int x, int y, unsi for(y=0;y<yo;y++) { for(x=0;x<xo;x++) { - - if (check_zone(x,y,xo,yo,seq,facf0)) { + float check = check_zone(x,y,xo,yo,seq,facf0); + if (check) { if (rt1) { - rt[0] = rt1[0]; - rt[1] = rt1[1]; - rt[2] = rt1[2]; - rt[3] = rt1[3]; + rt[0] = (int)(rt1[0]*check)+ (int)(rt2[0]*(1-check)); + rt[1] = (int)(rt1[1]*check)+ (int)(rt2[1]*(1-check)); + rt[2] = (int)(rt1[2]*check)+ (int)(rt2[2]*(1-check)); + rt[3] = (int)(rt1[3]*check)+ (int)(rt2[3]*(1-check)); } else { rt[0] = 0; rt[1] = 0; |