Browse Source

add egg-list-textures

David Rose 20 years ago
parent
commit
ae3fa2320d

+ 3 - 0
pandatool/src/eggbase/eggReader.cxx

@@ -59,6 +59,9 @@ EggReader() {
 
   _tex_type = (PNMFileType *)NULL;
   _delod = -1.0;
+
+  _got_tex_dirname = false;
+  _got_tex_extension = false;
 }
 
 ////////////////////////////////////////////////////////////////////

+ 8 - 0
pandatool/src/eggprogs/Sources.pp

@@ -72,3 +72,11 @@
     eggToC.cxx eggToC.h
 
 #end bin_target
+
+#begin bin_target
+  #define TARGET egg-list-textures
+
+  #define SOURCES \
+    eggListTextures.cxx eggListTextures.h
+
+#end bin_target

+ 73 - 0
pandatool/src/eggprogs/eggListTextures.cxx

@@ -0,0 +1,73 @@
+// Filename: eggListTextures.cxx
+// Created by:  drose (23May05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "eggListTextures.h"
+#include "eggTextureCollection.h"
+#include "pnmImageHeader.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggListTextures::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+EggListTextures::
+EggListTextures() {
+  set_program_description
+    ("egg-list-textures reads an egg file and writes a list of the "
+     "textures it references.  It is particularly useful for building "
+     "up the textures.txa file used for egg-palettize, since the output "
+     "format is crafted to be compatible with that file's input format.");
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggListTextures::run
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+void EggListTextures::
+run() {
+  if (!do_reader_options()) {
+    exit(1);
+  }
+
+  EggTextureCollection tc;
+  tc.find_used_textures(_data);
+  EggTextureCollection::TextureReplacement treplace;
+  tc.collapse_equivalent_textures(EggTexture::E_complete_filename, treplace);
+  tc.sort_by_basename();
+
+  EggTextureCollection::iterator ti;
+  for (ti = tc.begin(); ti != tc.end(); ++ti) {
+    Filename fullpath = (*ti)->get_fullpath();
+    PNMImageHeader header;
+    if (header.read_header(fullpath)) {
+      cout << fullpath.get_basename() << " : "
+           << header.get_x_size() << " " << header.get_y_size() << "\n";
+    } else {
+      cout << fullpath.get_basename() << " : unknown\n";
+    }
+  }
+}
+
+
+int main(int argc, char *argv[]) {
+  EggListTextures prog;
+  prog.parse_command_line(argc, argv);
+  prog.run();
+  return 0;
+}

+ 39 - 0
pandatool/src/eggprogs/eggListTextures.h

@@ -0,0 +1,39 @@
+// Filename: eggListTextures.h
+// Created by:  drose (23May05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef EGGLISTTEXTURES_H
+#define EGGLISTTEXTURES_H
+
+#include "pandatoolbase.h"
+
+#include "eggReader.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : EggListTextures
+// Description : Reads an egg file and outputs the list of textures it
+//               uses.
+////////////////////////////////////////////////////////////////////
+class EggListTextures : public EggReader {
+public:
+  EggListTextures();
+
+  void run();
+};
+
+#endif
+