15 #include "fltLocalVertexPool.h" 16 #include "fltRecordReader.h" 17 #include "fltRecordWriter.h" 18 #include "fltHeader.h" 19 #include "fltMaterial.h" 42 if (!FltRecord::extract_record(reader)) {
46 nassertr(reader.
get_opcode() == FO_local_vertex_pool,
false);
50 int attributes = iterator.get_be_int32();
52 for (
int i = 0; i < num_vertices; i++) {
54 _vertices.push_back(vertex);
56 if ((attributes & AM_has_position) != 0) {
57 vertex->_pos[0] = iterator.get_be_float64();
58 vertex->_pos[1] = iterator.get_be_float64();
59 vertex->_pos[2] = iterator.get_be_float64();
62 if ((attributes & AM_has_color_index) != 0) {
63 vertex->_color_index = iterator.get_be_int32();
65 }
else if ((attributes & AM_has_packed_color) != 0) {
66 if (!vertex->_packed_color.extract_record(reader)) {
69 vertex->_flags |= FltVertex::F_packed_color;
72 vertex->_flags |= FltVertex::F_no_color;
75 if ((attributes & AM_has_normal) != 0) {
76 vertex->_normal[0] = iterator.get_be_float32();
77 vertex->_normal[1] = iterator.get_be_float32();
78 vertex->_normal[2] = iterator.get_be_float32();
79 vertex->_has_normal =
true;
82 if ((attributes & AM_has_base_uv) != 0) {
83 vertex->_uv[0] = iterator.get_be_float32();
84 vertex->_uv[1] = iterator.get_be_float32();
85 vertex->_has_uv =
true;
88 if ((attributes & AM_has_uv_1) != 0) {
89 iterator.get_be_float32();
90 iterator.get_be_float32();
93 if ((attributes & AM_has_uv_2) != 0) {
94 iterator.get_be_float32();
95 iterator.get_be_float32();
98 if ((attributes & AM_has_uv_3) != 0) {
99 iterator.get_be_float32();
100 iterator.get_be_float32();
103 if ((attributes & AM_has_uv_4) != 0) {
104 iterator.get_be_float32();
105 iterator.get_be_float32();
108 if ((attributes & AM_has_uv_5) != 0) {
109 iterator.get_be_float32();
110 iterator.get_be_float32();
113 if ((attributes & AM_has_uv_6) != 0) {
114 iterator.get_be_float32();
115 iterator.get_be_float32();
118 if ((attributes & AM_has_uv_7) != 0) {
119 iterator.get_be_float32();
120 iterator.get_be_float32();
138 if (!FltRecord::build_record(writer)) {
146 int attributes = AM_has_position;
148 Vertices::const_iterator vi;
149 for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
151 if ((vertex->_flags & FltVertex::F_no_color) != 0) {
154 }
else if ((vertex->_flags & FltVertex::F_packed_color) != 0) {
156 attributes |= AM_has_packed_color;
160 attributes |= AM_has_color_index;
163 if (vertex->_has_normal) {
164 attributes |= AM_has_normal;
167 if (vertex->_has_uv) {
168 attributes |= AM_has_base_uv;
172 if ((attributes & AM_has_packed_color) != 0 &&
173 (attributes & AM_has_color_index) != 0) {
176 attributes &= ~AM_has_color_index;
183 for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
186 if ((attributes & AM_has_position) != 0) {
192 if ((attributes & AM_has_color_index) != 0) {
193 if ((vertex->_flags & (FltVertex::F_no_color | FltVertex::F_packed_color)) != 0) {
201 }
else if ((attributes & AM_has_packed_color) != 0) {
215 if (!color.build_record(writer)) {
220 if ((attributes & AM_has_normal) != 0) {
221 if (!vertex->_has_normal) {
232 if ((attributes & AM_has_base_uv) != 0) {
233 if (!vertex->_has_uv) {
This is the base class for all three-component vectors and points.
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 check_remaining_size(const DatagramIterator &di, const string &name=string()) const
Checks that the iterator has no bytes left, as it should at the end of a successfully read record...
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.
virtual bool extract_record(FltRecordReader &reader)
Fills in the information in this bead based on the information given in the indicated datagram...
The base class for all kinds of records in a MultiGen OpenFlight file.
A packed color record, A, B, G, R.
Represents a single vertex in the vertex palette.
void add_be_int32(PN_int32 value)
Adds a signed 32-bit big-endian integer to the datagram.
This is the base class for all three-component vectors and points.
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...
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 ...
PN_int32 get_be_int32()
Extracts a signed 32-bit big-endian integer.