Panda3D
 All Classes Functions Variables Enumerations
sceneGraphAnalyzer.h
1 // Filename: sceneGraphAnalyzer.h
2 // Created by: drose (02Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef SCENEGRAPHANALYZER_H
16 #define SCENEGRAPHANALYZER_H
17 
18 #include "pandabase.h"
19 #include "typedObject.h"
20 #include "luse.h"
21 #include "pmap.h"
22 #include "pset.h"
23 #include "bitArray.h"
24 #include "indirectCompareTo.h"
25 
26 class PandaNode;
27 class GeomNode;
28 class Geom;
29 class GeomVertexData;
30 class GeomVertexFormat;
32 class Texture;
33 
34 ////////////////////////////////////////////////////////////////////
35 // Class : SceneGraphAnalyzer
36 // Description : A handy class that can scrub over a scene graph and
37 // collect interesting statistics on it.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_PGRAPHNODES SceneGraphAnalyzer {
40 PUBLISHED:
43 
44  enum LodMode {
45  LM_lowest,
46  LM_highest,
47  LM_all,
48  LM_none,
49  };
50 
51  INLINE void set_lod_mode(LodMode lod_mode);
52  INLINE LodMode get_lod_mode(LodMode lod_mode) const;
53 
54  void clear();
55  void add_node(PandaNode *node);
56 
57  void write(ostream &out, int indent_level = 0) const;
58 
59  INLINE int get_num_nodes() const;
60  INLINE int get_num_instances() const;
61  INLINE int get_num_transforms() const;
62  INLINE int get_num_nodes_with_attribs() const;
63  INLINE int get_num_lod_nodes() const;
64  INLINE int get_num_geom_nodes() const;
65  INLINE int get_num_geoms() const;
66  INLINE int get_num_geom_vertex_datas() const;
67  INLINE int get_num_geom_vertex_formats() const;
68  INLINE int get_vertex_data_size() const;
69 
70  INLINE int get_num_vertices() const;
71  INLINE int get_num_normals() const;
72  INLINE int get_num_colors() const;
73  INLINE int get_num_texcoords() const;
74  INLINE int get_num_tris() const;
75  INLINE int get_num_lines() const;
76  INLINE int get_num_points() const;
77  INLINE int get_num_patches() const;
78 
79  INLINE int get_num_individual_tris() const;
80  INLINE int get_num_tristrips() const;
81  INLINE int get_num_triangles_in_strips() const;
82  INLINE int get_num_trifans() const;
83  INLINE int get_num_triangles_in_fans() const;
84  INLINE int get_num_vertices_in_patches() const;
85 
86  INLINE int get_texture_bytes() const;
87 
88  INLINE int get_num_long_normals() const;
89  INLINE int get_num_short_normals() const;
90  INLINE PN_stdfloat get_total_normal_length() const;
91 
92 private:
93  void collect_statistics(PandaNode *node, bool under_instance);
94  void collect_statistics(GeomNode *geom_node);
95  void collect_statistics(const Geom *geom);
96  void collect_statistics(Texture *texture);
97  void collect_statistics(const GeomVertexArrayData *vadata);
98  void collect_prim_statistics(const GeomVertexArrayData *vadata);
99 
100  class VDataTracker {
101  public:
102  BitArray _referenced_vertices;
103  };
104 
112 
113  LodMode _lod_mode;
114 
115  Nodes _nodes;
116  VDatas _vdatas;
117  VFormats _vformats;
118  VADatas _vadatas;
119  VADatas _prim_vadatas;
120  UniqueVDatas _unique_vdatas;
121  UniqueVADatas _unique_vadatas;
122  UniqueVADatas _unique_prim_vadatas;
123  Textures _textures;
124 
125 private:
126  int _num_nodes;
127  int _num_instances;
128  int _num_transforms;
129  int _num_nodes_with_attribs;
130  int _num_lod_nodes;
131  int _num_geom_nodes;
132  int _num_geoms;
133  int _num_geom_vertex_datas;
134  int _num_geom_vertex_formats;
135  size_t _vertex_data_size;
136  size_t _prim_data_size;
137 
138  int _num_vertices;
139  int _num_vertices_64;
140  int _num_normals;
141  int _num_colors;
142  int _num_texcoords;
143  int _num_tris;
144  int _num_lines;
145  int _num_points;
146  int _num_patches;
147 
148  int _num_individual_tris;
149  int _num_tristrips;
150  int _num_triangles_in_strips;
151  int _num_trifans;
152  int _num_triangles_in_fans;
153  int _num_vertices_in_patches;
154 
155  int _texture_bytes;
156 
157  int _num_long_normals;
158  int _num_short_normals;
159  PN_stdfloat _total_normal_length;
160 };
161 
162 #include "sceneGraphAnalyzer.I"
163 
164 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
A dynamic array with an unlimited number of bits.
Definition: bitArray.h:42
A handy class that can scrub over a scene graph and collect interesting statistics on it...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Definition: geom.h:58
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37
This is the data for one array of a GeomVertexData structure.