Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
fc8156209d
2 changed files with 15 additions and 6 deletions
  1. 3 1
      pandatool/src/eggprogs/lwoToEgg.cxx
  2. 12 5
      pandatool/src/lwoegg/cLwoPolygons.cxx

+ 3 - 1
pandatool/src/eggprogs/lwoToEgg.cxx

@@ -25,7 +25,9 @@ LwoToEgg() :
     ("This program converts Lightwave Object (.lwo) files to egg.  Many "
      "rendering characteristics of Lightwave (like layered shaders, etc.) "
      "are not supported, but fundamental things like polygons and texture "
-     "maps are.");
+     "maps are.  This program is primarily designed to support files written "
+     "by Lightwave version 6.x (LWO2 files), but it also has some limited "
+     "support for version 5.x files (LWOB files).");
 
   redescribe_option
     ("cs",

+ 12 - 5
pandatool/src/lwoegg/cLwoPolygons.cxx

@@ -12,6 +12,7 @@
 #include <lwoPolygonTags.h>
 #include <lwoTags.h>
 #include <eggPolygon.h>
+#include <eggPoint.h>
 #include <deg_2_rad.h>
 
 ////////////////////////////////////////////////////////////////////
@@ -140,8 +141,6 @@ make_faces() {
   for (int i = 0; i < num_polygons; i++) {
     LwoPolygons::Polygon *poly = _polygons->get_polygon(i);
     
-    PT(EggPolygon) egg_poly = new EggPolygon;
-
     bool is_valid = true;
 
     // Set up the vertices.
@@ -154,6 +153,14 @@ make_faces() {
     // last vertex, so that the first convex angle is the first angle
     // in the EggPolygon (for determining correct normals).
     int num_vertices = poly->_vertices.size();
+    PT(EggPrimitive) egg_prim;
+
+    if (num_vertices == 1) {
+      egg_prim = new EggPoint;
+    } else {
+      egg_prim = new EggPolygon;
+    }
+
     for (int vi = num_vertices; vi > 0; vi--) {
       int vindex = poly->_vertices[vi % num_vertices];
       if (vindex < 0 || vindex >= num_points) {
@@ -164,17 +171,17 @@ make_faces() {
 	EggVertex egg_vert;
 	egg_vert.set_pos(LCAST(double, points->get_point(vindex)));
 	EggVertex *new_vert = egg_vpool->create_unique_vertex(egg_vert);
-	egg_poly->add_vertex(new_vert);
+	egg_prim->add_vertex(new_vert);
       }
     }
 
     if (is_valid) {
       CLwoSurface *surface = get_surface(i);
       if (surface != (CLwoSurface *)NULL) {
-	surface->apply_properties(egg_poly, smooth_angle);
+	surface->apply_properties(egg_prim, smooth_angle);
       }
 
-      _egg_group->add_child(egg_poly.p());
+      _egg_group->add_child(egg_prim.p());
     }
   }