Panda3D
lwoPolygons.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file lwoPolygons.h
10  * @author drose
11  * @date 2001-04-24
12  */
13 
14 #ifndef LWOPOLYGONS_H
15 #define LWOPOLYGONS_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "lwoChunk.h"
20 
21 #include "luse.h"
22 #include "vector_int.h"
23 #include "referenceCount.h"
24 #include "pointerTo.h"
25 
26 /**
27  * An array of polygons that will be referenced by later chunks.
28  */
29 class LwoPolygons : public LwoChunk {
30 public:
31  enum PolygonFlags {
32  PF_continuity_1 = 0x0400,
33  PF_continuity_2 = 0x0800,
34  PF_numverts_mask = 0x03f,
35 
36  // This "flag" is stored artificially when reading 5.x LWOB files, and
37  // indicates that the polygon is a decal of a preceding polygon.
38  PF_decal = 0x0001
39  };
40 
41  class Polygon : public ReferenceCount {
42  public:
43  int _flags;
44  vector_int _vertices;
45 
46  // This value is only filled in when reading 5.x LWOB files, and indicates
47  // the surface index of the polygon within a preceding SRFS (LwoTags)
48  // chunk. For 6.x and later files, this will be set to -1.
49  int _surface_index;
50  };
51 
52  int get_num_polygons() const;
53  Polygon *get_polygon(int n) const;
54 
55  IffId _polygon_type;
56 
57 public:
58  virtual bool read_iff(IffInputFile *in, size_t stop_at);
59  virtual void write(std::ostream &out, int indent_level = 0) const;
60 
61 private:
62  typedef pvector< PT(Polygon) > Polygons;
63  Polygons _polygons;
64 
65 public:
66  virtual TypeHandle get_type() const {
67  return get_class_type();
68  }
69  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
70  static TypeHandle get_class_type() {
71  return _type_handle;
72  }
73  static void init_type() {
74  LwoChunk::init_type();
75  register_type(_type_handle, "LwoPolygons",
76  LwoChunk::get_class_type());
77  }
78 
79 private:
80  static TypeHandle _type_handle;
81 };
82 
83 #endif
int get_num_polygons() const
Returns the number of polygons of this group.
Definition: lwoPolygons.cxx:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
A specialization of IffChunk for Lightwave Object files.
Definition: lwoChunk.h:26
A wrapper around an istream used for reading an IFF file.
Definition: iffInputFile.h:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:34
An array of polygons that will be referenced by later chunks.
Definition: lwoPolygons.h:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
A four-byte chunk ID appearing in an "IFF" file.
Definition: iffId.h:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:46