Panda3D
lwoPolygonTags.h
1 // Filename: lwoPolygonTags.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 LWOPOLYGONTAGS_H
16 #define LWOPOLYGONTAGS_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "lwoChunk.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : LwoPolygonTags
24 // Description : An association of polygons defined in the most recent
25 // LwoPolygons chunk to tag ids defined in the most
26 // recent LwoTags chunk. This associated properties
27 // with the polygons, depending on the tag_type.
28 ////////////////////////////////////////////////////////////////////
29 class LwoPolygonTags : public LwoChunk {
30 public:
31  bool has_tag(int polygon_index) const;
32  int get_tag(int polygon_index) const;
33 
34  IffId _tag_type;
35 
36 public:
37  virtual bool read_iff(IffInputFile *in, size_t stop_at);
38  virtual void write(ostream &out, int indent_level = 0) const;
39 
40 private:
41  typedef pmap<int, int> TMap;
42  TMap _tmap;
43 
44 public:
45  virtual TypeHandle get_type() const {
46  return get_class_type();
47  }
48  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
49  static TypeHandle get_class_type() {
50  return _type_handle;
51  }
52  static void init_type() {
53  LwoChunk::init_type();
54  register_type(_type_handle, "LwoPolygonTags",
55  LwoChunk::get_class_type());
56  }
57 
58 private:
59  static TypeHandle _type_handle;
60 };
61 
62 #endif
63 
64 
An association of polygons defined in the most recent LwoPolygons chunk to tag ids defined in the mos...
virtual bool read_iff(IffInputFile *in, size_t stop_at)
Reads the data of the chunk in from the given input file, if possible.
int get_tag(int polygon_index) const
Returns the tag associated with the given polygon index, or -1 if there is no tag associated...
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
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
bool has_tag(int polygon_index) const
Returns true if the map has a tag associated with the given polygon index, false otherwise.