RE: changing a model's color at runtime

New Message Reply Date view Thread view Subject view Author view

From: Paul Duncan (paulduncan++at++thehfegroup.com)
Date: 02/20/2001 06:36:36


Thanks Mario and Ulrich that solved the problem.

-----Original Message-----
From: Mario Veraart [mailto:Veraart++at++fel.tno.nl]
Sent: Tuesday, February 20, 2001 6:27 AM
To: paulduncan++at++thehfegroup.com
Cc: Info Performer
Subject: Re: changing a model's color at runtime

Paul Duncan wrote:
>
> 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);

This line is the wrong place
colors is not assigned a value
>
> gset = pfGetGSet((pfGeode *)node, j);
> pfGetGSetAttrLists(gset, PFGS_COLOR4, (void
**)&colors, &icolors);
Here would be a better place

Mario
>
> 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


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Feb 20 2001 - 06:42:58 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.