64 return _children.size();
72 nassertr(n >= 0 && n < (
int)_children.size(),
nullptr);
89 _children.push_back(child);
99 return _subfaces.size();
107 nassertr(n >= 0 && n < (
int)_subfaces.size(),
nullptr);
124 _subfaces.push_back(subface);
134 return _extensions.size();
142 nassertr(n >= 0 && n < (
int)_extensions.size(),
nullptr);
143 return _extensions[n];
160 _extensions.push_back(extension);
172 return _ancillary.size();
181 nassertr(n >= 0 && n < (
int)_ancillary.size(),
nullptr);
182 return _ancillary[n];
208 _ancillary.push_back(ancillary);
216 return !_comment.empty();
261 <<
" bytes at the end of a ";
267 nout <<
" record.\n";
279 Records::const_iterator ci;
280 for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
281 (*ci)->apply_converted_filenames();
283 for (ci = _children.begin(); ci != _children.end(); ++ci) {
284 (*ci)->apply_converted_filenames();
304 write(std::ostream &out,
int indent_level)
const {
305 indent(out, indent_level) << *
this;
306 write_children(out, indent_level);
314 write_children(std::ostream &out,
int indent_level)
const {
315 if (!_ancillary.empty()) {
316 out <<
" + " << _ancillary.size() <<
" ancillary";
318 if (!_extensions.empty()) {
319 out <<
" + " << _extensions.size() <<
" extensions";
321 if (!_subfaces.empty()) {
323 Records::const_iterator ci;
324 for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
325 out <<
" " << *(*ci);
329 if (!_children.empty()) {
331 Records::const_iterator ci;
332 for (ci = _children.begin(); ci != _children.end(); ++ci) {
333 (*ci)->write(out, indent_level + 2);
335 indent(out, indent_level) <<
"}\n";
354 is_ancillary(FltOpcode opcode) {
358 case FO_multitexture:
362 case FO_transform_matrix:
363 case FO_rotate_about_edge:
366 case FO_rotate_about_point:
367 case FO_rotate_and_scale:
369 case FO_general_matrix:
371 case FO_bounding_box:
372 case FO_bounding_sphere:
373 case FO_bounding_cylinder:
375 case FO_bv_orientation:
376 case FO_local_vertex_pool:
379 case FO_14_material_palette:
380 case FO_vertex_palette:
385 case FO_color_palette:
389 case FO_eyepoint_palette:
390 case FO_light_definition:
391 case FO_texture_map_palette:
396 case FO_mesh_primitive:
405 case FO_external_ref:
408 case FO_light_source:
409 case FO_road_segment:
410 case FO_road_construction:
424 case FO_push_attribute:
425 case FO_pop_attribute:
426 case FO_push_extension:
427 case FO_pop_extension:
429 case FO_instance_ref:
433 nout <<
"Don't know whether " << opcode <<
" is ancillary.\n";
443 create_new_record(FltOpcode opcode)
const {
460 case FO_local_vertex_pool:
463 case FO_mesh_primitive:
470 return new FltLOD(_header);
475 case FO_instance_ref:
478 case FO_external_ref:
485 nout <<
"Ignoring unsupported record " << opcode <<
"\n";
500 if (!extract_record(reader)) {
501 nout <<
"Could not extract record for " << *
this <<
"\n";
502 assert(!flt_error_abort);
503 return FE_invalid_record;
505 FltError result = reader.
advance();
506 if (result == FE_end_of_file) {
508 }
else if (result != FE_ok) {
513 if (extract_ancillary(reader)) {
519 if (result != FE_ok) {
525 FltError result = child->read_record_and_children(reader);
526 if (result != FE_ok) {
530 if (child->is_of_type(FltInstanceDefinition::get_class_type())) {
540 if (reader.
eof() || reader.
error()) {
541 assert(!flt_error_abort);
542 return FE_end_of_file;
546 }
else if (reader.
get_opcode() == FO_push_face) {
549 if (result != FE_ok) {
555 FltError result = subface->read_record_and_children(reader);
556 if (result != FE_ok) {
560 if (reader.
eof() || reader.
error()) {
561 assert(!flt_error_abort);
562 return FE_end_of_file;
566 }
else if (reader.
get_opcode() == FO_push_extension) {
569 if (result != FE_ok) {
573 while (reader.
get_opcode() != FO_pop_extension) {
575 FltError result = extension->read_record_and_children(reader);
576 if (result != FE_ok) {
580 if (reader.
eof() || reader.
error()) {
581 assert(!flt_error_abort);
582 return FE_end_of_file;
586 }
else if (is_ancillary(reader.
get_opcode())) {
589 ancillary->extract_record(reader);
590 _ancillary.push_back(ancillary);
599 if (reader.
eof() || result != FE_ok) {
640 if (!build_record(writer)) {
641 assert(!flt_error_abort);
645 FltError result = writer.
advance();
646 if (result != FE_ok) {
651 result = write_ancillary(writer);
652 if (result != FE_ok) {
655 Records::const_iterator ci;
656 for (ci = _ancillary.begin(); ci != _ancillary.end(); ++ci) {
657 if (!(*ci)->build_record(writer)) {
658 assert(!flt_error_abort);
662 if (result != FE_ok) {
668 if (!_extensions.empty()) {
670 if (result != FE_ok) {
674 for (ci = _extensions.begin(); ci != _extensions.end(); ++ci) {
675 (*ci)->write_record_and_children(writer);
679 if (result != FE_ok) {
685 if (!_children.empty()) {
687 if (result != FE_ok) {
691 for (ci = _children.begin(); ci != _children.end(); ++ci) {
692 (*ci)->write_record_and_children(writer);
696 if (result != FE_ok) {
703 if (!_subfaces.empty()) {
705 if (result != FE_ok) {
709 for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
710 (*ci)->write_record_and_children(writer);
714 if (result != FE_ok) {
738 if (!_comment.empty()) {
739 Datagram dc(_comment.data(), _comment.size());
741 if (result != FE_ok) {
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void clear_comment()
Removes the comment for this record.
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly.
void clear_ancillary()
Removes all unsupported ancillary records from this record.
void clear_extensions()
Removes all extensions from this record.
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.
FltRecord * get_ancillary(int n) const
Returns the nth unsupported ancillary record of this record.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_children() const
Returns the number of child records of this record.
FltRecord * get_extension(int n) const
Returns the nth extension of this record.
The main grouping bead of the flt file.
virtual void apply_converted_filenames()
Walks the hierarchy at this record and below and copies the _converted_filename record into the _orig...
bool error() const
Returns true if some error has been encountered while reading (for instance, a truncated file).
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single primitive of a mesh, like a triangle strip or fan.
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
void add_child(FltRecord *child)
Adds a new child to the end of the list of children for this record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
size_t get_remaining_size() const
Return the bytes left in the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_comment() const
Returns true if this record has a nonempty comment, false otherwise.
A local vertex pool, as might appear in the middle of the hierarchy, for instance for a mesh.
const std::string & get_comment() const
Retrieves the comment for this record, or empty string if the record has no comment.
FltRecord * get_subface(int n) const
Returns the nth subface of this record.
A mesh of connected polygons and tristrips, etc., with a local vertex pool.
A list of vertices, typically added as a child of a face bead.
void set_comment(const std::string &comment)
Changes the comment for this record.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The base class for all kinds of records in a MultiGen OpenFlight file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This bead appears in the hierarchy to refer to a FltInstanceDefinition node defined elsewhere.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An external reference to another flt file (possibly to a specific bead within the flt file).
FltError advance()
Writes the current record to the flt file, and resets the current record to receive new data.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The main objecting bead of the flt file.
FltRecord * get_child(int n) const
Returns the nth child of this record.
void add_extension(FltRecord *extension)
Adds a new extension to the end of the list of extensions for this record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_subface(FltRecord *subface)
Adds a new subface to the end of the list of subfaces for this record.
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void output(std::ostream &out) const
Writes a quick one-line description of the record, but not its children.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
void add_ancillary(FltRecord *ancillary)
Adds a new unsupported ancillary record to the end of the list of ancillary records for this record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
A single curve, like a Bezier or B-Spline.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
A Level-of-Detail record.
FltError advance(bool ok_eof=false)
Extracts the next record from the file.
int get_num_ancillary() const
Returns the number of unsupported ancillary records of this record.
void clear_children()
Removes all children from this record.
void clear_subfaces()
Removes all subfaces from this record.
virtual void write(std::ostream &out, int indent_level=0) const
Writes a multiple-line description of the record and all of its children.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This special kind of record marks the top node of an instance subtree.
This is an ancillary record of the old (pre-15.4) face node.
int get_num_subfaces() const
Returns the number of subface records of this record.
int get_num_extensions() const
Returns the number of extension attribute records for this object.
bool eof() const
Returns true if end-of-file has been reached without error.
FltError write_record(FltOpcode opcode, const Datagram &datagram=Datagram())
A convenience function to quickly write a simple record that consists of an opcode and possibly a dat...
std::string get_fixed_string(size_t size)
Extracts a fixed-length string.