#IXP programming question
Yost Group:
I have several IXP questions. On page C-22 of the 3D Studio Reference
Manual under "IXP Processes" you state that frame ranges will be accessible
to the IXP process – "Current Frame range alloted to this process in the
Keyframer and the Video Post dialog box." I assume you were refering
to the FrameInfo structure. My experience has shown that I DO NOT have
access to any frame range information. This is what I've found to be
true :
FrameInfo.fnum = the current frame number being processed
FrameInfo.animlength = the total KF Scene length in frames
FrameInfo.start = starting frame to be rendered
FrameInfo.end = Video Post length in frames
I assumed when reading the 3D Studio Manual that the last two would
reference the current frame range the IXP is active on. I would like
to be able to know what frame range my IXP is active as I am writing some
transition effects between layers and need to know the length in order to
interpolate the images correctly. I'd rather not have to ask the user
in "Setup" how long the IXP is active if I am able to get it from 3DS.
Is this a bug? Has anyone else experienced this problem? My setup
includes : Metaware 3.04, PharLap 5.0, 3DS 2.01a.
Another question I have is in regard to "field-rendering mode." On page
13 of the IPAS toolkit Reference Guide, you state that I should look
to the 3D Studio Reference and Installation Guides for more info on
writing IXPs in "field-rendering mode." I searched both manuals but
could find no reference to fields in regards to writing IXPs. I would
assume that it'd be something as simple as a flag letting me know that
"field-rendering mode" was on, then it'd be up to me to handle the image
correctly. Is there some example code I could get ahold of? Vblur.ixp
and stars.ixp make no reference to fields.
Ok, now for the last question. I can't seem to get two string fields to
work correctly in a dialog. I've used MDB.EXE to trace through the code,
after I hit the "OK" button, when execution passes to ClientSetStateVar()
and id == STOP_IMAGE, guess what? The variable s is empty, therefore
state.stop_image never gets set to anything. In addition, the structure
state.stop_color is usually mangled when I try to change state.stop_image.
I also tried different return values in ClientVarSize() to no avail.
Very frustrating. I must be doing something incredibly stupid. Here's
the code.
– Greg Chard
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h>
#include "ixp.h" #define VERSION 0x0F45DE #define TRANS_LEN 1
#define START_TYPE 2 #define STOP_TYPE 3 #define START_IMAGE 4
#define STOP_IMAGE 5 #define START_COLOR 6 #define STOP_COLOR 7
/* Typedefs */ typedef struct {
ulong version;
long length;
int start_type;
int stop_type;
char start_image[13];
char stop_image[13];
Color_24 start_color;
Color_24 stop_color; } State;
/* Variables */ static Color_24 _far *inpix; static Color_24 _far *outpix;
static Color_24 *buf = 0;
static int dev_width; static int dev_height; static int iy = 0;
static State init_state =
{VERSION,30,0,0,"FILENAME.EXT","FILENAME.EXT",{0.0,0.0,0.0},{0.0,0.0,0.0}};
static State state =
{VERSION,30,0,0,"FILENAME.EXT","FILENAME.EXT",{0.0,0.0,0.0},{0.0,0.0,0.0}};
DlgEntry cdialog[]= {
0,"TITLE=\"3D Studio Fade Transition Effect\"",
0,"TITLE=\"\"",
TRANS_LEN,"LINT=\"Transition Length : \",0,32000,6",
0,"TITLE=\"\"",
START_TYPE,"RADIO=\" Start Type : \",\"Layer\",\"Color\",\"Bitmap\"",
STOP_TYPE,"RADIO=\" Stop Type : \",\"Layer\",\"Color\",\"Bitmap\"",
0,"TITLE=\"\"",
START_COLOR,"COLOR=\" Start Color\"",
START_IMAGE,"-FILENAME=\"Start Image :\"",
STOP_COLOR,"COLOR=\" Stop Color \"",
STOP_IMAGE,"-FILENAME=\"Stop Image :\"",
0,"TITLE=\"\"",
0,NULL };
/* Function prototypes */ void freebufs(); void getline(int, Color_24 *); void
putline(int, Color_24 *);
/* IPAS functions */ int ClientProcImage(FrameParm *fp,
FrameInfo *fi,
int phase,
Report *rpt) {
int i;
int ix;
Color_24 pixel;
Color_24 start_pixel;
Color_24 stop_pixel;
float prog = 0.0;
char str[50];
switch(phase)
{
case PHASE_START : iy = 0;
dev_width= fp->dev_width;
dev_height=fp->dev_height;
inpix = fp->inpix;
outpix = fp->outpix;
buf = (Color_24 *)malloc(dev_width*sizeof(Color_24));
if(buf == NULL)
{
freebufs();
return(IXP_ERROR);
}
break;
case PHASE_CONTINUE : getline(iy,buf);
putline(iy,buf);
if(++iy >= dev_height)
{
freebufs();
return(IXP_EXIT);
}
break;
}
strcpy(rpt->title,"Fading Image");
rpt->max=dev_height;
rpt->current=iy;
rpt->recall_state = PHASE_CONTINUE;
return(IXP_REPORT); }
int ClientVarSize(int id) {
switch(id)
{
case START_IMAGE :
case STOP_IMAGE : return(4);
default : return(1);
} }
void ClientSetStateVar(int id,
void *ptr) {
OVL o;
ulong *ul;
char *s;
ul=(ulong *)ptr;
s=(char *)ptr;
o.ul = *ul;
switch(id)
{
case TRANS_LEN : state.length = o.l;
break;
case START_TYPE : state.start_type = o.i;
break;
case STOP_TYPE : state.stop_type = o.i;
break;
case START_IMAGE : strcpy(state.start_image,s);
break;
case STOP_IMAGE : strcpy(state.stop_image,s);
break;
case START_COLOR : state.start_color.r = o.c.r;
state.start_color.g = o.c.g;
state.start_color.b = o.c.b;
break;
case STOP_COLOR : state.stop_color.r = o.c.r;
state.stop_color.g = o.c.g;
state.stop_color.b = o.c.b;
break;
} }
ulong ClientGetStateVar(int id) {
OVL o;
switch(id)
{
case TRANS_LEN : o.l = state.length;
break;
case START_TYPE : o.i = state.start_type;
break;
case STOP_TYPE : o.i = state.stop_type;
break;
case START_IMAGE : o.s = state.start_image;
break;
case STOP_IMAGE : o.s = state.stop_image;
break;
case START_COLOR : o.c.r = state.start_color.r;
o.c.g = state.start_color.g;
o.c.b = state.start_color.b;
break;
case STOP_COLOR : o.c.r = state.stop_color.r;
o.c.g = state.stop_color.g;
o.c.b = state.stop_color.b;
break;
}
return(o.ul); }
char *ClientGetState(int *size) {
*size = sizeof(State);
return((char *)&state); }
void ClientResetState() {
state = init_state; }
void ClientStartup(void) { }
void ClientTerminate(void) {
freebufs(); }
DlgEntry *ClientDialog(int n) {
return(&cdialog[n]); }
char *ClientName(void) {
return("FADE.IXP"); }
/* IPAS specific "user" functions */ void freebufs() {
if(buf != NULL)
free(buf);
buf = 0; }
void getline(int y, Color_24 *buf) {
far_to_near(buf,&inpix[y*dev_width],dev_width*3); }
void putline(int y, Color_24 *buf) {
near_to_far(&outpix[y*dev_width],buf,dev_width*3); }