Re: HW-texture representation on Impact and Texture detail discussion

New Message Reply Date view Thread view Subject view Author view

Scott McMillan (scott++at++ht.com)
Tue, 21 Jan 1997 17:15:46 -0500 (EST)


This discussion reminds me of one of my posts back in September. You can run
it on any part of a scene graph rooted by the node passed as the argument
(at least that is the way it worked the last time I checked :).

---------------------------------------------------------------------

Below is a recursive function (an extension of Dwight's post) that
traverses the scene graph below a node specified by the argument, and
replaces all Textures specified to the 32bit (RGBA_8) format. Note
this problem also occurs with the obj and pfb loaders.

Also note that many times in my apps, multiple GeoSets share the same
texture. This function will just set the same Texture multiple times.
Since I only do this once during initialization, I don't care about
efficiency.

scott

void upgradeTextures(pfNode *node)
{
   if (node->isOfType(pfGroup::getClassType()))
   {
      for (int i=0; i<((pfGroup *) node)->getNumChildren(); i++)
      {
         upgradeTextures(((pfGroup *) node)->getChild(i));
      }
   }
   else if (node->isOfType(pfGeode::getClassType()))
   {
      // okay...I have found a Geode now access the Texture, if present

      pfGeode *gnode = (pfGeode *)node;
      pfGeoSet *gset = gnode->getGSet(0);

      if (gset)
      {
         pfGeoState* gstate = gset->getGState();

         if (gstate)
         {
            pfTexture *tex =
               (pfTexture *) gstate->getAttr(PFSTATE_TEXTURE);

            if (tex)
            {
               // You probably should access the existing format and make a
               // decision about what to change it to here. This is how you
               // access the existing format:
               // int old_format = tex->getFormat(PFTEX_INTERNAL_FORMAT);

               tex->setFormat(PFTEX_INTERNAL_FORMAT, PFTEX_RGBA_8);
            }
         }
      }
   }
}

---------------------------------------------------------------------

-- 
  Scott McMillan  |       HT Medical, Inc.      | Developing virtual environ-
   scott++at++ht.com   |      http://www.ht.com      | ment medical and surgical
 Ph: 301-984-3706 | 6001 Montrose Rd., Ste. 902 | simulations and surgery
Fax: 301-984-2104 |     Rockville, MD 20852     | simulation creation tools.

======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:25 PDT

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