33 set_program_brief(
"describe the contents of .bam files");
34 set_program_description
35 (
"This program scans one or more Bam files--Panda's Binary Animation " 36 "and Models native binary format--and describes their contents.");
39 add_runline(
"[opts] input.bam [input.bam ... ]");
43 "List the scene graph hierarchy in the bam file.",
44 &BamInfo::dispatch_none, &_ls);
48 "List explicitly each transition in the hierarchy.",
49 &BamInfo::dispatch_none, &_verbose_transitions);
53 "Output verbose information about the each Geom in the Bam file.",
54 &BamInfo::dispatch_none, &_verbose_geoms);
56 _num_scene_graphs = 0;
67 Filenames::const_iterator fi;
68 for (fi = _filenames.begin(); fi != _filenames.end(); ++fi) {
74 if (_num_scene_graphs > 0) {
75 nout <<
"\nScene graph statistics:\n";
76 _analyzer.
write(nout, 2);
93 nout <<
"You must specify the Bam file(s) to read on the command line.\n";
97 ProgramBase::Args::const_iterator ai;
98 for (ai = args.begin(); ai != args.end(); ++ai) {
99 _filenames.push_back(*ai);
111 get_info(
const Filename &filename) {
115 nout <<
"Unable to read.\n";
119 const char *endian =
"little-endian";
121 endian =
"big-endian";
123 int float_width = 32;
130 <<
", " << endian <<
", " << float_width <<
"-bit floats.\n";
135 if (
object !=
nullptr &&
145 while (
object !=
nullptr || !bam_file.
is_eof()) {
146 if (
object !=
nullptr) {
147 objects.push_back(
object);
152 nout <<
"Unable to fully resolve file.\n";
159 if (objects.size() == 1 &&
160 objects[0]->is_of_type(PandaNode::get_class_type())) {
161 describe_scene_graph(DCAST(
PandaNode, objects[0]));
163 }
else if (objects.size() == 1 &&
164 objects[0]->is_of_type(Texture::get_class_type())) {
165 describe_texture(DCAST(
Texture, objects[0]));
167 }
else if (objects.size() == 1 &&
168 objects[0]->is_of_type(BamCacheIndex::get_class_type())) {
171 }
else if (!objects.empty() && objects[0]->is_of_type(RecorderHeader::get_class_type())) {
175 nout <<
"file contains " << objects.size() <<
" objects:\n";
176 for (
int i = 0; i < (int)objects.size(); i++) {
177 describe_general_object(objects[i]);
197 root->add_child(node);
200 int num_nodes = _analyzer.get_num_nodes();
202 num_nodes = _analyzer.get_num_nodes() - num_nodes;
204 nout <<
" " << num_nodes <<
" nodes, bounding volume is " 205 << *root->get_bounds() <<
"\n";
207 if (_ls || _verbose_geoms || _verbose_transitions) {
208 list_hierarchy(node, 0);
216 describe_texture(
Texture *tex) {
225 index->write(nout, 2);
233 char time_buffer[1024];
234 strftime(time_buffer, 1024,
"%c",
235 localtime(&header->_start_time));
238 double last_timestamp = 0.0;
240 for (
size_t i = 1; i < objects.size(); i++) {
241 if (objects[i]->is_of_type(RecorderFrame::get_class_type())) {
243 if (frame->_table_changed) {
244 RecorderTable::Recorders::const_iterator ri;
245 for (ri = frame->_table->_recorders.begin();
246 ri != frame->_table->_recorders.end();
248 recorders.insert((*ri).first);
251 last_timestamp = frame->_timestamp;
255 nout <<
"Session, " << last_timestamp
256 <<
" secs, " << objects.size() - 1 <<
" frames, " 257 << time_buffer <<
".\n" 260 ni != recorders.end();
262 nout <<
" " << (*ni);
274 nassertv(
object !=
nullptr);
275 nout <<
" " <<
object->get_type() <<
"\n";
282 list_hierarchy(
PandaNode *node,
int indent_level) {
283 indent(nout, indent_level) << *node;
285 if (_verbose_transitions) {
287 if (!node->get_transform()->is_identity()) {
288 node->get_transform()->write(nout, indent_level);
290 if (!node->get_state()->is_empty()) {
291 node->get_state()->write(nout, indent_level);
293 if (!node->get_effects()->is_empty()) {
294 node->get_effects()->write(nout, indent_level);
298 if (!node->get_transform()->is_identity()) {
299 nout <<
" " << *node->get_transform();
301 if (!node->get_state()->is_empty()) {
302 nout <<
" " << *node->get_state();
304 if (!node->get_effects()->is_empty()) {
305 nout <<
" " << *node->get_effects();
312 DCAST_INTO_V(geom_node, node);
317 for (
int i = 0; i < num_children; i++) {
319 list_hierarchy(child, indent_level + 2);
323 int main(
int argc,
char *argv[]) {
void write(std::ostream &out, int indent_level=0) const
Describes all the data collected.
The principle public interface to reading and writing Bam disk files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
bool open_read(const Filename &bam_filename, bool report_errors=true)
Attempts to open the indicated filename for reading.
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
bool resolve()
This must be called after one or more objects have been read via calls to read_object() in order to r...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
int get_file_major_ver()
Returns the major version number of the file currently being read, or the system current major versio...
void add_node(PandaNode *node)
Adds a new node to the set of data for analysis.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_file_stdfloat_double
Returns true if the file stores all "standard" floats as 64-bit doubles, or false if they are 32-bit ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
This represents the in-memory index that records the list of files stored in the BamCache.
get_num_children
Returns the number of child nodes this node has.
bool is_eof() const
Returns true if the reader has reached end-of-file, false otherwise.
void write_verbose(std::ostream &out, int indent_level) const
Writes a detailed description of all the Geoms in the node.
The name of a file, such as a texture file or an Egg file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_file_endian
Returns the endian preference indicated by the Bam file currently being read or written.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object represents one frame of data in the recorded session file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_child
Returns the nth child node of this node.
virtual bool is_geom_node() const
A simple downcast check.
int get_file_minor_ver()
Returns the minor version number of the file currently being read, or the system current minor versio...
TypedWritable * read_object()
Reads and returns the next object from the Bam file, or NULL if the end of the file has been reached,...
A node that holds Geom objects, renderable pieces of geometry.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool write(const Filename &fullpath)
Writes the texture to the named filename.