Panda3D
 All Classes Functions Variables Enumerations
lwoPolygons.h
1 // Filename: lwoPolygons.h
2 // Created by: drose (24Apr01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef LWOPOLYGONS_H
16 #define LWOPOLYGONS_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "lwoChunk.h"
21 
22 #include "luse.h"
23 #include "vector_int.h"
24 #include "referenceCount.h"
25 #include "pointerTo.h"
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : LwoPolygons
29 // Description : An array of polygons that will be referenced by later
30 // chunks.
31 ////////////////////////////////////////////////////////////////////
32 class LwoPolygons : public LwoChunk {
33 public:
34  enum PolygonFlags {
35  PF_continuity_1 = 0x0400,
36  PF_continuity_2 = 0x0800,
37  PF_numverts_mask = 0x03f,
38 
39  // This "flag" is stored artificially when reading 5.x LWOB files,
40  // and indicates that the polygon is a decal of a preceding
41  // polygon.
42  PF_decal = 0x0001
43  };
44 
45  class Polygon : public ReferenceCount {
46  public:
47  int _flags;
48  vector_int _vertices;
49 
50  // This value is only filled in when reading 5.x LWOB files, and
51  // indicates the surface index of the polygon within a preceding
52  // SRFS (LwoTags) chunk. For 6.x and later files, this will be
53  // set to -1.
54  int _surface_index;
55  };
56 
57  int get_num_polygons() const;
58  Polygon *get_polygon(int n) const;
59 
60  IffId _polygon_type;
61 
62 public:
63  virtual bool read_iff(IffInputFile *in, size_t stop_at);
64  virtual void write(ostream &out, int indent_level = 0) const;
65 
66 private:
68  Polygons _polygons;
69 
70 public:
71  virtual TypeHandle get_type() const {
72  return get_class_type();
73  }
74  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
75  static TypeHandle get_class_type() {
76  return _type_handle;
77  }
78  static void init_type() {
79  LwoChunk::init_type();
80  register_type(_type_handle, "LwoPolygons",
81  LwoChunk::get_class_type());
82  }
83 
84 private:
85  static TypeHandle _type_handle;
86 };
87 
88 #endif
89 
90 
int get_num_polygons() const
Returns the number of polygons of this group.
Definition: lwoPolygons.cxx:29
A specialization of IffChunk for Lightwave Object files.
Definition: lwoChunk.h:29
A wrapper around an istream used for reading an IFF file.
Definition: iffInputFile.h:33
A base class for all things that want to be reference-counted.
Polygon * get_polygon(int n) const
Returns the nth polygon of this group.
Definition: lwoPolygons.cxx:39
An array of polygons that will be referenced by later chunks.
Definition: lwoPolygons.h:32
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A four-byte chunk ID appearing in an "IFF" file.
Definition: iffId.h:29
virtual bool read_iff(IffInputFile *in, size_t stop_at)
Reads the data of the chunk in from the given input file, if possible.
Definition: lwoPolygons.cxx:55