00001 // Filename: fltBead.h 00002 // Created by: drose (24Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef FLTBEAD_H 00016 #define FLTBEAD_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "fltRecord.h" 00021 #include "fltTransformRecord.h" 00022 00023 #include "luse.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : FltBead 00027 // Description : A base class for any of a broad family of flt records 00028 // that represent particular beads in the hierarchy. 00029 // These are things like group beads and object beads, 00030 // as opposed to things like push and pop or comment 00031 // records. 00032 //////////////////////////////////////////////////////////////////// 00033 class FltBead : public FltRecord { 00034 public: 00035 FltBead(FltHeader *header); 00036 00037 bool has_transform() const; 00038 const LMatrix4d &get_transform() const; 00039 void set_transform(const LMatrix4d &mat); 00040 void clear_transform(); 00041 00042 int get_num_transform_steps() const; 00043 FltTransformRecord *get_transform_step(int n); 00044 const FltTransformRecord *get_transform_step(int n) const; 00045 void add_transform_step(FltTransformRecord *record); 00046 00047 int get_replicate_count() const; 00048 void set_replicate_count(int count); 00049 00050 protected: 00051 virtual bool extract_record(FltRecordReader &reader); 00052 virtual bool extract_ancillary(FltRecordReader &reader); 00053 00054 virtual bool build_record(FltRecordWriter &writer) const; 00055 virtual FltError write_ancillary(FltRecordWriter &writer) const; 00056 00057 private: 00058 bool extract_transform_matrix(FltRecordReader &reader); 00059 bool extract_replicate_count(FltRecordReader &reader); 00060 00061 FltError write_transform(FltRecordWriter &writer) const; 00062 FltError write_replicate_count(FltRecordWriter &writer) const; 00063 00064 private: 00065 bool _has_transform; 00066 LMatrix4d _transform; 00067 00068 typedef pvector<PT(FltTransformRecord)> Transforms; 00069 Transforms _transform_steps; 00070 00071 int _replicate_count; 00072 00073 public: 00074 virtual TypeHandle get_type() const { 00075 return get_class_type(); 00076 } 00077 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00078 static TypeHandle get_class_type() { 00079 return _type_handle; 00080 } 00081 static void init_type() { 00082 FltRecord::init_type(); 00083 register_type(_type_handle, "FltBead", 00084 FltRecord::get_class_type()); 00085 } 00086 00087 private: 00088 static TypeHandle _type_handle; 00089 }; 00090 00091 #endif 00092 00093