From: Eric S. Hirschorn (eric++at++spiffy.paradigmsim.com)
Date: 03/06/2000 09:57:10
> Hi,
>
> I have a model added to my scene that I clone when needed. Now I want to
> add a different colour version of the same model. A quick fix was to
> just re-colour the model at the modelling stage, but I think that the
> same job can be accomplished in the draw callback. Can it be done? Could
> I just draw all the white polygons at a specific part of the scene
> database in red, then carry on drawing with the model's original colour
> afterwards?
>
> thanks,
> Andy
Here's a snippet I posted way back in 1995 to change the color of a .flt
object by modifying pfMaterial info using DRAW callbacks. A few people
have found it of use since then.
Hope it helps,
Eric
------------------------------------
/* read in flt file */
root = (pfGroup *)LoadFile(DatabaseFiles[i], NULL);
/* grab pointer to shared memory */
arena = pfGetSharedArena();
/* define new material in shared memory */
planeMtl = pfNewMtl(arena);
/* modify material emissivity */
pfMtlColor(planeMtl, PFMTL_AMBIENT, 0.10f, 0.15f, 0.11f);
pfMtlColor(planeMtl, PFMTL_DIFFUSE, 0.25f, 0.30f, 0.25f);
pfMtlColor(planeMtl, PFMTL_SPECULAR, 0.20f, 0.20f, 0.20f);
pfMtlColor(planeMtl, PFMTL_EMISSION, 0.00f, 0.00f, 0.00f);
/* set up pre- and post- draw callbacks */
pfNodeTravFuncs((pfNode *)root, PFTRAV_DRAW,
planePreCallback, planePostCallback);
/* pass material planeMtl into the draw callbacks */
pfNodeTravData((pfNode *)root, PFTRAV_DRAW, (void *)planeMtl);
------------------------------------
and the draw callbacks:
/* Change material properties just before drawing */
long
planePreCallback(pfTraverser *trav, void *data)
{
pfPushState();
pfMtlColorMode((pfMaterial *)data, PFMTL_FRONT, PFMTL_CMODE_COLOR);
pfApplyMtl((pfMaterial *)data);
pfOverride(PFSTATE_FRONTMTL, PF_ON);
return PFTRAV_CONT;
}
/*
Reset material properties after the draw
so no other object is affected
*/
long
planePostCallback(pfTraverser *trav, void *data)
{
pfOverride(PFSTATE_FRONTMTL, PF_OFF);
pfPopState();
return PFTRAV_CONT;
}
-- Eric S. Hirschorn Multigen-Paradigm, Inc. 972-960-2301 x264 (VMail) http://www.paradigmsim.com 972-960-9049 (FAX) 14900 Landmark Blvd., Suite 400 eric++at++paradigmsim.com Dallas, Texas 75240 USA
attached mail follows:
Tammy,
Here's a snippet I posted way back in 1995 to change the color of a .flt object by modifying pfMaterial info using DRAW callbacks.
Hope it helps,
Eric
> ------------------------------------ > > /* read in flt file */ > root = (pfGroup *)LoadFile(DatabaseFiles[i], NULL); > > /* grab pointer to shared memory */ > arena = pfGetSharedArena(); > /* define new material in shared memory */ > planeMtl = pfNewMtl(arena); > > /* modify material emissivity */ > pfMtlColor(planeMtl, PFMTL_AMBIENT, 0.10f, 0.15f, 0.11f); > pfMtlColor(planeMtl, PFMTL_DIFFUSE, 0.25f, 0.30f, 0.25f); > pfMtlColor(planeMtl, PFMTL_SPECULAR, 0.20f, 0.20f, 0.20f); > pfMtlColor(planeMtl, PFMTL_EMISSION, 0.00f, 0.00f, 0.00f); > > /* set up pre- and post- draw callbacks */ > pfNodeTravFuncs((pfNode *)root, PFTRAV_DRAW, > planePreCallback, planePostCallback); > /* pass material planeMtl into the draw callbacks */ > pfNodeTravData((pfNode *)root, PFTRAV_DRAW, (void *)planeMtl); > > ------------------------------------ > > and the draw callbacks: > > > > /* Change material properties just before drawing */ > long > planePreCallback(pfTraverser *trav, void *data) > { > > pfPushState(); > > pfMtlColorMode((pfMaterial *)data, PFMTL_FRONT, PFMTL_CMODE_COLOR); > > pfApplyMtl((pfMaterial *)data); > pfOverride(PFSTATE_FRONTMTL, PF_ON); > > return PFTRAV_CONT; > } > > > /* > Reset material properties after the draw > so no other object is affected > */ > long > planePostCallback(pfTraverser *trav, void *data) > { > pfOverride(PFSTATE_FRONTMTL, PF_OFF); > > pfPopState(); > > return PFTRAV_CONT; > } > > ----------------------------------------- > >
tmartin++at++metricsys.com wrote: > > We our doing a port of our application from OpenGVS to Performer. We need > to import MultiGen models of aircraft in our Performer application. The > users like to color code these models dynamically. That is the users choose > the color of the aircraft from the application code. The aircraft models > have 3 LODs the highest level having texture, the 2 lower levels are > untextured models. The untextured models need to change color the textured > models should not. In the current OpenGVS application we put the comment > #ignore_color in the LOD bead, (LOD attribute dialog box under comments or > attribute extensions) in MultiGen and use a glColor call in a draw callback > on the model in OpenGVS to change the color to what the user has selected. > In Performer, when I use a glColor call in a draw callback on that > aircraft model the color will not change. So I was wondering if you know > the appropriate way to change the color of the aircraft dynamically? > Any help you can provide is greatly appreciated. > Thanks. > Tammy C. Martin > tmartin++at++metricsys.com > Metric Systems Corporation > 749 N.W. Beal Parkway > Fort Walton Beach, Florida 32547-3076 > 850-302-3785 > > ======================================================================= > List Archives, FAQ, FTP: http://www.sgi.com/software/performer/ > Submissions: info-performer++at++sgi.com > Admin. requests: info-performer-request++at++sgi.com
-- Eric S. Hirschorn Multigen-Paradigm, Inc. 972-960-2301 x264 (VMail) http://www.paradigmsim.com 972-960-9049 (FAX) 14900 Landmark Blvd., Suite 400 eric++at++paradigmsim.com Dallas, Texas 75240 USA
This archive was generated by hypermail 2b29 : Mon Mar 06 2000 - 09:45:25 PST