Panda3D
|
00001 // Filename: transformTable.h 00002 // Created by: drose (23Mar05) 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 TRANSFORMTABLE_H 00016 #define TRANSFORMTABLE_H 00017 00018 #include "pandabase.h" 00019 #include "vertexTransform.h" 00020 #include "typedWritableReferenceCount.h" 00021 #include "pointerTo.h" 00022 #include "luse.h" 00023 #include "pvector.h" 00024 #include "cycleData.h" 00025 #include "cycleDataReader.h" 00026 #include "cycleDataWriter.h" 00027 #include "pipelineCycler.h" 00028 00029 class FactoryParams; 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Class : TransformTable 00033 // Description : Stores the total set of VertexTransforms that the 00034 // vertices in a particular GeomVertexData object might 00035 // depend on. 00036 // 00037 // This structure is used for a GeomVertexData set up to 00038 // compute its dynamic vertices on the graphics card. 00039 // See TransformBlendTable for one set up to compute 00040 // its dynamic vertices on the CPU. 00041 //////////////////////////////////////////////////////////////////// 00042 class EXPCL_PANDA_GOBJ TransformTable : public TypedWritableReferenceCount { 00043 PUBLISHED: 00044 TransformTable(); 00045 TransformTable(const TransformTable ©); 00046 void operator = (const TransformTable ©); 00047 virtual ~TransformTable(); 00048 00049 INLINE bool is_registered() const; 00050 INLINE static CPT(TransformTable) register_table(const TransformTable *table); 00051 00052 INLINE int get_num_transforms() const; 00053 INLINE const VertexTransform *get_transform(int n) const; 00054 MAKE_SEQ(get_transforms, get_num_transforms, get_transform); 00055 INLINE UpdateSeq get_modified(Thread *current_thread) const; 00056 00057 void set_transform(int n, const VertexTransform *transform); 00058 void remove_transform(int n); 00059 int add_transform(const VertexTransform *transform); 00060 00061 void write(ostream &out) const; 00062 00063 private: 00064 void do_register(); 00065 void do_unregister(); 00066 INLINE void update_modified(UpdateSeq modified, Thread *current_thread); 00067 00068 private: 00069 bool _is_registered; 00070 00071 typedef pvector< CPT(VertexTransform) > Transforms; 00072 Transforms _transforms; 00073 00074 // This is the data that must be cycled between pipeline stages. 00075 class EXPCL_PANDA_GOBJ CData : public CycleData { 00076 public: 00077 INLINE CData(); 00078 INLINE CData(const CData ©); 00079 virtual CycleData *make_copy() const; 00080 virtual void write_datagram(BamWriter *manager, Datagram &dg) const; 00081 virtual void fillin(DatagramIterator &scan, BamReader *manager); 00082 virtual TypeHandle get_parent_type() const { 00083 return TransformTable::get_class_type(); 00084 } 00085 00086 UpdateSeq _modified; 00087 }; 00088 00089 PipelineCycler<CData> _cycler; 00090 typedef CycleDataReader<CData> CDReader; 00091 typedef CycleDataWriter<CData> CDWriter; 00092 00093 public: 00094 static void register_with_read_factory(); 00095 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00096 virtual int complete_pointers(TypedWritable **plist, BamReader *manager); 00097 00098 protected: 00099 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00100 void fillin(DatagramIterator &scan, BamReader *manager); 00101 00102 public: 00103 static TypeHandle get_class_type() { 00104 return _type_handle; 00105 } 00106 static void init_type() { 00107 TypedWritableReferenceCount::init_type(); 00108 register_type(_type_handle, "TransformTable", 00109 TypedWritableReferenceCount::get_class_type()); 00110 } 00111 virtual TypeHandle get_type() const { 00112 return get_class_type(); 00113 } 00114 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00115 00116 private: 00117 static TypeHandle _type_handle; 00118 00119 friend class VertexTransform; 00120 }; 00121 00122 INLINE ostream &operator << (ostream &out, const TransformTable &obj); 00123 00124 #include "transformTable.I" 00125 00126 #endif