34 EggWriter(
bool allow_last_param,
bool allow_stdout) :
39 _preferred_extension =
".egg";
42 if (_allow_last_param) {
43 add_runline(
"[opts] output.egg");
45 add_runline(
"[opts] -o output.egg");
47 add_runline(
"[opts] >output.egg");
50 std::string o_description;
53 if (_allow_last_param) {
55 "Specify the filename to which the resulting egg file will be written. "
56 "If this option is omitted, the last parameter name is taken to be the "
57 "name of the output file, or standard output is used if there are no "
61 "Specify the filename to which the resulting egg file will be written. "
62 "If this option is omitted, the egg file is written to standard output.";
65 if (_allow_last_param) {
67 "Specify the filename to which the resulting egg file will be written. "
68 "If this option is omitted, the last parameter name is taken to be the "
69 "name of the output file.";
72 "Specify the filename to which the resulting egg file will be written.";
77 (
"o",
"filename", 50, o_description,
78 &EggWriter::dispatch_filename, &_got_output_filename, &_output_filename);
82 "Specify the coordinate system of the resulting egg file. This may be "
83 "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default is "
113 if (_got_transform) {
114 nout <<
"Applying transform matrix:\n";
115 _transform.write(nout, 2);
116 LVecBase3d scale, hpr, translate;
117 if (decompose_matrix(_transform, scale, hpr, translate,
118 _data->get_coordinate_system())) {
119 nout <<
"(scale " << scale <<
", hpr " << hpr <<
", translate "
120 << translate <<
")\n";
122 _data->transform(_transform);
126 nout <<
"Making points\n";
127 _data->make_point_primitives();
130 bool needs_remove =
false;
132 switch (_normals_mode) {
134 nout <<
"Stripping normals.\n";
135 _data->strip_normals();
140 nout <<
"Recomputing polygon normals.\n";
141 _data->recompute_polygon_normals();
146 nout <<
"Recomputing vertex normals.\n";
147 _data->recompute_vertex_normals(_normals_threshold);
157 needs_remove |= _data->recompute_tangent_binormal(
GlobPattern(
"*"));
160 needs_remove |= _data->recompute_tangent_binormal_auto();
162 needs_remove |= _data->recompute_tangent_binormal(_tbn_names);
166 _data->remove_unused_vertices(
true);
189 if (!check_last_arg(args, 0)) {
194 nout <<
"Unexpected arguments on command line:\n";
195 Args::const_iterator ai;
196 for (ai = args.begin(); ai != args.end(); ++ai) {
197 nout << (*ai) <<
" ";
203 if (!_got_path_directory && _got_output_filename) {
205 _path_replace->_path_directory = _output_filename.get_dirname();
215 post_command_line() {
216 if (!_allow_stdout && !_got_output_filename) {
217 nout <<
"You must specify the filename to write with -o.\n";
221 append_command_comment(_data);
223 return EggSingleBase::post_command_line();