From: Paul Duncan (paulduncan++at++thehfegroup.com)
Date: 02/14/2001 08:40:50
Hi,
I'm modifying the color of models at runtime by traversing through the model
tree until I get to a node and then setting the node 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;
}
}
}
}
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 : Wed Feb 14 2001 - 08:46:29 PST