16 #include "fltRecordReader.h"
17 #include "fltRecordWriter.h"
18 #include "fltTransformGeneralMatrix.h"
19 #include "fltTransformPut.h"
20 #include "fltTransformRotateAboutEdge.h"
21 #include "fltTransformRotateAboutPoint.h"
22 #include "fltTransformScale.h"
23 #include "fltTransformTranslate.h"
24 #include "fltTransformRotateScale.h"
25 #include "config_flt.h"
40 _has_transform =
false;
55 return _has_transform;
94 _has_transform =
false;
96 _transform_steps.clear();
111 return _transform_steps.size();
123 nassertr(n >= 0 && n < (
int)_transform_steps.size(),
125 return _transform_steps[n];
137 nassertr(n >= 0 && n < (
int)_transform_steps.size(),
139 return _transform_steps[n];
150 if (!_has_transform) {
151 _has_transform =
true;
154 _transform = record->
get_matrix() * _transform;
156 _transform_steps.push_back(record);
171 return _replicate_count;
184 _replicate_count = count;
197 if (!FltRecord::extract_record(reader)) {
217 case FO_transform_matrix:
218 return extract_transform_matrix(reader);
220 case FO_general_matrix:
228 case FO_rotate_about_edge:
232 case FO_rotate_about_point:
244 case FO_rotate_and_scale:
249 return extract_replicate_count(reader);
252 return FltRecord::extract_ancillary(reader);
257 if (!step->extract_record(reader)) {
275 if (!FltRecord::build_record(writer)) {
290 if (_has_transform) {
291 FltError result = write_transform(writer);
292 if (result != FE_ok) {
296 if (_replicate_count != 0) {
297 FltError result = write_replicate_count(writer);
298 if (result != FE_ok) {
304 return FltRecord::write_ancillary(writer);
318 nassertr(reader.
get_opcode() == FO_transform_matrix,
false);
322 for (
int r = 0; r < 4; r++) {
323 for (
int c = 0; c < 4; c++) {
324 matrix(r, c) = iterator.get_be_float32();
329 _transform_steps.clear();
330 _has_transform =
true;
343 nassertr(reader.
get_opcode() == FO_replicate,
false);
346 _replicate_count = iterator.get_be_int16();
347 iterator.skip_bytes(2);
365 for (
int r = 0; r < 4; r++) {
366 for (
int c = 0; c < 4; c++) {
371 FltError result = writer.
advance();
372 if (result != FE_ok) {
377 Transforms::const_iterator ti;
378 for (ti = _transform_steps.begin(); ti != _transform_steps.end(); ++ti) {
379 if (!(*ti)->build_record(writer)) {
380 assert(!flt_error_abort);
381 return FE_invalid_record;
383 FltError result = writer.
advance();
384 if (result != FE_ok) {
399 if (_replicate_count != 0) {
406 FltError result = writer.
advance();
407 if (result != FE_ok) {
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 is a 4-by-4 transform matrix.
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
int get_replicate_count() const
Returns the replicate count of this bead.
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.
const LMatrix4d & get_transform() const
Returns the single-precision 4x4 matrix that represents the transform applied to this bead...
int get_num_transform_steps() const
Returns the number of individual steps that define the net transform on this bead as returned by set_...
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
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.
static const LMatrix4d & ident_mat()
Returns an identity matrix.
The base class for all kinds of records in a MultiGen OpenFlight file.
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...
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...
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. ...
TypeHandle is the identifier used to differentiate C++ class types.
void set_replicate_count(int count)
Changes 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 ...
void add_be_int16(PN_int16 value)
Adds a signed 16-bit big-endian integer to the datagram.