Skip to content

Commit ae3fa23

Browse files
committed
add egg-list-textures
1 parent d122e00 commit ae3fa23

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed

pandatool/src/eggbase/eggReader.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ EggReader() {
5959

6060
_tex_type = (PNMFileType *)NULL;
6161
_delod = -1.0;
62+
63+
_got_tex_dirname = false;
64+
_got_tex_extension = false;
6265
}
6366

6467
////////////////////////////////////////////////////////////////////

pandatool/src/eggprogs/Sources.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,11 @@
7272
eggToC.cxx eggToC.h
7373

7474
#end bin_target
75+
76+
#begin bin_target
77+
#define TARGET egg-list-textures
78+
79+
#define SOURCES \
80+
eggListTextures.cxx eggListTextures.h
81+
82+
#end bin_target
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Filename: eggListTextures.h
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+
#ifndef EGGLISTTEXTURES_H
20+
#define EGGLISTTEXTURES_H
21+
22+
#include "pandatoolbase.h"
23+
24+
#include "eggReader.h"
25+
26+
////////////////////////////////////////////////////////////////////
27+
// Class : EggListTextures
28+
// Description : Reads an egg file and outputs the list of textures it
29+
// uses.
30+
////////////////////////////////////////////////////////////////////
31+
class EggListTextures : public EggReader {
32+
public:
33+
EggListTextures();
34+
35+
void run();
36+
};
37+
38+
#endif
39+

0 commit comments

Comments
 (0)