40 _generic_layer =
nullptr;
41 _make_materials =
true;
57 ~LwoToEggConverter() {
106 nout <<
"Reading " << filename <<
"\n";
108 nout <<
"Unable to open " << filename <<
"\n";
112 PT(
IffChunk) chunk = in.get_chunk();
113 if (chunk ==
nullptr) {
114 nout <<
"Unable to read " << filename <<
"\n";
118 if (!chunk->is_of_type(LwoHeader::get_class_type())) {
119 nout <<
"File " << filename <<
" is not a Lightwave Object file.\n";
125 nout <<
"File " << filename
126 <<
" is not recognized as a Lightwave Object file. "
127 <<
"Perhaps the version is too recent.\n";
139 if (_egg_data->get_coordinate_system() == CS_default) {
140 _egg_data->set_coordinate_system(CS_yup_left);
144 _lwo_header = lwo_header;
150 _egg_data->remove_unused_vertices(
true);
162 if (number >= 0 && number < (
int)_layers.size()) {
163 return _layers[number];
174 if (number >= 0 && number < (
int)_clips.size()) {
175 return _clips[number];
186 Surfaces::const_iterator si;
187 si = _surfaces.find(name);
188 if (si != _surfaces.end()) {
198 void LwoToEggConverter::
202 if (_generic_layer !=
nullptr) {
203 delete _generic_layer;
204 _generic_layer =
nullptr;
208 for (li = _layers.begin(); li != _layers.end(); ++li) {
210 if (layer !=
nullptr) {
217 for (ci = _clips.begin(); ci != _clips.end(); ++ci) {
219 if (clip !=
nullptr) {
226 for (pi = _points.begin(); pi != _points.end(); ++pi) {
232 Polygons::iterator gi;
233 for (gi = _polygons.begin(); gi != _polygons.end(); ++gi) {
239 Surfaces::iterator si;
240 for (si = _surfaces.begin(); si != _surfaces.end(); ++si) {
251 void LwoToEggConverter::
259 int num_chunks = _lwo_header->get_num_chunks();
260 for (
int i = 0; i < num_chunks; i++) {
261 const IffChunk *chunk = _lwo_header->get_chunk(i);
263 if (chunk->
is_of_type(LwoLayer::get_class_type())) {
269 if (_layers[number] !=
nullptr) {
270 nout <<
"Warning: multiple layers with number " << number <<
"\n";
272 _layers[number] = layer;
274 last_points =
nullptr;
275 last_polygons =
nullptr;
277 }
else if (chunk->
is_of_type(LwoClip::get_class_type())) {
284 if (_clips[index] !=
nullptr) {
285 nout <<
"Warning: multiple clips with index " << index <<
"\n";
287 _clips[index] = clip;
289 }
else if (chunk->
is_of_type(LwoPoints::get_class_type())) {
290 if (last_layer ==
nullptr) {
291 last_layer = make_generic_layer();
296 _points.push_back(points);
297 last_points = points;
299 }
else if (chunk->
is_of_type(LwoVertexMap::get_class_type())) {
300 if (last_points ==
nullptr) {
301 nout <<
"Vertex map chunk encountered without a preceding points chunk.\n";
307 }
else if (chunk->
is_of_type(LwoDiscontinuousVertexMap::get_class_type())) {
308 if (last_polygons ==
nullptr) {
309 nout <<
"Discontinous vertex map chunk encountered without a preceding polygons chunk.\n";
315 }
else if (chunk->
is_of_type(LwoTags::get_class_type())) {
318 }
else if (chunk->
is_of_type(LwoPolygons::get_class_type())) {
319 if (last_points ==
nullptr) {
320 nout <<
"Polygon chunk encountered without a preceding points chunk.\n";
325 _polygons.push_back(polygons);
326 last_polygons = polygons;
329 }
else if (chunk->
is_of_type(LwoPolygonTags::get_class_type())) {
330 if (last_polygons ==
nullptr) {
331 nout <<
"Polygon tags chunk encountered without a preceding polygons chunk.\n";
332 }
else if (tags ==
nullptr) {
333 nout <<
"Polygon tags chunk encountered without a preceding tags chunk.\n";
336 last_polygons->
add_ptags(lwo_ptags, tags);
339 }
else if (chunk->
is_of_type(LwoSurface::get_class_type())) {
340 if (last_layer ==
nullptr) {
341 last_layer = make_generic_layer();
347 bool inserted = _surfaces.insert(Surfaces::value_type(surface->
get_name(), surface)).second;
349 nout <<
"Multiple surface definitions named " << surface->
get_name() <<
"\n";
359 void LwoToEggConverter::
361 if (_generic_layer !=
nullptr) {
366 for (li = _layers.begin(); li != _layers.end(); ++li) {
368 if (layer !=
nullptr) {
374 for (pi = _points.begin(); pi != _points.end(); ++pi) {
379 Polygons::iterator gi;
380 for (gi = _polygons.begin(); gi != _polygons.end(); ++gi) {
389 void LwoToEggConverter::
391 if (_generic_layer !=
nullptr) {
396 for (li = _layers.begin(); li != _layers.end(); ++li) {
398 if (layer !=
nullptr) {
404 for (pi = _points.begin(); pi != _points.end(); ++pi) {
409 Polygons::iterator gi;
410 for (gi = _polygons.begin(); gi != _polygons.end(); ++gi) {
420 void LwoToEggConverter::
421 slot_layer(
int number) {
422 nassertv(number - (
int)_layers.size() < 1000);
423 while (number >= (
int)_layers.size()) {
424 _layers.push_back(
nullptr);
426 nassertv(number >= 0 && number < (
int)_layers.size());
433 void LwoToEggConverter::
434 slot_clip(
int number) {
435 nassertv(number - (
int)_clips.size() < 1000);
436 while (number >= (
int)_clips.size()) {
437 _clips.push_back(
nullptr);
439 nassertv(number >= 0 && number < (
int)_clips.size());
449 make_generic_layer() {
450 nassertr(_generic_layer ==
nullptr, _generic_layer);
453 layer->make_generic();
455 _generic_layer =
new CLwoLayer(
this, layer);
456 return _generic_layer;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is a wrapper around LwoClip and stores additional information useful during the conversion...
int get_index() const
Returns the index number of this clip.
This class is a wrapper around LwoLayer and stores additional information useful during the conversio...
void make_egg()
Creates the egg structures associated with this Lightwave object.
int get_number() const
Returns the index number associated with this particular layer.
void connect_egg()
Connects all the egg structures together.
This class is a wrapper around LwoPoints and stores additional information useful during the conversi...
void make_egg()
Creates the egg structures associated with this Lightwave object.
void add_vmap(const LwoVertexMap *lwo_vmap)
Associates the indicated VertexMap with the points set.
void connect_egg()
Connects all the egg structures together.
This class is a wrapper around LwoPolygons and stores additional information useful during the conver...
void make_egg()
Creates the egg structures associated with this Lightwave object.
void connect_egg()
Connects all the egg structures together.
void add_vmad(const LwoDiscontinuousVertexMap *lwo_vmad)
Associates the indicated DiscontinousVertexMap with the polygons.
void add_ptags(const LwoPolygonTags *lwo_ptags, const LwoTags *tags)
Associates the indicated PolygonTags and Tags with the polygons in this chunk.
This class is a wrapper around LwoSurface and stores additional information useful during the convers...
const std::string & get_name() const
Returns the name of the surface.
The name of a file, such as a texture file or an Egg file.
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on.
A single image file, or a numbered sequence of images (e.g.
A mapping of floating-point values per integer index.
Signals the start of a new layer.
An array of points that will be referenced by later chunks.
An array of polygons that will be referenced by later chunks.
Describes the shading attributes of a surface.
This class supervises the construction of an EggData structure from the data represented by the LwoHe...
CLwoSurface * get_surface(const std::string &name) const
Returns a pointer to the surface definition with the given name, or NULL if there is no such surface.
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension),...
CLwoClip * get_clip(int number) const
Returns a pointer to the clip with the given index number, or NULL if there is no such clip.
virtual std::string get_name() const
Returns the English name of the file type this converter supports.
virtual SomethingToEggConverter * make_copy()
Allocates and returns a new copy of the converter.
virtual std::string get_extension() const
Returns the common extension of the file type this converter supports.
CLwoLayer * get_layer(int number) const
Returns a pointer to the layer with the given index number, or NULL if there is no such layer.
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
bool convert_lwo(const LwoHeader *lwo_header)
Fills up the egg_data structure according to the indicated lwo structure.
A mapping of floating-point values per integer index.
This is a base class for a family of converter classes that manage a conversion from some file type t...
bool had_error() const
Returns true if an error was detected during the conversion process (unless _allow_errors is true),...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.