From: Paul Duncan (paulduncan++at++thehfegroup.com)
Date: 02/19/2001 12:49:15
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
This archive was generated by hypermail 2b29 : Mon Feb 19 2001 - 12:54:23 PST