#IXP programming question
9 messages in this thread
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); }
Hi Greg,
Welcome to the wonderful world of "That ain't quite what they say". I've posted
those same questions a couple of months ago and never got any real explanation
either.
To your first question: No. The frame info you get is for the entire sequence.
The information is redundant. You have to ask the user the number of frames the
process will work for and the starting frame.
To your second question: All stuff related to field mode is undocumented. Your
best bet is to download the stuff Gary (Yost) uploaded here. There you will
find example source of IXP's making use of the new structure items handling
field mode.
To your third question: String gadgets are pretty sensitive to the info you
provide. This is a nightmare. The definition of the structure is backwards
(where you define the length and how much you want displayed). The limits (as
to how long they can be) appear to be rather random. My best luck was trial and
error untill I managed to get a set of string gadgets that wouldn't "reboot"
the system. It's also very importand to understand how to send back to 3DS the
variable length. This is done in ClientVarSize(). Make sure the string is
rounded of to a 4 bytes boundary (you have it as 13 bytes long).
In your code, I noticed a couple of strange things. I have to say I haven't had
much time to study it in detail but here is what I found:
In your State structure initialization, you set the colors to float values. The
elements (r,g,and b) are unsigned char. You also define "length" to be of type
"long" but fail to tell 3DS about it in ClientVarSize(). Remember that a long
here is 64 bits long.
This is far as I go. Good luck.
Gus,
Thanks for the help. The reason for all the funny stuff in the
ClientVarSize() is that
I used the vblur and stars examples sent with the developer's kit. It didn't
make
any sense, but they sent back 1 in all cases except for strings in which case
they
divided the string length by 4 then multiplied it by 4! Wierd stuff. Maybe
it's that
long. I'll give that a try. Where can I find the file uploaded by Gary?
Thanks again.
– Greg
Try LIB 1 file: IPAS21.ZIP. That's the archive that contains the additions
found in release 2.01. Just browse LIB 1 with IPAS as the search key.
Gus's answers are all pretty right on… the best place to get your questions
answered is from the example code in IPAS21.ZIP in DL1, and from experience.
For information about the Autodesk's IPAS SDK, you'll have to ask Phil
DeGeorge, Bob Prokopp, or Nik Grant… contrary to what Gus wrote in 3D Artist
this month <g>, the IPAS SDK isn't a YG product… it's an Adesk product. It's
all we can do just to keep up with the core 3DS code.
– G
>> contrary to what Gus wrote in 3D Artist >>
this month <g>, the IPAS SDK isn't a YG product… it's an Adesk product
Yep. Yep. Mea culpa, mea culpa. Technical details… <g>
I just wish I was here several months ago to answer my own questions!
Gus (not in Adesk payroll) Grubba
>> I just wish I was here several months ago
to answer my own questions! <<
What a great quote! I hope it's not copyrighted because I'd like to steal it.
<g>
JKJ
Thanks for the help. You said for further IPAS SDK questions I could ask "Phil
DeGeorge, Bob Prokopp, or Nik Grant", where might I be able to reach these
fellows?
Greg,
Phil DeGeorge 71650,2154
Bob Prokopp 75270,1205
Nik Grant 70421,76
They're usually around here on the forum. Give em a holler <g>
Mark K.