Gordon Tomlinson (gordon++at++paradigmsim.com)
Tue, 26 Jan 1999 09:37:07 -0600
Hi Simon,
One alternative, would be to write a simple wrapper class
around pfFlux's, then you can have your arguements as properties
of the wrapper class and not global, you can then even template
that wrapper. I do that now and it works fine.
Regards
Gordon.
>
> I can create a fluxed geoset no problem as above, however I wish to pass
> arguments to my fluxed geoset init function to parameterize some the
> dimensions. This is not possible at present and so as a workaround I
> place the arguments in globals and read them in my init function. This
> is not very elegant. I notice that function pfFlux::callDataFunc()
> *does* allow function arguments to be passed. Could this mechanism also
> be implemented for the init function?
>
> To illustrate, this is what I'm doing at present:
>
> /* Globals */
>
> /* only used to pass arguments to fluxed geoset creation callback */
> static int AllocPnt;
> static float Linewidth;
> static int Recolor;
> static pfVec4 Startcol;
> static pfVec4 Endcol;
>
>
> /*************************** C O D E ***************************/
>
> /* Create a fluxed pfGeoSet with correct properties */
>
> static int
> createFluxedGSet(pfFluxMemory *fmem)
> {
> pfGeoSet *gset; /* ptr to geoset */
> pfGeoState *gSt; /* ptr to geostate */
> pfVec3 *verts; /* vertex arrays */
> pfVec4 *colors; /* color array */
> int *lengths; /* primitive length array */
>
> /* "Arguments" - get from globals */
> void *arena = pfGetSharedArena();
> int allocPnt = AllocPnt;
> float linewidth = Linewidth;
> int recolor = Recolor;
> pfVec4 startcol;
> pfVec4 endcol;
> pfCopyVec4(startcol, Startcol);
> pfCopyVec4(endcol, Endcol);
> /* end arguments */
>
> /* If null argument return default size of geoset to create */
> if (fmem == NULL)
> return pfFluxedGSetInit(fmem);
>
> /* Get geoset to create in flux memory */
> pfFluxedGSetInit(fmem);
> gset = (pfGeoSet *) pfGetData(fmem);
>
> /* GeoSet is single linestrip which will grow dynamically */
> pfGSetNumPrims(gset, 1);
> if (recolor)
> pfGSetPrimType(gset, PFGS_LINESTRIPS);
> else
> pfGSetPrimType(gset, PFGS_FLAT_LINESTRIPS);
>
> /* Create array for vertex values of given size */
> verts = (pfVec3 *)pfMalloc(sizeof(pfVec3)*allocPnt, arena);
> pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, verts, NULL);
>
> /* Create array for color values
> * If start and end colours the same only one colour per geoset
> required
> * otherwise a colour per vertex is required
> */
> if (recolor) {
> colors = (pfVec4 *)pfMalloc(sizeof(pfVec4)*allocPnt, arena);
> pfGSetAttr(gset, PFGS_COLOR4, PFGS_PER_VERTEX, colors, NULL);
> }
> else {
> colors = (pfVec4 *)pfMalloc(sizeof(pfVec4), arena);
> pfGSetAttr(gset, PFGS_COLOR4, PFGS_OVERALL, colors, NULL);
> pfCopyVec4(colors[0], startcol);
> }
>
> /* Create array for line length values */
> lengths = (int *)pfMalloc(sizeof(int), arena);
> pfGSetPrimLengths(gset, lengths);
> lengths[0] = 0; /* initially empty! */
>
> /* Set line width */
> pfGSetLineWidth(gset, linewidth);
>
> /* Attach a geostate to the geoset */
> gSt = pfNewGState(arena);
> pfGSetGState(gset, gSt);
>
> /* Transparency required? */
> if (startcol[3] < 1.0f || endcol[3] < 1.0f)
> pfGStateMode(gSt, PFSTATE_TRANSPARENCY, PFTR_ON);
>
> /* Ensure lighting off, texturing off */
> pfGStateMode(gSt, PFSTATE_ENLIGHTING, PF_OFF);
> pfGStateMode(gSt, PFSTATE_ENTEXTURE, PF_OFF);
>
> #ifdef DEBUG
> pfPrint(gset, PFTRAV_SELF, PFPRINT_VB_INFO, NULL);
> #endif
>
> return 0;
> }
-- Gordon Tomlinson | Multigen - Paradigm Inc Vega Software Engineer | Suite 400, 14900 Landmark Blvd Email: gordon++at++paradigmsim.com | Dallas, Texas 75240, USA Tel: 972 960 2301 | Fax: 972 960 2303 ______________________________________________________________'Smoke me a kipper skipper, I'll be back for breakfast' ______________________________________________________________ 640K ought to be enough for anybody. Bill gates 1981 There is no reason anyone would want a computer in their home (Ken Olson, president of Digital Equip Corp 1977 )
This archive was generated by hypermail 2.0b2 on Tue Jan 26 1999 - 07:32:48 PST