Bladeren bron

*** empty log message ***

David Rose 25 jaren geleden
bovenliggende
commit
a4bd18215d

+ 2 - 0
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

+ 2 - 0
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();
 }
 

+ 1 - 1
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";
     }
   }
 

+ 4 - 0
pandatool/src/lwo/lwoSurface.cxx

@@ -7,6 +7,7 @@
 #include "iffInputFile.h"
 #include "lwoSurfaceColor.h"
 #include "lwoSurfaceParameter.h"
+#include "lwoSurfaceSidedness.h"
 
 #include <indent.h>
 
@@ -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);
   }

+ 41 - 0
pandatool/src/lwo/lwoSurfaceSidedness.cxx

@@ -0,0 +1,41 @@
+// Filename: lwoSurfaceSidedness.cxx
+// Created by:  drose (24Apr01)
+// 
+////////////////////////////////////////////////////////////////////
+
+#include "lwoSurfaceSidedness.h"
+#include "lwoInputFile.h"
+
+#include <indent.h>
+
+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";
+}

+ 52 - 0
pandatool/src/lwo/lwoSurfaceSidedness.h

@@ -0,0 +1,52 @@
+// Filename: lwoSurfaceSidedness.h
+// Created by:  drose (24Apr01)
+// 
+////////////////////////////////////////////////////////////////////
+
+#ifndef LWOSURFACESIDEDNESS_H
+#define LWOSURFACESIDEDNESS_H
+
+#include <pandatoolbase.h>
+
+#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
+
+