[SESI logo]

Prisms Development Toolkit Documentation

Side Effects Software Inc. 1997

Custom SOPs

Creating and Modifying Geometry

sopCook is the heart of the SOP code. It is here that the pdp (poly detail pointer) is created, that is, set to point to some output geometry.

Source Listing


#include <custom.h>			/* you must have this! */

.
.	omitted SOP code
.

static void
sopCook(SOP *sop)
{
    SOP_DATA	*sb;
    OBJECT	*obp;
    char	*expanded;
    int		 idx;
    PolyDetail	*sourcePdp;
    PolyPointPointer	tmppt;
    int		npts;

    
    /* first, some housekeeping */
    sb = (SOP_DATA *)sop->special;
    if (sop->pdp) 
	FreePolyDetail(sop->pdp);
    sop->pdp = 0;

    /* Then read in any source geometry */
    GETSOURCE(sourcePdp, sop, 0, "Invalid source SOP");

    /* Always copy the input and modify the copy, never the source */
    sop->pdp = PolyCopyDetail(sourcePdp);

    /* Next, use either EVALUATE or EVALUATEV to get the values of
       the SOP input fields */
    EVALUATELV(sop, sb->Single);

    /*
     *	There are macros used to traverse lists. Here, we multiply each
     *	point's (x,y,z) values by 0.5. You will probably do something
     * 	more useful.
     */
    FOR_ALL_POINTS(sop->pdp->ppt, tmppt, npts)
    {
	tmppt->pos.x *= 0.5;
	tmppt->pos.y *= 0.5;
	tmppt->pos.z *= 0.5;
    }

    /* here is another macro to clear the normals of the SOP data */
    CLEARSOPNML(sop)
    
}

For More Detailed Information:

There are dozens of macros and subroutines available to the graphics programmer in action. The best approach to using them is to see if they are used in the example SOPs provided, and copy that usage. If not, there are several reference sections in this documentation. You can look in:

Macros available to the programmer
Subroutines available


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