Panda3D
eggUtilities.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggUtilities.cxx
10  * @author drose
11  * @date 1999-01-28
12  */
13 
14 #include "eggUtilities.h"
15 #include "eggPrimitive.h"
16 #include "eggGroupNode.h"
17 #include "pt_EggTexture.h"
18 #include "dcast.h"
19 
20 
21 /**
22  * Extracts from the egg subgraph beginning at the indicated node a set of all
23  * the texture objects referenced, grouped together by filename. Texture
24  * objects that share a common filename (but possibly differ in other
25  * properties) are returned together in the same element of the map.
26  */
27 void
29  if (node->is_of_type(EggPrimitive::get_class_type())) {
30  const EggPrimitive *prim = DCAST(EggPrimitive, node);
31 
32  int num_textures = prim->get_num_textures();
33  for (int i = 0; i < num_textures; i++) {
34  PT_EggTexture tex = prim->get_texture(i);
35  result[tex->get_filename()].insert(tex);
36  }
37 
38  } else if (node->is_of_type(EggGroupNode::get_class_type())) {
39  const EggGroupNode *group = DCAST(EggGroupNode, node);
40 
41  EggGroupNode::const_iterator ci;
42  for (ci = group->begin(); ci != group->end(); ++ci) {
43  get_textures_by_filename(*ci, result);
44  }
45  }
46 }
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:36
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition: eggPrimitive.h:49
get_num_textures
Returns the number of textures applied to the primitive.
Definition: eggPrimitive.h:100
get_texture
Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive...
Definition: eggPrimitive.h:100
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:28
This is our own Panda specialization on the default STL map.
Definition: pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void get_textures_by_filename(const EggNode *node, EggTextureFilenames &result)
Extracts from the egg subgraph beginning at the indicated node a set of all the texture objects refer...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.