added a new Sequence Effect: Sweep.

this consists of 22 different ways to sweep from 1 strip to another. For you windows lovers: it's like "Blinds" in Powerpoint :)
- in the NKEY menu you can choose which type you want perform, vertical, horizontal, in/out etc. it's too much to decribe.

Credits for this go to Kent 'Sirdude" Mein who coded the sequence plugin I stole the code from.

To allow certain sequence effects to have settings, I also added a "varstr" void pointer to the Sequence DNA, that can point to a special struct for each effect. This is similar to how plugins are handles.

more neat effects to come....
This commit is contained in:
Roel Spruit 2004-06-18 22:53:06 +00:00
parent 35382146be
commit a31dec3712
6 changed files with 768 additions and 532 deletions

View File

@ -95,6 +95,18 @@ void do_mul_effect(float facf0, float facf1,
int x, int y,
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);
void do_sweep_effect(struct Sequence *seq, float facf0, float facf1, int x, int y, unsigned int *rect1, unsigned int *rect2, unsigned int *out);
void make_black_ibuf(struct ImBuf *ibuf);
void multibuf(struct ImBuf *ibuf, float fmul);
void do_effect(int cfra, struct Sequence *seq, struct StripElem *se);

View File

@ -119,6 +119,8 @@ typedef struct Sequence {
int curpos; /* last sample position in audio_fill() */
int pad;
void *varstr; /* Struct pointer for effect settings */
} Sequence;
#
#
@ -136,6 +138,12 @@ typedef struct Editing {
int pad;
} Editing;
/* ************* Effect Variable Structs ********* */
typedef struct SweepVars {
short sweeptype;
} SweepVars;
/* ***************** SEQUENCE ****************** */
/* seq->flag */
@ -162,6 +170,7 @@ typedef struct Editing {
#define SEQ_MUL 14
#define SEQ_OVERDROP 15
#define SEQ_PLUGIN 24
#define SEQ_SWEEP 25
#endif

View File

@ -120,6 +120,7 @@ static char *give_seqname(Sequence *seq)
else if(seq->type==SEQ_ALPHAOVER) return "ALPHAOVER";
else if(seq->type==SEQ_ALPHAUNDER) return "ALPHAUNDER";
else if(seq->type==SEQ_OVERDROP) return "OVER DROP";
else if(seq->type==SEQ_SWEEP) return "SWEEP";
else if(seq->type==SEQ_PLUGIN) {
if(seq->plugin && seq->plugin->doit) return seq->plugin->pname;
return "PLUGIN";
@ -164,6 +165,8 @@ static unsigned int seq_color(Sequence *seq)
return 0x9080A0;
case SEQ_OVERDROP:
return 0x5080B0;
case SEQ_SWEEP:
return 0x2080B0;
case SEQ_PLUGIN:
return 0x906000;
case SEQ_SOUND:
@ -701,6 +704,15 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES
uiDefBut(block, LABEL, 0, "Striptype: Effect", 10,140,150,20, 0, 0, 0, 0, 0, "");
uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, "");
if(last_seq->type==SEQ_SWEEP){
SweepVars *sweep = (SweepVars *)last_seq->varstr;
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|");
uiDefButS(block, MENU,SEQ_BUT_MOVIE, formatstring, 10,90,220,22, &sweep->sweeptype, 0, 0, 0, 0, "What type of sweep should be performed");
}
}

View File

@ -836,6 +836,7 @@ static int event_to_efftype(int event)
if(event==8) return SEQ_ALPHAUNDER;
if(event==9) return SEQ_OVERDROP;
if(event==10) return SEQ_PLUGIN;
if(event==13) return SEQ_SWEEP;
return 0;
}
@ -870,7 +871,7 @@ static int add_seq_effect(int type)
seq= seq->next;
}
if(type==10) { /* plugin: minimal 1 select */
if(type==10 || type==13) { /* plugin: minimal 1 select */
if(seq2==0) {
error("Need at least one selected sequence strip");
return 0;
@ -898,6 +899,11 @@ static int add_seq_effect(int type)
seq->type= event_to_efftype(type);
/* Allocate variable structs for effects with settings */
if(seq->type==SEQ_SWEEP){
seq->varstr = MEM_callocN(sizeof(struct SweepVars), "sweepvars");
}
if(seq->type==SEQ_ALPHAUNDER || seq->type==SEQ_ALPHAOVER) {
seq->seq2= seq1;
seq->seq1= seq2;
@ -994,13 +1000,16 @@ void add_sequence(int type)
case SEQ_OVERDROP:
event = 9;
break;
case SEQ_SWEEP:
event = 13;
break;
default:
event = 0;
break;
}
}
else {
event= pupmenu("Add Sequence Strip%t|Images%x1|Movie%x102|Audio%x103|Scene%x101|Plugin%x10|Cross%x2|Gamma Cross%x3|Add%x4|Sub%x5|Mul%x6|Alpha Over%x7|Alpha Under%x8|Alpha Over Drop%x9");
event= pupmenu("Add Sequence Strip%t|Images%x1|Movie%x102|Audio%x103|Scene%x101|Plugin%x10|Cross%x2|Gamma Cross%x3|Add%x4|Sub%x5|Mul%x6|Alpha Over%x7|Alpha Under%x8|Alpha Over Drop%x9|Sweep%x13");
}
if(event<1) return;
@ -1070,6 +1079,7 @@ void add_sequence(int type)
case 8:
case 9:
case 10:
case 13:
if(last_seq==0) error("Need at least one active sequence strip");
else if(event==10) {

View File

@ -206,6 +206,9 @@ static void do_seq_addmenu_effectmenu(void *arg, int event)
case 8:
add_sequence(SEQ_PLUGIN);
break;
case 9:
add_sequence(SEQ_SWEEP);
break;
}
}
@ -225,6 +228,7 @@ static uiBlock *seq_addmenu_effectmenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Alpha Over", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Alpha Under", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Alpha Over Drop", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Sweep", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Plugin...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");

View File

@ -225,6 +225,7 @@ void free_sequence(Sequence *seq)
extern Sequence *last_seq;
if(seq->strip) free_strip(seq->strip);
if(seq->varstr) MEM_freeN(seq->varstr);
if(seq->anim) IMB_free_anim(seq->anim);
@ -954,6 +955,191 @@ void do_mul_effect(float facf0, float facf1, int x, int y, unsigned int *rect1,
}
}
int check_zone(int x, int y, int xo, int yo, Sequence *seq, float facf0) {
float posx, posy;
float halfx = xo/2;
float halfy = yo/2;
SweepVars *sweep = (SweepVars *)seq->varstr;
//printf("facf0: %f xo: %d\n", facf0, x);
posx = facf0 * xo;
posy = 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;
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;
}
void do_sweep_effect(Sequence *seq, float facf0, float facf1, int x, int y, unsigned int *rect1, unsigned int *rect2, unsigned int *out)
{
int xo, yo;
char *rt1, *rt2, *rt;
rt1 = (char *)rect1;
rt2 = (char *)rect2;
rt = (char *)out;
xo = x;
yo = y;
for(y=0;y<yo;y++) {
for(x=0;x<xo;x++) {
if (check_zone(x,y,xo,yo,seq,facf0)) {
if (rt1) {
rt[0] = rt1[0];
rt[1] = rt1[1];
rt[2] = rt1[2];
rt[3] = rt1[3];
} else {
rt[0] = 0;
rt[1] = 0;
rt[2] = 0;
rt[3] = 255;
}
} else {
if (rt2) {
rt[0] = rt2[0];
rt[1] = rt2[1];
rt[2] = rt2[2];
rt[3] = rt2[3];
} else {
rt[0] = 0;
rt[1] = 0;
rt[2] = 0;
rt[3] = 255;
}
}
rt+=4;
if(rt1 !=NULL){
rt1+=4;
}
if(rt2 !=NULL){
rt2+=4;
}
}
}
}
void make_black_ibuf(ImBuf *ibuf)
{
unsigned int *rect;
@ -1026,7 +1212,7 @@ void do_effect(int cfra, Sequence *seq, StripElem *se)
fac= seq->facf0;
facf= seq->facf1;
}
else if ELEM3( seq->type, SEQ_CROSS, SEQ_GAMCROSS, SEQ_PLUGIN) {
else if ( seq->type==SEQ_CROSS || seq->type==SEQ_GAMCROSS || seq->type==SEQ_PLUGIN || seq->type==SEQ_SWEEP) {
fac= (float)(cfra - seq->startdisp);
facf= (float)(fac+0.5);
fac /= seq->len;
@ -1064,6 +1250,9 @@ void do_effect(int cfra, Sequence *seq, StripElem *se)
case SEQ_ALPHAUNDER:
do_alphaunder_effect(fac, facf, x, y, se1->ibuf->rect, se2->ibuf->rect, se->ibuf->rect);
break;
case SEQ_SWEEP:
do_sweep_effect(seq, fac, facf, x, y, se1->ibuf->rect, se2->ibuf->rect, se->ibuf->rect);
break;
case SEQ_PLUGIN:
if(seq->plugin && seq->plugin->doit) {