Panda3D
|
00001 // Filename: lwoPolygons.h 00002 // Created by: drose (24Apr01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef LWOPOLYGONS_H 00016 #define LWOPOLYGONS_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "lwoChunk.h" 00021 00022 #include "luse.h" 00023 #include "vector_int.h" 00024 #include "referenceCount.h" 00025 #include "pointerTo.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : LwoPolygons 00029 // Description : An array of polygons that will be referenced by later 00030 // chunks. 00031 //////////////////////////////////////////////////////////////////// 00032 class LwoPolygons : public LwoChunk { 00033 public: 00034 enum PolygonFlags { 00035 PF_continuity_1 = 0x0400, 00036 PF_continuity_2 = 0x0800, 00037 PF_numverts_mask = 0x03f, 00038 00039 // This "flag" is stored artificially when reading 5.x LWOB files, 00040 // and indicates that the polygon is a decal of a preceding 00041 // polygon. 00042 PF_decal = 0x0001 00043 }; 00044 00045 class Polygon : public ReferenceCount { 00046 public: 00047 int _flags; 00048 vector_int _vertices; 00049 00050 // This value is only filled in when reading 5.x LWOB files, and 00051 // indicates the surface index of the polygon within a preceding 00052 // SRFS (LwoTags) chunk. For 6.x and later files, this will be 00053 // set to -1. 00054 int _surface_index; 00055 }; 00056 00057 int get_num_polygons() const; 00058 Polygon *get_polygon(int n) const; 00059 00060 IffId _polygon_type; 00061 00062 public: 00063 virtual bool read_iff(IffInputFile *in, size_t stop_at); 00064 virtual void write(ostream &out, int indent_level = 0) const; 00065 00066 private: 00067 typedef pvector< PT(Polygon) > Polygons; 00068 Polygons _polygons; 00069 00070 public: 00071 virtual TypeHandle get_type() const { 00072 return get_class_type(); 00073 } 00074 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00075 static TypeHandle get_class_type() { 00076 return _type_handle; 00077 } 00078 static void init_type() { 00079 LwoChunk::init_type(); 00080 register_type(_type_handle, "LwoPolygons", 00081 LwoChunk::get_class_type()); 00082 } 00083 00084 private: 00085 static TypeHandle _type_handle; 00086 }; 00087 00088 #endif 00089 00090