瀏覽代碼

add line primitive to egg syntax

David Rose 22 年之前
父節點
當前提交
3a24581e96

+ 40 - 14
panda/src/builder/builderFuncs.I

@@ -20,9 +20,8 @@
 #include "mesherTempl.h"
 #include "mesherTempl.h"
 #include "builderNormalVisualizer.h"
 #include "builderNormalVisualizer.h"
 #include "config_builder.h"
 #include "config_builder.h"
-
-#include <geom.h>
-#include <geomprimitives.h>
+#include "geom.h"
+#include "geomprimitives.h"
 
 
 #include <algorithm>
 #include <algorithm>
 
 
@@ -401,20 +400,40 @@ expand_points(const PrimType &prim, BuilderBucket &,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template <class PrimType, class OutputIterator>
 template <class PrimType, class OutputIterator>
 static bool
 static bool
-expand_lines(const PrimType &prim, BuilderBucket &,
+expand_lines(PrimType &prim, BuilderBucket &,
              OutputIterator result) {
              OutputIterator result) {
-  // Each line segment goes in its own primitive.  This breaks up the
-  // linestrips already defined; we'll re-strip them later if the
-  // generate-tstrips flag is enabled.
+  // Actually, we don't have support for meshing linestrips right now,
+  // so let's not break up the linestrips we're supplied with.
+  /*
+  if (bucket._subdivide_polys) {
+    // If we're subdividing, each line segment goes in its own
+    // primitive.  This breaks up the linestrips already defined;
+    // we'll re-strip them later if the generate-tstrips flag is
+    // enabled.
+    prim.set_type(BPT_line);
+    
+    int num_verts = prim.get_num_verts();
+    for (int i = 1; i < num_verts; i++) {
+      PrimType new_prim(prim);
+      new_prim.clear_vertices();
+      new_prim.add_vertex(prim.get_vertex(i-1));
+      new_prim.add_vertex(prim.get_vertex(i));
+      *result++ = new_prim;
+    }
+    return true;
+  }
+  */
 
 
-  int num_verts = prim.get_num_verts();
-  for (int i = 1; i < num_verts; i++) {
-    PrimType new_prim(prim);
-    new_prim.clear_vertices();
-    new_prim.add_vertex(prim.get_vertex(i-1));
-    new_prim.add_vertex(prim.get_vertex(i));
-    *result++ = new_prim;
+  // If we're not to subdivide the polys, then just pass them through
+  // as they are.  Two vertices is a BPT_line; more than that is a
+  // BPT_linestrip.
+  if (prim.get_num_verts() > 2) {
+    prim.set_type(BPT_linestrip);
+  } else {
+    prim.set_type(BPT_line);
   }
   }
+  *result++ = prim;
+  
   return true;
   return true;
 }
 }
 
 
@@ -467,6 +486,7 @@ expand(const PrimType &prim, BuilderBucket &bucket, OutputIterator result) {
     return expand_points(new_prim, bucket, result);
     return expand_points(new_prim, bucket, result);
 
 
   case BPT_line:
   case BPT_line:
+  case BPT_linestrip:
     new_prim.remove_doubled_verts(false);
     new_prim.remove_doubled_verts(false);
     return expand_lines(new_prim, bucket, result);
     return expand_lines(new_prim, bucket, result);
 
 
@@ -614,6 +634,7 @@ build_geoms(InputIterator first, InputIterator last,
 
 
   Geom *geom = NULL;
   Geom *geom = NULL;
   BuilderPrimType type = (*first).get_type();
   BuilderPrimType type = (*first).get_type();
+
   switch (type) {
   switch (type) {
   case BPT_poly:
   case BPT_poly:
     geom = new GeomPolygon;
     geom = new GeomPolygon;
@@ -634,6 +655,11 @@ build_geoms(InputIterator first, InputIterator last,
     geom = new GeomLine;
     geom = new GeomLine;
     break;
     break;
 
 
+  case BPT_linestrip:
+    geom = new GeomLinestrip;
+    want_lengths = true;
+    break;
+
   case BPT_point:
   case BPT_point:
     geom = new GeomPoint;
     geom = new GeomPoint;
     break;
     break;

+ 3 - 7
panda/src/builder/builderPrim.h

@@ -61,16 +61,12 @@
 //
 //
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
 
 
-
-
-#include <pandabase.h>
-
+#include "pandabase.h"
 #include "builderPrimTempl.h"
 #include "builderPrimTempl.h"
 #include "builderBucket.h"
 #include "builderBucket.h"
 #include "builderTypes.h"
 #include "builderTypes.h"
-
-#include <pta_ushort.h>
-#include <geom.h>
+#include "pta_ushort.h"
+#include "geom.h"
 
 
 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertex>);
 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertex>);
 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertexI>);
 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertexI>);

+ 3 - 0
panda/src/builder/builderPrimTempl.I

@@ -792,6 +792,9 @@ is_valid() const {
     return num_verts >= 1;
     return num_verts >= 1;
 
 
   case BPT_line:
   case BPT_line:
+    return num_verts == 2;
+
+  case BPT_linestrip:
     return num_verts >= 2;
     return num_verts >= 2;
 
 
   case BPT_tri:
   case BPT_tri:

+ 3 - 1
panda/src/builder/builderTypes.cxx

@@ -17,7 +17,7 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "builderTypes.h"
 #include "builderTypes.h"
-#include <notify.h>
+#include "notify.h"
 
 
 ostream &operator << (ostream &out, BuilderAttribFlags baf) {
 ostream &operator << (ostream &out, BuilderAttribFlags baf) {
   const char *space = "";
   const char *space = "";
@@ -107,6 +107,8 @@ ostream &operator << (ostream &out, BuilderPrimType bpt) {
     return out << "quad";
     return out << "quad";
   case BPT_quadstrip:
   case BPT_quadstrip:
     return out << "quadstrip";
     return out << "quadstrip";
+  case BPT_linestrip:
+    return out << "linestrip";
   }
   }
   nassertr(false, out);
   nassertr(false, out);
   return out << "(**invalid**)";
   return out << "(**invalid**)";

+ 7 - 6
panda/src/builder/builderTypes.h

@@ -18,13 +18,13 @@
 #ifndef BUILDERTYPES_H
 #ifndef BUILDERTYPES_H
 #define BUILDERTYPES_H
 #define BUILDERTYPES_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
-#include <luse.h>
-#include <pta_TexCoordf.h>
-#include <pta_Vertexf.h>
-#include <pta_Normalf.h>
-#include <pta_Colorf.h>
+#include "luse.h"
+#include "pta_TexCoordf.h"
+#include "pta_Vertexf.h"
+#include "pta_Normalf.h"
+#include "pta_Colorf.h"
 
 
 typedef TexCoordf BuilderTC;
 typedef TexCoordf BuilderTC;
 typedef Vertexf BuilderV;
 typedef Vertexf BuilderV;
@@ -72,6 +72,7 @@ enum BuilderPrimType {
   BPT_trifan,
   BPT_trifan,
   BPT_quad,
   BPT_quad,
   BPT_quadstrip,
   BPT_quadstrip,
+  BPT_linestrip,
 };
 };
 
 
 ostream &operator << (ostream &out, BuilderPrimType bpt);
 ostream &operator << (ostream &out, BuilderPrimType bpt);

+ 1 - 1
panda/src/builder/mesher.h

@@ -18,7 +18,7 @@
 #ifndef MESHER_H
 #ifndef MESHER_H
 #define MESHER_H
 #define MESHER_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #include "mesherConfig.h"
 #include "mesherConfig.h"
 #include "mesherFanMaker.h"
 #include "mesherFanMaker.h"

+ 2 - 3
panda/src/builder/mesherStrip.I

@@ -16,7 +16,6 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#include "config_builder.h"
 
 
 template <class PrimType>
 template <class PrimType>
 INLINE MesherStrip<PrimType>::
 INLINE MesherStrip<PrimType>::
@@ -1496,8 +1495,8 @@ remove_all_edges() {
 template <class PrimType>
 template <class PrimType>
 bool MesherStrip<PrimType>::
 bool MesherStrip<PrimType>::
 pick_mate(const MesherStrip &a_strip, const MesherStrip &b_strip,
 pick_mate(const MesherStrip &a_strip, const MesherStrip &b_strip,
-         const Edge &a_edge, const Edge &b_edge,
-         const BuilderBucket &bucket) const {
+          const Edge &a_edge, const Edge &b_edge,
+          const BuilderBucket &bucket) const {
   // First, try to avoid polluting quads, quadstrips, and tristrips
   // First, try to avoid polluting quads, quadstrips, and tristrips
   // with arbitrary triangles.  When we mate a tri or tristrip to a
   // with arbitrary triangles.  When we mate a tri or tristrip to a
   // quadstrip, we end up with a tristrip that may be less versatile
   // quadstrip, we end up with a tristrip that may be less versatile

+ 2 - 1
panda/src/builder/mesherStrip.h

@@ -19,11 +19,12 @@
 #ifndef MESHERSTRIP_H
 #ifndef MESHERSTRIP_H
 #define MESHERSTRIP_H
 #define MESHERSTRIP_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #include "mesherConfig.h"
 #include "mesherConfig.h"
 #include "builderTypes.h"
 #include "builderTypes.h"
 #include "builderBucket.h"
 #include "builderBucket.h"
+#include "config_builder.h"
 
 
 #include "plist.h"
 #include "plist.h"
 #include <math.h>
 #include <math.h>

+ 1 - 1
panda/src/builder/mesherTempl.h

@@ -18,7 +18,7 @@
 #ifndef MESHERTEMPL_H
 #ifndef MESHERTEMPL_H
 #define MESHERTEMPL_H
 #define MESHERTEMPL_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #include "mesherConfig.h"
 #include "mesherConfig.h"
 #include "builderBucket.h"
 #include "builderBucket.h"

+ 5 - 2
panda/src/egg/Sources.pp

@@ -18,6 +18,7 @@
      eggExternalReference.I eggExternalReference.h  \
      eggExternalReference.I eggExternalReference.h  \
      eggFilenameNode.I eggFilenameNode.h eggGroup.I eggGroup.h  \
      eggFilenameNode.I eggFilenameNode.h eggGroup.I eggGroup.h  \
      eggGroupNode.I eggGroupNode.h eggGroupUniquifier.h  \
      eggGroupNode.I eggGroupNode.h eggGroupUniquifier.h  \
+     eggLine.I eggLine.h \
      eggMaterial.I eggMaterial.h eggMaterialCollection.I  \
      eggMaterial.I eggMaterial.h eggMaterialCollection.I  \
      eggMaterialCollection.h eggMiscFuncs.I eggMiscFuncs.h  \
      eggMaterialCollection.h eggMiscFuncs.I eggMiscFuncs.h  \
      eggMorph.I eggMorph.h eggMorphList.I eggMorphList.h  \
      eggMorph.I eggMorph.h eggMorphList.I eggMorphList.h  \
@@ -44,7 +45,7 @@
      eggBinMaker.cxx eggComment.cxx eggCoordinateSystem.cxx  \
      eggBinMaker.cxx eggComment.cxx eggCoordinateSystem.cxx  \
      eggCurve.cxx eggData.cxx eggExternalReference.cxx  \
      eggCurve.cxx eggData.cxx eggExternalReference.cxx  \
      eggFilenameNode.cxx eggGroup.cxx eggGroupNode.cxx  \
      eggFilenameNode.cxx eggGroup.cxx eggGroupNode.cxx  \
-     eggGroupUniquifier.cxx eggMaterial.cxx  \
+     eggGroupUniquifier.cxx eggLine.cxx eggMaterial.cxx  \
      eggMaterialCollection.cxx eggMiscFuncs.cxx eggMorphList.cxx  \
      eggMaterialCollection.cxx eggMiscFuncs.cxx eggMorphList.cxx  \
      eggNamedObject.cxx eggNameUniquifier.cxx eggNode.cxx  \
      eggNamedObject.cxx eggNameUniquifier.cxx eggNode.cxx  \
      eggNurbsCurve.cxx eggNurbsSurface.cxx eggObject.cxx  \
      eggNurbsCurve.cxx eggNurbsSurface.cxx eggObject.cxx  \
@@ -67,7 +68,9 @@
     eggCurve.h eggData.I eggData.h eggExternalReference.I \
     eggCurve.h eggData.I eggData.h eggExternalReference.I \
     eggExternalReference.h eggFilenameNode.I eggFilenameNode.h \
     eggExternalReference.h eggFilenameNode.I eggFilenameNode.h \
     eggGroup.I eggGroup.h eggGroupNode.I eggGroupNode.h \
     eggGroup.I eggGroup.h eggGroupNode.I eggGroupNode.h \
-    eggGroupUniquifier.h eggMaterial.I \
+    eggGroupUniquifier.h \
+    eggLine.I eggLine.h \
+    eggMaterial.I \
     eggMaterial.h eggMaterialCollection.I eggMaterialCollection.h \
     eggMaterial.h eggMaterialCollection.I eggMaterialCollection.h \
     eggMorph.I eggMorph.h eggMorphList.I eggMorphList.h \
     eggMorph.I eggMorph.h eggMorphList.I eggMorphList.h \
     eggNamedObject.I eggNamedObject.h eggNameUniquifier.h eggNode.I eggNode.h \
     eggNamedObject.I eggNamedObject.h eggNameUniquifier.h eggNode.I eggNode.h \

+ 2 - 0
panda/src/egg/config_egg.cxx

@@ -29,6 +29,7 @@
 #include "eggFilenameNode.h"
 #include "eggFilenameNode.h"
 #include "eggGroup.h"
 #include "eggGroup.h"
 #include "eggGroupNode.h"
 #include "eggGroupNode.h"
+#include "eggLine.h"
 #include "eggMaterial.h"
 #include "eggMaterial.h"
 #include "eggNameUniquifier.h"
 #include "eggNameUniquifier.h"
 #include "eggNamedObject.h"
 #include "eggNamedObject.h"
@@ -100,6 +101,7 @@ init_libegg() {
   EggFilenameNode::init_type();
   EggFilenameNode::init_type();
   EggGroup::init_type();
   EggGroup::init_type();
   EggGroupNode::init_type();
   EggGroupNode::init_type();
+  EggLine::init_type();
   EggMaterial::init_type();
   EggMaterial::init_type();
   EggNameUniquifier::init_type();
   EggNameUniquifier::init_type();
   EggNamedObject::init_type();
   EggNamedObject::init_type();

+ 47 - 0
panda/src/egg/eggLine.I

@@ -0,0 +1,47 @@
+// Filename: eggLine.I
+// Created by:  drose (14Oct03)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggLine::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE EggLine::
+EggLine(const string &name) : EggPrimitive(name) {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggLine::Copy constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE EggLine::
+EggLine(const EggLine &copy) : EggPrimitive(copy) {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggLine::Copy assignment operator
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE EggLine &EggLine::
+operator = (const EggLine &copy) {
+  EggPrimitive::operator = (copy);
+  return *this;
+}

+ 36 - 0
panda/src/egg/eggLine.cxx

@@ -0,0 +1,36 @@
+// Filename: eggLine.cxx
+// Created by:  drose (14Oct03)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "eggLine.h"
+
+#include "indent.h"
+
+TypeHandle EggLine::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggLine::write
+//       Access: Public, Virtual
+//  Description: Writes the point to the indicated output stream in
+//               Egg format.
+////////////////////////////////////////////////////////////////////
+void EggLine::
+write(ostream &out, int indent_level) const {
+  write_header(out, indent_level, "<Line>");
+  write_body(out, indent_level+2);
+  indent(out, indent_level) << "}\n";
+}

+ 61 - 0
panda/src/egg/eggLine.h

@@ -0,0 +1,61 @@
+// Filename: eggLine.h
+// Created by:  drose (14Oct03)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef EGGLINE_H
+#define EGGLINE_H
+
+#include "pandabase.h"
+
+#include "eggPrimitive.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : EggLine
+// Description : A line segment, or a series of connected line
+//               segments, defined by a <Line> entry.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAEGG EggLine : public EggPrimitive {
+PUBLISHED:
+  INLINE EggLine(const string &name = "");
+  INLINE EggLine(const EggLine &copy);
+  INLINE EggLine &operator = (const EggLine &copy);
+
+  virtual void write(ostream &out, int indent_level) const;
+
+public:
+
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    EggPrimitive::init_type();
+    register_type(_type_handle, "EggLine",
+                  EggPrimitive::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+
+};
+
+#include "eggLine.I"
+
+#endif

+ 0 - 1
panda/src/egg/eggPoint.I

@@ -17,7 +17,6 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 
 
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: EggPoint::Constructor
 //     Function: EggPoint::Constructor
 //       Access: Public
 //       Access: Public

+ 1 - 3
panda/src/egg/eggPoint.cxx

@@ -18,9 +18,7 @@
 
 
 #include "eggPoint.h"
 #include "eggPoint.h"
 
 
-#include <indent.h>
-
-#include <algorithm>
+#include "indent.h"
 
 
 TypeHandle EggPoint::_type_handle;
 TypeHandle EggPoint::_type_handle;
 
 

+ 1 - 1
panda/src/egg/egg_composite1.cxx

@@ -12,6 +12,7 @@
 #include "eggGroup.cxx"
 #include "eggGroup.cxx"
 #include "eggGroupNode.cxx"
 #include "eggGroupNode.cxx"
 #include "eggGroupUniquifier.cxx"
 #include "eggGroupUniquifier.cxx"
+#include "eggLine.cxx"
 #include "eggMaterial.cxx"
 #include "eggMaterial.cxx"
 #include "eggMaterialCollection.cxx"
 #include "eggMaterialCollection.cxx"
 #include "eggMiscFuncs.cxx"
 #include "eggMiscFuncs.cxx"
@@ -21,4 +22,3 @@
 #include "eggNode.cxx"
 #include "eggNode.cxx"
 #include "eggNurbsCurve.cxx"
 #include "eggNurbsCurve.cxx"
 #include "eggNurbsSurface.cxx"
 #include "eggNurbsSurface.cxx"
-

+ 4 - 0
panda/src/egg/lexer.lxx

@@ -451,6 +451,10 @@ NUMERIC         ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
   accept();
   accept();
   return INSTANCE;
   return INSTANCE;
 }
 }
+"<LINE>" {
+  accept();
+  return LINE;
+}
 "<LOOP>" {
 "<LOOP>" {
   accept();
   accept();
   return LOOP;
   return LOOP;

+ 24 - 2
panda/src/egg/parser.yxx

@@ -14,6 +14,7 @@
 #include "eggVertexPool.h"
 #include "eggVertexPool.h"
 #include "eggPolygon.h"
 #include "eggPolygon.h"
 #include "eggPoint.h"
 #include "eggPoint.h"
+#include "eggLine.h"
 #include "eggNurbsSurface.h"
 #include "eggNurbsSurface.h"
 #include "eggNurbsCurve.h"
 #include "eggNurbsCurve.h"
 #include "eggTable.h"
 #include "eggTable.h"
@@ -121,7 +122,7 @@ egg_cleanup_parser() {
 %token DYNAMICVERTEXPOOL EXTERNAL_FILE
 %token DYNAMICVERTEXPOOL EXTERNAL_FILE
 %token FLIGHT GROUP HIP INTANGENT
 %token FLIGHT GROUP HIP INTANGENT
 %token JOINT KNOTS INCLUDE
 %token JOINT KNOTS INCLUDE
-%token INSTANCE LOOP MATERIAL MATRIX3 MATRIX4 MODEL MREF NORMAL
+%token INSTANCE LINE LOOP MATERIAL MATRIX3 MATRIX4 MODEL MREF NORMAL
 %token NURBSCURVE NURBSSURFACE OBJECTTYPE ORDER
 %token NURBSCURVE NURBSSURFACE OBJECTTYPE ORDER
 %token OUTTANGENT POINTLIGHT POLYGON REF RGBA ROTATE ROTX ROTY ROTZ
 %token OUTTANGENT POINTLIGHT POLYGON REF RGBA ROTATE ROTX ROTY ROTZ
 %token SANIM SCALAR SCALE SEQUENCE SHADING SWITCH SWITCHCONDITION
 %token SANIM SCALAR SCALE SEQUENCE SHADING SWITCH SWITCHCONDITION
@@ -146,8 +147,9 @@ egg_cleanup_parser() {
 %type <_egg> external_reference
 %type <_egg> external_reference
 %type <_egg> vertex_pool
 %type <_egg> vertex_pool
 %type <_egg> group
 %type <_egg> group
-%type <_egg> joint
 %type <_egg> instance
 %type <_egg> instance
+%type <_egg> joint
+%type <_egg> line
 %type <_egg> polygon
 %type <_egg> polygon
 %type <_egg> point_light
 %type <_egg> point_light
 %type <_egg> nurbs_surface
 %type <_egg> nurbs_surface
@@ -218,6 +220,7 @@ node:
         | instance
         | instance
         | polygon
         | polygon
         | point_light
         | point_light
+        | line
         | nurbs_surface
         | nurbs_surface
         | nurbs_curve
         | nurbs_curve
         | table
         | table
@@ -1357,6 +1360,25 @@ point_light:
 }
 }
         ;
         ;
 
 
+/*
+ * line
+ *
+ * enter:
+ * exit: returns a new EggLine.
+ *
+ */
+line:
+        LINE optional_name
+{
+  egg_stack.push_back(new EggLine($2));
+}
+        '{' primitive_body '}'
+{
+  $$ = egg_stack.back();
+  egg_stack.pop_back();
+}
+        ;
+
 /*
 /*
  * nurbs_surface
  * nurbs_surface
  *
  *

+ 8 - 3
panda/src/egg2pg/eggLoader.cxx

@@ -47,6 +47,7 @@
 #include "string_utils.h"
 #include "string_utils.h"
 #include "eggPrimitive.h"
 #include "eggPrimitive.h"
 #include "eggPoint.h"
 #include "eggPoint.h"
+#include "eggLine.h"
 #include "eggTextureCollection.h"
 #include "eggTextureCollection.h"
 #include "eggNurbsCurve.h"
 #include "eggNurbsCurve.h"
 #include "eggNurbsSurface.h"
 #include "eggNurbsSurface.h"
@@ -253,10 +254,12 @@ make_nonindexed_primitive(EggPrimitive *egg_prim, PandaNode *parent,
     make_nurbs_surface(DCAST(EggNurbsSurface, egg_prim), parent, mat);
     make_nurbs_surface(DCAST(EggNurbsSurface, egg_prim), parent, mat);
 
 
   } else {
   } else {
-    // A normal primitive: polygon or point.
+    // A normal primitive: polygon, line, or point.
     BuilderPrim bprim;
     BuilderPrim bprim;
     bprim.set_type(BPT_poly);
     bprim.set_type(BPT_poly);
-    if (egg_prim->is_of_type(EggPoint::get_class_type())) {
+    if (egg_prim->is_of_type(EggLine::get_class_type())) {
+      bprim.set_type(BPT_linestrip);
+    } else if (egg_prim->is_of_type(EggPoint::get_class_type())) {
       bprim.set_type(BPT_point);
       bprim.set_type(BPT_point);
     }
     }
     
     
@@ -344,7 +347,9 @@ make_indexed_primitive(EggPrimitive *egg_prim, PandaNode *parent,
 
 
   BuilderPrimI bprim;
   BuilderPrimI bprim;
   bprim.set_type(BPT_poly);
   bprim.set_type(BPT_poly);
-  if (egg_prim->is_of_type(EggPoint::get_class_type())) {
+  if (egg_prim->is_of_type(EggLine::get_class_type())) {
+    bprim.set_type(BPT_linestrip);
+  } else if (egg_prim->is_of_type(EggPoint::get_class_type())) {
     bprim.set_type(BPT_point);
     bprim.set_type(BPT_point);
   }
   }