From: Alexandre Naaman (naaman++at++laplace.engr.sgi.com)
Date: 02/20/2001 07:15:14
On Mon, 19 Feb 2001, Paul Duncan wrote:
Hi Paul,
In your code you are assuming the color for the primitives has been
specified in a PFGS_PER_VERTEX, PFGS_OVERALL or PFGS_PER_PRIM fashion.
This may not be the case ... (PFGS_OFF)
You may want to fetch the geostate associated with the geoset and check
it's properties (pfGeoState::getAttr() called with PFSTATE_FRONTMTL and
PFSTATE_BACKMTL as attr) as well.
Last but not least, you are doing a pfGetSize() on a ptr before actually
calling pfGetGSetAttrLists() !!! (BTW, I normally use
pfGeoSet::getAttrRange() to figure out the # of elements in an array of
attrs) Unitialized variable. Bad.
A+,
Alex.
> Hi,
>
> I'm reposting this since I didn't get any responses last time and I haven't
> found a solution yet.
>
> I'm modifying the color of models at runtime by traversing through the model
> tree until I get to a node (ofGeodeClassType) and then setting the
> node(Geode) to the color I want.
> This works fine for simple models, but for more complex ones with multiple
> LOD's and such the behavior is odd. Some models have one LOD of many
> modified, others all but one and others cause it to crash.
>
> The code looks like this:
>
> void modifyModelColor(pfNode *node, float brightLevel)
> {
> int i, k, j;
>
> if (pfIsOfType(node, pfGetGroupClassType()))
> {
> for ( i=0; i<(pfGetNumChildren(node)); ++i)
> {
> modifyModelColor(pfGetChild((pfGroup *)node,i), brightLevel);
> }
> }
>
> if (pfIsOfType(node, pfGetGeodeClassType()))
> {
> for ( j=0; j < pfGetNumGSets(node); ++j)
> {
> pfGeoSet *gset;
> pfVec4 *colors;
> ushort *icolors;
> int numcolors = pfGetSize(colors)/sizeof(pfVec4);
>
> gset = pfGetGSet((pfGeode *)node, j);
> pfGetGSetAttrLists(gset, PFGS_COLOR4, (void **)&colors, &icolors);
>
> for (k=0; k<numcolors; ++k)
> {
> /* Here we modify the color element of each
> vertex that we encounter */
>
> colors[k][0] = brightLevel;
> colors[k][1] = brightLevel;
> colors[k][2] = brightLevel;
>
> }
> }
> }
> }
>
> Is this a feasible way of doing this?
> Do I have to set the traversal mode?
> What am I doing wrong?
>
> Any help would be appreciated.
>
> Thanks Paul
>
> Paul Duncan
> The HFE Group
> 220 Laurier Ave. W, Suite 350
> (613) 230-8226
> paulduncan++at++thehfegroup.com
>
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>
This archive was generated by hypermail 2b29 : Tue Feb 20 2001 - 07:15:19 PST