36 if (!FltRecord::extract_record(reader)) {
40 nassertr(reader.
get_opcode() == FO_local_vertex_pool,
false);
44 int attributes = iterator.get_be_int32();
46 for (
int i = 0; i < num_vertices; i++) {
48 _vertices.push_back(vertex);
50 if ((attributes & AM_has_position) != 0) {
51 vertex->_pos[0] = iterator.get_be_float64();
52 vertex->_pos[1] = iterator.get_be_float64();
53 vertex->_pos[2] = iterator.get_be_float64();
56 if ((attributes & AM_has_color_index) != 0) {
57 vertex->_color_index = iterator.get_be_int32();
59 }
else if ((attributes & AM_has_packed_color) != 0) {
60 if (!vertex->_packed_color.extract_record(reader)) {
63 vertex->_flags |= FltVertex::F_packed_color;
66 vertex->_flags |= FltVertex::F_no_color;
69 if ((attributes & AM_has_normal) != 0) {
70 vertex->_normal[0] = iterator.get_be_float32();
71 vertex->_normal[1] = iterator.get_be_float32();
72 vertex->_normal[2] = iterator.get_be_float32();
73 vertex->_has_normal =
true;
76 if ((attributes & AM_has_base_uv) != 0) {
77 vertex->_uv[0] = iterator.get_be_float32();
78 vertex->_uv[1] = iterator.get_be_float32();
79 vertex->_has_uv =
true;
82 if ((attributes & AM_has_uv_1) != 0) {
83 iterator.get_be_float32();
84 iterator.get_be_float32();
87 if ((attributes & AM_has_uv_2) != 0) {
88 iterator.get_be_float32();
89 iterator.get_be_float32();
92 if ((attributes & AM_has_uv_3) != 0) {
93 iterator.get_be_float32();
94 iterator.get_be_float32();
97 if ((attributes & AM_has_uv_4) != 0) {
98 iterator.get_be_float32();
99 iterator.get_be_float32();
102 if ((attributes & AM_has_uv_5) != 0) {
103 iterator.get_be_float32();
104 iterator.get_be_float32();
107 if ((attributes & AM_has_uv_6) != 0) {
108 iterator.get_be_float32();
109 iterator.get_be_float32();
112 if ((attributes & AM_has_uv_7) != 0) {
113 iterator.get_be_float32();
114 iterator.get_be_float32();
129 if (!FltRecord::build_record(writer)) {
137 int attributes = AM_has_position;
139 Vertices::const_iterator vi;
140 for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
142 if ((vertex->_flags & FltVertex::F_no_color) != 0) {
145 }
else if ((vertex->_flags & FltVertex::F_packed_color) != 0) {
147 attributes |= AM_has_packed_color;
151 attributes |= AM_has_color_index;
154 if (vertex->_has_normal) {
155 attributes |= AM_has_normal;
158 if (vertex->_has_uv) {
159 attributes |= AM_has_base_uv;
163 if ((attributes & AM_has_packed_color) != 0 &&
164 (attributes & AM_has_color_index) != 0) {
167 attributes &= ~AM_has_color_index;
174 for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
177 if ((attributes & AM_has_position) != 0) {
183 if ((attributes & AM_has_color_index) != 0) {
184 if ((vertex->_flags & (FltVertex::F_no_color | FltVertex::F_packed_color)) != 0) {
186 datagram.
add_be_int32(_header->get_closest_rgb(LRGBColor(1.0, 1.0, 1.0)));
191 }
else if ((attributes & AM_has_packed_color) != 0) {
202 color.
set_color(LColor(1.0, 1.0, 1.0, 1.0));
205 if (!color.build_record(writer)) {
210 if ((attributes & AM_has_normal) != 0) {
211 if (!vertex->_has_normal) {
222 if ((attributes & AM_has_base_uv) != 0) {
223 if (!vertex->_has_uv) {
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void check_remaining_size(const DatagramIterator &di, const std::string &name=std::string()) const
Checks that the iterator has no bytes left, as it should at the end of a successfully read record.
int32_t get_be_int32()
Extracts a signed 32-bit big-endian integer.
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
bool has_color() const
Returns true if the vertex has a primary color indicated, false otherwise.
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the datagram.
void set_color(const LColor &color)
Sets the color according to the indicated four-component LColor value (including alpha).
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool extract_record(FltRecordReader &reader)
Fills in the information in this bead based on the information given in the indicated datagram,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The base class for all kinds of records in a MultiGen OpenFlight file.
A packed color record, A, B, G, R.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a single vertex in the vertex palette.
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
A class to retrieve the individual data elements previously stored in a Datagram.
LColor get_color() const
If has_color() indicates true, returns the color of the vertex, as a four- component value.
void add_be_int32(int32_t value)
Adds a signed 32-bit big-endian integer to the datagram.
TypeHandle is the identifier used to differentiate C++ class types.
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
virtual bool build_record(FltRecordWriter &writer) const
Fills up the current record on the FltRecordWriter with data for this record, but does not advance th...
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...