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