37 _has_transform =
false;
38 _transform = LMatrix4d::ident_mat();
49 return _has_transform;
59 return _has_transform ? _transform : LMatrix4d::ident_mat();
80 _has_transform =
false;
81 _transform = LMatrix4d::ident_mat();
82 _transform_steps.clear();
93 return _transform_steps.size();
102 nassertr(n >= 0 && n < (
int)_transform_steps.size(),
104 return _transform_steps[n];
113 nassertr(n >= 0 && n < (
int)_transform_steps.size(),
115 return _transform_steps[n];
124 if (!_has_transform) {
125 _has_transform =
true;
126 _transform = record->get_matrix();
128 _transform = record->get_matrix() * _transform;
130 _transform_steps.push_back(record);
142 return _replicate_count;
152 _replicate_count = count;
162 if (!FltRecord::extract_record(reader)) {
178 case FO_transform_matrix:
179 return extract_transform_matrix(reader);
181 case FO_general_matrix:
189 case FO_rotate_about_edge:
193 case FO_rotate_about_point:
205 case FO_rotate_and_scale:
210 return extract_replicate_count(reader);
213 return FltRecord::extract_ancillary(reader);
217 nassertr(step !=
nullptr,
false);
218 if (!step->extract_record(reader)) {
233 if (!FltRecord::build_record(writer)) {
245 if (_has_transform) {
246 FltError result = write_transform(writer);
247 if (result != FE_ok) {
251 if (_replicate_count != 0) {
252 FltError result = write_replicate_count(writer);
253 if (result != FE_ok) {
259 return FltRecord::write_ancillary(writer);
269 nassertr(reader.
get_opcode() == FO_transform_matrix,
false);
273 for (
int r = 0; r < 4; r++) {
274 for (
int c = 0; c < 4; c++) {
280 _transform_steps.clear();
281 _has_transform =
true;
292 nassertr(reader.
get_opcode() == FO_replicate,
false);
295 _replicate_count = iterator.get_be_int16();
296 iterator.skip_bytes(2);
311 for (
int r = 0; r < 4; r++) {
312 for (
int c = 0; c < 4; c++) {
317 FltError result = writer.
advance();
318 if (result != FE_ok) {
323 Transforms::const_iterator ti;
324 for (ti = _transform_steps.begin(); ti != _transform_steps.end(); ++ti) {
325 if (!(*ti)->build_record(writer)) {
326 assert(!flt_error_abort);
327 return FE_invalid_record;
329 FltError result = writer.
advance();
330 if (result != FE_ok) {
343 if (_replicate_count != 0) {
350 FltError result = writer.
advance();
351 if (result != FE_ok) {
int get_num_transform_steps() const
Returns the number of individual steps that define the net transform on this bead as returned by set_...
void set_transform(const LMatrix4d &mat)
Replaces the transform matrix on this bead.
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.
FltTransformRecord * get_transform_step(int n)
Returns the nth individual step that defines the net transform on this bead.
void add_transform_step(FltTransformRecord *record)
Applies the indicated transform step to the net transformation applied to the bead.
PN_float32 get_be_float32()
Extracts a 32-bit big-endian single-precision floating-point number.
const LMatrix4d & get_transform() const
Returns the single-precision 4x4 matrix that represents the transform applied to this bead,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
bool has_transform() const
Returns true if the bead has been transformed, false otherwise.
The base class for all kinds of records in a MultiGen OpenFlight file.
void add_be_int16(int16_t value)
Adds a signed 16-bit big-endian integer to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void clear_transform()
Removes any transform matrix and all transform steps on this bead.
FltError advance()
Writes the current record to the flt file, and resets the current record to receive new data.
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
void set_replicate_count(int count)
Changes the replicate count of this bead.
int get_replicate_count() const
Returns the replicate count of this bead.
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.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...