|
| 1 | +// Filename: eggListTextures.cxx |
| 2 | +// Created by: drose (23May05) |
| 3 | +// |
| 4 | +//////////////////////////////////////////////////////////////////// |
| 5 | +// |
| 6 | +// PANDA 3D SOFTWARE |
| 7 | +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved |
| 8 | +// |
| 9 | +// All use of this software is subject to the terms of the Panda 3d |
| 10 | +// Software license. You should have received a copy of this license |
| 11 | +// along with this source code; you will also find a current copy of |
| 12 | +// the license at http://etc.cmu.edu/panda3d/docs/license/ . |
| 13 | +// |
| 14 | +// To contact the maintainers of this program write to |
| 15 | +// panda3d-general@lists.sourceforge.net . |
| 16 | +// |
| 17 | +//////////////////////////////////////////////////////////////////// |
| 18 | + |
| 19 | +#include "eggListTextures.h" |
| 20 | +#include "eggTextureCollection.h" |
| 21 | +#include "pnmImageHeader.h" |
| 22 | + |
| 23 | +//////////////////////////////////////////////////////////////////// |
| 24 | +// Function: EggListTextures::Constructor |
| 25 | +// Access: Public |
| 26 | +// Description: |
| 27 | +//////////////////////////////////////////////////////////////////// |
| 28 | +EggListTextures:: |
| 29 | +EggListTextures() { |
| 30 | + set_program_description |
| 31 | + ("egg-list-textures reads an egg file and writes a list of the " |
| 32 | + "textures it references. It is particularly useful for building " |
| 33 | + "up the textures.txa file used for egg-palettize, since the output " |
| 34 | + "format is crafted to be compatible with that file's input format."); |
| 35 | +} |
| 36 | + |
| 37 | +//////////////////////////////////////////////////////////////////// |
| 38 | +// Function: EggListTextures::run |
| 39 | +// Access: Public |
| 40 | +// Description: |
| 41 | +//////////////////////////////////////////////////////////////////// |
| 42 | +void EggListTextures:: |
| 43 | +run() { |
| 44 | + if (!do_reader_options()) { |
| 45 | + exit(1); |
| 46 | + } |
| 47 | + |
| 48 | + EggTextureCollection tc; |
| 49 | + tc.find_used_textures(_data); |
| 50 | + EggTextureCollection::TextureReplacement treplace; |
| 51 | + tc.collapse_equivalent_textures(EggTexture::E_complete_filename, treplace); |
| 52 | + tc.sort_by_basename(); |
| 53 | + |
| 54 | + EggTextureCollection::iterator ti; |
| 55 | + for (ti = tc.begin(); ti != tc.end(); ++ti) { |
| 56 | + Filename fullpath = (*ti)->get_fullpath(); |
| 57 | + PNMImageHeader header; |
| 58 | + if (header.read_header(fullpath)) { |
| 59 | + cout << fullpath.get_basename() << " : " |
| 60 | + << header.get_x_size() << " " << header.get_y_size() << "\n"; |
| 61 | + } else { |
| 62 | + cout << fullpath.get_basename() << " : unknown\n"; |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | + |
| 68 | +int main(int argc, char *argv[]) { |
| 69 | + EggListTextures prog; |
| 70 | + prog.parse_command_line(argc, argv); |
| 71 | + prog.run(); |
| 72 | + return 0; |
| 73 | +} |
0 commit comments