|
Prisms Development Toolkit Documentation
Side Effects Software Inc. 1997
|
Custom SOPs
Setting Up Inputs (if any) to the SOP
SOPs can take no geometric input - these are called Primitive SOPs because
they generate primitives. Examples are circle, ellipsoid, read, etc.
Other SOPs can take one, two or up to six inputs.
More detailed comments follow the listing.
Source Listing:
#include <custom.h> /* you must have this! */
#define NSOURCES 1 /* Takes One Source */
/*
* This function is used when creating a new sop. It sets up the
* initial values of the sop.
*/
static void
sopDefaults(SOP *sop) /* Put in default values */
{
SOP_DATA *sb;
COOKVAR.fval = 0;
if (sop->special) free(sop->special);
sb = (SOP_DATA *)Calloc(sizeof(SOP_DATA), "Sample sopDefaults");
sop->special = (char *)sb;
/* Initialize the SOP source, can be one of:
* SOURCE_NULL SOURCE_PREV
* SOURCE_2BACK SOURCE_FIRST
* SOURCE_LAST SOURCE_DISPLAY
* SOURCE_RENDER SOURCE_MODEL
* SOURCE_LABEL
*/
sop->nsources = NSOURCES;
/* the test means that only new SOPs have their input(s) changed;
renamed existing SOPs are left alone
*/
if (sop->sop[0].type == SOURCE_NULL)
sop->sopin[0].type = SOURCE_PREV;
/*
* the 0 in the above lines matches the 0 in GETSOURCE below
*/
/* then have to do this: */
SopClearSources(sop, sop->nsources);
}
static void
sopCook(SOP *sop) /* Normally this is where you build a PDP */
{
SOP_DATA *sb;
OBJECT *obp;
char *expanded;
int idx;
PolyDetail *sourcePdp;
PolyPointPointer tmppt;
int npts;
sb = (SOP_DATA *)sop->special;
if (sop->pdp) FreePolyDetail(sop->pdp);
sop->pdp = 0;
/*
* GETSOURCE will check that you have a valid source
* and get its pdp
* sourcePdp is a pointer to the retrieved data
* sop is the current sop
* 0 is input index; goes 0, 1, 2, etc for
* subsequent sources
* string for error message if problem
*/
GETSOURCE(sourcePdp, sop, 0, "Invalid source SOP");
/* Always copy the input and modify the copy, never the source */
sop->pdp = PolyCopyDetail(sourcePdp);
}
/*
* This is the string next to the source input line
* Additional sources would simply have additional strings
*/
static char *srclabels[] =
{
"Source"
};
static void
sopGPMake(UI_DBOX *dbp, SOP *sop)
{
InitSopParms(sop);
BuildCommonSopGadgets(sop, NSOURCES, sopParms,
sopHelp, dbp, srclabels);
}
For More Detailed Information:
The sopDefault routine
The sopCook routine
The sopGPMake routine
Tookit Overview
Expression Functions |
User Functions |
Custom SOPs
Prisms Internal Format |
Programmer's Reference
Compiling SOPs |
Using sopbuild |
SOP Routine Reference
Dynamic SOPs |
Prisms Types |
Macros
Math Routines |
Data Routines |
Polygon Routines |
Winged-edge Routines
Copyright © 1997 Side Effects Software Inc.
477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7