Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/egg/eggUtilities.cxx

Go to the documentation of this file.
00001 // Filename: eggUtilities.cxx
00002 // Created by:  drose (28Jan99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "eggUtilities.h"
00020 #include "eggPrimitive.h"
00021 #include "eggGroupNode.h"
00022 
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: get_textures_by_filename
00026 //  Description: Extracts from the egg subgraph beginning at the
00027 //               indicated node a set of all the texture objects
00028 //               referenced, grouped together by filename.  Texture
00029 //               objects that share a common filename (but possibly
00030 //               differ in other properties) are returned together in
00031 //               the same element of the map.
00032 ////////////////////////////////////////////////////////////////////
00033 void
00034 get_textures_by_filename(const EggNode *node, EggTextureFilenames &result) {
00035   if (node->is_of_type(EggPrimitive::get_class_type())) {
00036     const EggPrimitive *prim = DCAST(EggPrimitive, node);
00037 
00038     if (prim->has_texture()) {
00039       PT(EggTexture) tex = prim->get_texture();
00040       result[tex->get_filename()].insert(tex);
00041     }
00042 
00043   } else if (node->is_of_type(EggGroupNode::get_class_type())) {
00044     const EggGroupNode *group = DCAST(EggGroupNode, node);
00045 
00046     EggGroupNode::const_iterator ci;
00047     for (ci = group->begin(); ci != group->end(); ++ci) {
00048       get_textures_by_filename(*ci, result);
00049     }
00050   }
00051 }
00052 

Generated on Fri May 2 00:38:01 2003 for Panda by doxygen1.3