Panda3D
 All Classes Functions Variables Enumerations
fltVertex.h
1 // Filename: fltVertex.h
2 // Created by: drose (25Aug00)
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 FLTVERTEX_H
16 #define FLTVERTEX_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "fltRecord.h"
21 #include "fltPackedColor.h"
22 
23 #include "luse.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : FltVertex
27 // Description : Represents a single vertex in the vertex palette.
28 // Flt files index vertices by their byte offset in the
29 // vertex palette; within this library, we map those
30 // byte offsets to pointers automatically.
31 //
32 // This may represent a vertex with or without a normal
33 // or texture coordinates.
34 ////////////////////////////////////////////////////////////////////
35 class FltVertex : public FltRecord {
36 public:
37  FltVertex(FltHeader *header);
38 
39  FltOpcode get_opcode() const;
40  int get_record_length() const;
41 
42  enum Flags {
43  F_hard_edge = 0x8000,
44  F_normal_frozen = 0x4000,
45  F_no_color = 0x2000,
46  F_packed_color = 0x1000
47  };
48 
49  int _color_name_index;
50  unsigned int _flags;
51  LPoint3d _pos;
52  LPoint3 _normal;
53  LPoint2 _uv;
54  FltPackedColor _packed_color;
55  int _color_index;
56 
57  bool _has_normal;
58  bool _has_uv;
59 
60 public:
61  INLINE bool has_color() const;
62  LColor get_color() const;
63  INLINE void set_color(const LColor &color);
64  LRGBColor get_rgb() const;
65  void set_rgb(const LRGBColor &rgb);
66 
67 
68 protected:
69  virtual bool extract_record(FltRecordReader &reader);
70  virtual bool build_record(FltRecordWriter &writer) const;
71 
72 public:
73  virtual TypeHandle get_type() const {
74  return get_class_type();
75  }
76  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
77  static TypeHandle get_class_type() {
78  return _type_handle;
79  }
80  static void init_type() {
81  FltRecord::init_type();
82  register_type(_type_handle, "FltVertex",
83  FltRecord::get_class_type());
84  }
85 
86 private:
87  static TypeHandle _type_handle;
88 
89  friend class FltHeader;
90 };
91 
92 #include "fltVertex.I"
93 
94 #endif
95 
96 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly...
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
void set_color(const LColor &color)
Sets the color of the vertex, using the packed color convention.
Definition: fltVertex.I:37
LRGBColor get_rgb() const
If has_color() indicates true, returns the color of the vertex, as a three-component value...
Definition: fltVertex.cxx:137
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
void set_rgb(const LRGBColor &rgb)
Sets the color of the vertex, using the packed color convention.
Definition: fltVertex.cxx:151
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition: fltHeader.h:48
The base class for all kinds of records in a MultiGen OpenFlight file.
Definition: fltRecord.h:40
A packed color record, A, B, G, R.
Represents a single vertex in the vertex palette.
Definition: fltVertex.h:35
int get_record_length() const
Returns the length of this record in bytes as it will be written to the flt file. ...
Definition: fltVertex.cxx:70
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:531
bool has_color() const
Returns true if the vertex has a primary color indicated, false otherwise.
Definition: fltVertex.I:23
LColor get_color() const
If has_color() indicates true, returns the color of the vertex, as a four-component value...
Definition: fltVertex.cxx:123
This is a two-component point in space.
Definition: lpoint2.h:92
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
FltOpcode get_opcode() const
Returns the opcode that this record will be written as.
Definition: fltVertex.cxx:47