36 if (!FltRecord::extract_record(reader)) {
40 nassertr(reader.
get_opcode() == FO_local_vertex_pool,
false);
46 for (
int i = 0; i < num_vertices; i++) {
48 _vertices.push_back(vertex);
50 if ((attributes & AM_has_position) != 0) {
56 if ((attributes & AM_has_color_index) != 0) {
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) {
73 vertex->_has_normal =
true;
76 if ((attributes & AM_has_base_uv) != 0) {
79 vertex->_has_uv =
true;
82 if ((attributes & AM_has_uv_1) != 0) {
87 if ((attributes & AM_has_uv_2) != 0) {
92 if ((attributes & AM_has_uv_3) != 0) {
97 if ((attributes & AM_has_uv_4) != 0) {
102 if ((attributes & AM_has_uv_5) != 0) {
107 if ((attributes & AM_has_uv_6) != 0) {
112 if ((attributes & AM_has_uv_7) != 0) {
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) {
A class to retrieve the individual data elements previously stored in a Datagram.
int32_t get_be_int32()
Extracts a signed 32-bit big-endian integer.
PN_float32 get_be_float32()
Extracts a 32-bit big-endian single-precision floating-point number.
PN_float64 get_be_float64()
Extracts a 64-bit big-endian floating-point number.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_be_int32(int32_t value)
Adds a signed 32-bit big-endian integer to the datagram.
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
void add_be_float64(PN_float64 value)
Adds a 64-bit 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,...
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...
A packed color record, A, B, G, R.
void set_color(const LColor &color)
Sets the color according to the indicated four-component LColor value (including alpha).
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly.
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
The base class for all kinds of records in a MultiGen OpenFlight file.
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.
Represents a single vertex in the vertex palette.
LColor get_color() const
If has_color() indicates true, returns the color of the vertex, as a four- component value.
bool has_color() const
Returns true if the vertex has a primary color indicated, false otherwise.
TypeHandle is the identifier used to differentiate C++ class types.
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.