Panda3D
|
00001 // Filename: eggListTextures.cxx 00002 // Created by: drose (23May05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "eggListTextures.h" 00016 #include "eggTextureCollection.h" 00017 #include "pnmImageHeader.h" 00018 #include "pystub.h" 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: EggListTextures::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 EggListTextures:: 00026 EggListTextures() { 00027 set_program_description 00028 ("egg-list-textures reads an egg file and writes a list of the " 00029 "textures it references. It is particularly useful for building " 00030 "up the textures.txa file used for egg-palettize, since the output " 00031 "format is crafted to be compatible with that file's input format."); 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: EggListTextures::run 00036 // Access: Public 00037 // Description: 00038 //////////////////////////////////////////////////////////////////// 00039 void EggListTextures:: 00040 run() { 00041 if (!do_reader_options()) { 00042 exit(1); 00043 } 00044 00045 EggTextureCollection tc; 00046 tc.find_used_textures(_data); 00047 EggTextureCollection::TextureReplacement treplace; 00048 tc.collapse_equivalent_textures(EggTexture::E_complete_filename, treplace); 00049 tc.sort_by_basename(); 00050 00051 EggTextureCollection::iterator ti; 00052 for (ti = tc.begin(); ti != tc.end(); ++ti) { 00053 Filename fullpath = (*ti)->get_fullpath(); 00054 PNMImageHeader header; 00055 if (header.read_header(fullpath)) { 00056 cout << fullpath.get_basename() << " : " 00057 << header.get_x_size() << " " << header.get_y_size() << "\n"; 00058 } else { 00059 cout << fullpath.get_basename() << " : unknown\n"; 00060 } 00061 } 00062 } 00063 00064 00065 int main(int argc, char *argv[]) { 00066 // A call to pystub() to force libpystub.so to be linked in. 00067 pystub(); 00068 00069 EggListTextures prog; 00070 prog.parse_command_line(argc, argv); 00071 prog.run(); 00072 return 0; 00073 }