From a4bd18215d53751c4d9a5cfb1fb37e69fedff237 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 24 Apr 2001 21:13:34 +0000 Subject: [PATCH] *** empty log message *** --- pandatool/src/lwo/Sources.pp | 2 + pandatool/src/lwo/config_lwo.cxx | 2 + pandatool/src/lwo/lwoPolygonTags.cxx | 2 +- pandatool/src/lwo/lwoSurface.cxx | 4 ++ pandatool/src/lwo/lwoSurfaceSidedness.cxx | 41 ++++++++++++++++++ pandatool/src/lwo/lwoSurfaceSidedness.h | 52 +++++++++++++++++++++++ 6 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 pandatool/src/lwo/lwoSurfaceSidedness.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceSidedness.h diff --git a/pandatool/src/lwo/Sources.pp b/pandatool/src/lwo/Sources.pp index d948110531..fe26bf5ff7 100644 --- a/pandatool/src/lwo/Sources.pp +++ b/pandatool/src/lwo/Sources.pp @@ -27,6 +27,7 @@ lwoSurface.h lwoSurface.cxx \ lwoSurfaceColor.h lwoSurfaceColor.cxx \ lwoSurfaceParameter.h lwoSurfaceParameter.cxx \ + lwoSurfaceSidedness.h lwoSurfaceSidedness.cxx \ lwoVertexMap.h lwoVertexMap.cxx #define INSTALL_HEADERS \ @@ -48,6 +49,7 @@ lwoSurface.h \ lwoSurfaceColor.h \ lwoSurfaceParameter.h \ + lwoSurfaceSidedness.h \ lwoVertexMap.h #end ss_lib_target diff --git a/pandatool/src/lwo/config_lwo.cxx b/pandatool/src/lwo/config_lwo.cxx index 3a7c68b89f..5a148d55f5 100644 --- a/pandatool/src/lwo/config_lwo.cxx +++ b/pandatool/src/lwo/config_lwo.cxx @@ -22,6 +22,7 @@ #include "lwoSurface.h" #include "lwoSurfaceColor.h" #include "lwoSurfaceParameter.h" +#include "lwoSurfaceSidedness.h" #include "lwoTags.h" #include "lwoVertexMap.h" @@ -49,6 +50,7 @@ ConfigureFn(config_lwo) { LwoSurface::init_type(); LwoSurfaceColor::init_type(); LwoSurfaceParameter::init_type(); + LwoSurfaceSidedness::init_type(); LwoVertexMap::init_type(); } diff --git a/pandatool/src/lwo/lwoPolygonTags.cxx b/pandatool/src/lwo/lwoPolygonTags.cxx index 5be95d9e80..334bca9c23 100644 --- a/pandatool/src/lwo/lwoPolygonTags.cxx +++ b/pandatool/src/lwo/lwoPolygonTags.cxx @@ -61,7 +61,7 @@ read_iff(IffInputFile *in, size_t stop_at) { bool inserted = _tmap.insert(TMap::value_type(polygon_index, tag)).second; if (!inserted) { - nout << "Duplicate index " << index << " in map.\n"; + nout << "Duplicate index " << polygon_index << " in map.\n"; } } diff --git a/pandatool/src/lwo/lwoSurface.cxx b/pandatool/src/lwo/lwoSurface.cxx index 93f0af7072..2584909353 100644 --- a/pandatool/src/lwo/lwoSurface.cxx +++ b/pandatool/src/lwo/lwoSurface.cxx @@ -7,6 +7,7 @@ #include "iffInputFile.h" #include "lwoSurfaceColor.h" #include "lwoSurfaceParameter.h" +#include "lwoSurfaceSidedness.h" #include @@ -70,6 +71,9 @@ make_new_chunk(IffInputFile *in, IffId id) { id == IffId("RIND")) { return new LwoSurfaceParameter; + } else if (id == IffId("SIDE")) { + return new LwoSurfaceSidedness; + } else { return IffChunk::make_new_chunk(in, id); } diff --git a/pandatool/src/lwo/lwoSurfaceSidedness.cxx b/pandatool/src/lwo/lwoSurfaceSidedness.cxx new file mode 100644 index 0000000000..29e1918ae9 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceSidedness.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceSidedness.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceSidedness.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceSidedness::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceSidedness::read_iff +// Access: Public, Virtual +// Description: Reads the data of the chunk in from the given input +// file, if possible. The ID and length of the chunk +// have already been read. stop_at is the byte position +// of the file to stop at (based on the current position +// at in->get_bytes_read()). Returns true on success, +// false otherwise. +//////////////////////////////////////////////////////////////////// +bool LwoSurfaceSidedness:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _sidedness = (Sidedness)lin->get_be_int16(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceSidedness::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceSidedness:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { sidedness = " << (int)_sidedness << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceSidedness.h b/pandatool/src/lwo/lwoSurfaceSidedness.h new file mode 100644 index 0000000000..7c001261e1 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceSidedness.h @@ -0,0 +1,52 @@ +// Filename: lwoSurfaceSidedness.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACESIDEDNESS_H +#define LWOSURFACESIDEDNESS_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceSidedness +// Description : Records whether polygons are frontfacing only or +// backfacing also. This is associated with the +// LwoSurface chunk. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceSidedness : public LwoChunk { +public: + enum Sidedness { + S_front = 1, + S_front_and_back = 3 + }; + + Sidedness _sidedness; + +public: + virtual bool read_iff(IffInputFile *in, size_t stop_at); + virtual void write(ostream &out, int indent_level = 0) const; + +public: + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + LwoChunk::init_type(); + register_type(_type_handle, "LwoSurfaceSidedness", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + +