00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef GEOMVERTEXWRITER_H
00016 #define GEOMVERTEXWRITER_H
00017
00018 #include "pandabase.h"
00019 #include "geomVertexData.h"
00020 #include "geomVertexColumn.h"
00021 #include "internalName.h"
00022 #include "luse.h"
00023 #include "pointerTo.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 class EXPCL_PANDA_GOBJ GeomVertexWriter : public GeomEnums {
00070 PUBLISHED:
00071 INLINE GeomVertexWriter(Thread *current_thread = Thread::get_current_thread());
00072 INLINE GeomVertexWriter(GeomVertexData *vertex_data,
00073 Thread *current_thread = Thread::get_current_thread());
00074 INLINE GeomVertexWriter(GeomVertexData *vertex_data,
00075 const string &name,
00076 Thread *current_thread = Thread::get_current_thread());
00077 INLINE GeomVertexWriter(GeomVertexData *vertex_data,
00078 const InternalName *name,
00079 Thread *current_thread = Thread::get_current_thread());
00080 INLINE GeomVertexWriter(GeomVertexArrayData *array_data,
00081 Thread *current_thread = Thread::get_current_thread());
00082 INLINE GeomVertexWriter(GeomVertexArrayData *array_data,
00083 int column,
00084 Thread *current_thread = Thread::get_current_thread());
00085
00086 public:
00087 INLINE GeomVertexWriter(GeomVertexDataPipelineWriter *data_writer,
00088 const InternalName *name);
00089
00090 PUBLISHED:
00091 INLINE GeomVertexWriter(const GeomVertexWriter ©);
00092 INLINE void operator = (const GeomVertexWriter ©);
00093 INLINE ~GeomVertexWriter();
00094
00095 INLINE GeomVertexData *get_vertex_data() const;
00096 INLINE GeomVertexArrayData *get_array_data() const;
00097 INLINE GeomVertexArrayDataHandle *get_array_handle() const;
00098 INLINE size_t get_stride() const;
00099 INLINE Thread *get_current_thread() const;
00100
00101 INLINE bool set_column(int column);
00102 INLINE bool set_column(const string &name);
00103 INLINE bool set_column(const InternalName *name);
00104 bool set_column(int array, const GeomVertexColumn *column);
00105 INLINE void clear();
00106 bool reserve_num_rows(int num_rows);
00107
00108 INLINE bool has_column() const;
00109 INLINE int get_array() const;
00110 INLINE const GeomVertexColumn *get_column() const;
00111
00112 INLINE void set_row_unsafe(int row);
00113 INLINE void set_row(int row);
00114
00115 INLINE int get_start_row() const;
00116 INLINE int get_write_row() const;
00117 INLINE bool is_at_end() const;
00118
00119 INLINE void set_data1f(float data);
00120 INLINE void set_data2f(float x, float y);
00121 INLINE void set_data2f(const LVecBase2f &data);
00122 INLINE void set_data3f(float x, float y, float z);
00123 INLINE void set_data3f(const LVecBase3f &data);
00124 INLINE void set_data4f(float x, float y, float z, float w);
00125 INLINE void set_data4f(const LVecBase4f &data);
00126
00127 INLINE void set_data1d(double data);
00128 INLINE void set_data2d(double x, double y);
00129 INLINE void set_data2d(const LVecBase2d &data);
00130 INLINE void set_data3d(double x, double y, double z);
00131 INLINE void set_data3d(const LVecBase3d &data);
00132 INLINE void set_data4d(double x, double y, double z, double w);
00133 INLINE void set_data4d(const LVecBase4d &data);
00134
00135 INLINE void set_data1(PN_stdfloat data);
00136 INLINE void set_data2(PN_stdfloat x, PN_stdfloat y);
00137 INLINE void set_data2(const LVecBase2 &data);
00138 INLINE void set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
00139 INLINE void set_data3(const LVecBase3 &data);
00140 INLINE void set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w);
00141 INLINE void set_data4(const LVecBase4 &data);
00142
00143 INLINE void set_data1i(int data);
00144 INLINE void set_data2i(int a, int b);
00145 INLINE void set_data2i(const int data[2]);
00146 INLINE void set_data3i(int a, int b, int c);
00147 INLINE void set_data3i(const int data[3]);
00148 INLINE void set_data4i(int a, int b, int c, int d);
00149 INLINE void set_data4i(const int data[4]);
00150
00151 INLINE void add_data1f(float data);
00152 INLINE void add_data2f(float x, float y);
00153 INLINE void add_data2f(const LVecBase2f &data);
00154 INLINE void add_data3f(float x, float y, float z);
00155 INLINE void add_data3f(const LVecBase3f &data);
00156 INLINE void add_data4f(float x, float y, float z, float w);
00157 INLINE void add_data4f(const LVecBase4f &data);
00158
00159 INLINE void add_data1d(double data);
00160 INLINE void add_data2d(double x, double y);
00161 INLINE void add_data2d(const LVecBase2d &data);
00162 INLINE void add_data3d(double x, double y, double z);
00163 INLINE void add_data3d(const LVecBase3d &data);
00164 INLINE void add_data4d(double x, double y, double z, double w);
00165 INLINE void add_data4d(const LVecBase4d &data);
00166
00167 INLINE void add_data1(PN_stdfloat data);
00168 INLINE void add_data2(PN_stdfloat x, PN_stdfloat y);
00169 INLINE void add_data2(const LVecBase2 &data);
00170 INLINE void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
00171 INLINE void add_data3(const LVecBase3 &data);
00172 INLINE void add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w);
00173 INLINE void add_data4(const LVecBase4 &data);
00174
00175 INLINE void add_data1i(int data);
00176 INLINE void add_data2i(int a, int b);
00177 INLINE void add_data2i(const int data[2]);
00178 INLINE void add_data3i(int a, int b, int c);
00179 INLINE void add_data3i(const int data[3]);
00180 INLINE void add_data4i(int a, int b, int c, int d);
00181 INLINE void add_data4i(const int data[4]);
00182
00183 void output(ostream &out) const;
00184
00185 protected:
00186 INLINE GeomVertexColumn::Packer *get_packer() const;
00187
00188 private:
00189 class Writer;
00190
00191 void initialize();
00192
00193 INLINE void set_pointer(int row);
00194 INLINE void quick_set_pointer(int row);
00195 INLINE unsigned char *inc_pointer();
00196 INLINE unsigned char *inc_add_pointer();
00197
00198 bool set_vertex_column(int array, const GeomVertexColumn *column,
00199 GeomVertexDataPipelineWriter *data_writer);
00200 bool set_array_column(const GeomVertexColumn *column);
00201
00202
00203
00204
00205
00206
00207 PT(GeomVertexData) _vertex_data;
00208 int _array;
00209 PT(GeomVertexArrayData) _array_data;
00210
00211 Thread *_current_thread;
00212 GeomVertexColumn::Packer *_packer;
00213 int _stride;
00214
00215 PT(GeomVertexArrayDataHandle) _handle;
00216 unsigned char *_pointer_begin;
00217 unsigned char *_pointer_end;
00218 unsigned char *_pointer;
00219
00220 int _start_row;
00221
00222 #ifndef NDEBUG
00223
00224
00225 static unsigned char empty_buffer[100];
00226 #endif
00227 };
00228
00229 INLINE ostream &
00230 operator << (ostream &out, const GeomVertexWriter &writer) {
00231 writer.output(out);
00232 return out;
00233 }
00234
00235 #include "geomVertexWriter.I"
00236
00237 #endif