00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GZ_PARAMETRIC_H__
00023 #define __GZ_PARAMETRIC_H__
00024
00030
00031
00032
00033 #include "gzGeometry.h"
00034
00035 class gzParametricGeometry;
00036
00037
00038
00039 const gzFloat I_127 = GZ_FLOAT_ONE/127.0f;
00040
00041 const gzFloat I_127_2=I_127*I_127;
00042
00043
00044 class gzLODContainerItem;
00045 class gzLODContainer;
00046 class gzParametricGeometry;
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class gzLODItem
00063 {
00064 private:
00065 friend class gzLODContainerItem;
00066 friend class gzLODContainer;
00067 friend class gzParametricGeometry;
00068
00069 gzByte n_x,n_y,n_z;
00070 gzBool renderChildren;
00071 gzFloat diff2;
00072 gzUShort counter;
00073
00074 gzBool GZ_FASTCALL isLODVisible(gzParametricGeometry *geom,gzLODContainerItem *item);
00075
00076 };
00077
00078
00079 class gzLODSize
00080 {
00081 public:
00082 gzFloat diff2;
00083 gzByte n_x,n_y,n_z;
00084 };
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 class gzLODContainerItem
00101 {
00102 private:
00103
00104 friend class gzLODContainer;
00105 friend class gzParametricGeometry;
00106 friend class gzLODItem;
00107
00108 gzLODContainerItem *leftChild,*rightChild;
00109 gzLODContainerItem * split;
00110 gzLODContainerItem * parent;
00111
00112 gzULong v0_s;
00113 gzULong v0_t;
00114 gzULong index_0;
00115
00116 gzULong v1_s;
00117 gzULong v1_t;
00118 gzULong index_1;
00119
00120 gzULong va_s;
00121 gzULong va_t;
00122 gzULong index_a;
00123
00124 gzULong vc_s;
00125 gzULong vc_t;
00126 gzULong index_c;
00127
00128 gzULong index;
00129
00130 gzBool checkSplit(gzParametricGeometry *geom);
00131
00132 gzVec3 calculateCenterDiff(gzParametricGeometry *geom);
00133 gzLODSize completeUnifyDynamicLOD(gzParametricGeometry *geom);
00134
00135 gzBool updateIndex(gzParametricGeometry *geom);
00136 gzVoid forceSplit(gzParametricGeometry *geom);
00137 gzVoid updateSplit(gzParametricGeometry *geom);
00138 gzVoid renderIndex(gzParametricGeometry *geom , gzUByte toggle=0);
00139
00140 gzVoid isectorIndex(gzParametricGeometry *geom,gzIntersectorAction *isector,gzContext *context);
00141 };
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 class gzLODContainer : public gzReference
00159 {
00160 public:
00161
00162 gzLODContainer(gzULong s_index, gzULong t_index,gzULong max_t_index);
00163 virtual ~gzLODContainer();
00164
00165 private:
00166
00167 friend class gzParametricGeometry;
00168
00169 static gzLODContainer *getLODContainer(gzULong s_index, gzULong t_index);
00170
00171 gzLODContainerItem *createLODItem(gzULong v0_s,gzULong v0_t,gzULong v1_s,gzULong v1_t,gzULong va_s,gzULong va_t,gzLODContainerItem *parent,gzULong max_t_index);
00172
00173 gzVoid deleteLODItem(gzLODContainerItem *item);
00174
00175 gzVoid createSplit(gzLODContainerItem *item);
00176
00177 gzLODContainerItem *findSplit(gzLODContainerItem *split,gzLODContainerItem *search);
00178
00179 gzVoid updateMergeBoundary(gzParametricGeometry *geom);
00180
00181 gzLODContainerItem *tree_a,*tree_b,*item;
00182 gzLODItem *lod_item;
00183 gzList<gzLODContainerItem> boundaryTree;
00184
00185 gzListIterator<gzLODContainerItem> iterator;
00186
00187 gzULong s_index_size;
00188 gzULong t_index_size;
00189
00190 gzULong lod_index_size;
00191 };
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00215 class gzParametricGeometry : public gzBaseGeometry
00216 {
00217 public:
00218
00219 GZ_GRAPH_EXPORT gzParametricGeometry(const gzString & name=GZ_EMPTY_STRING);
00220 GZ_GRAPH_EXPORT virtual ~gzParametricGeometry(){};
00221
00222 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00223
00224
00225
00226
00227 GZ_GRAPH_EXPORT virtual gzReference* clone() const=0;
00228 GZ_GRAPH_EXPORT virtual gzBool useDeepCopy();
00229
00230
00231
00232
00233
00234
00235 GZ_GRAPH_EXPORT virtual gzVoid updateNode();
00236
00237
00238
00239 GZ_GRAPH_EXPORT virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00240
00241
00242
00244 GZ_GRAPH_EXPORT gzVoid setStartParams( gzDouble start_s , gzDouble start_t );
00245
00247 GZ_GRAPH_EXPORT gzVoid setStopParams( gzDouble stop_s , gzDouble stop_t );
00248
00250 GZ_GRAPH_EXPORT gzVoid setStepParams( gzDouble step_s , gzDouble step_t );
00251
00255 GZ_GRAPH_EXPORT gzVoid setStepIndex( gzUShort count_s_index , gzUShort count_t_index );
00256
00257 GZ_GRAPH_EXPORT gzVoid getStepIndex( gzUShort &count_s_index , gzUShort &count_t_index );
00258
00260 GZ_GRAPH_EXPORT gzVoid setLODFactor( gzFloat factor );
00261
00264 GZ_GRAPH_EXPORT gzVoid createDynamicLOD();
00265
00267 GZ_GRAPH_EXPORT gzVoid deleteDynamicLOD();
00268
00270 GZ_GRAPH_EXPORT gzVoid createPatch();
00271
00273 GZ_GRAPH_EXPORT gzVoid useColor(gzBool on) { m_useColor=on;}
00274
00276 GZ_GRAPH_EXPORT gzVoid useTexture(gzBool on,gzULong unit=0) { m_useTexture[unit]=on;}
00277
00279 GZ_GRAPH_EXPORT gzVoid useNormal(gzBool on) { m_useNormal=on;}
00280
00282 GZ_GRAPH_EXPORT virtual gzVec3 getCoordinate(gzDouble s , gzDouble t);
00283
00285 GZ_GRAPH_EXPORT virtual gzVec3 getNormal(gzDouble s , gzDouble t);
00286
00288 GZ_GRAPH_EXPORT virtual gzVec4 getColor(gzDouble s , gzDouble t);
00289
00291 GZ_GRAPH_EXPORT virtual gzVec2 getTexCoordinate(gzDouble s , gzDouble t , gzULong unit);
00292
00296 GZ_GRAPH_EXPORT gzBool unifyDynamicLOD(gzParametricGeometry *geometry);
00297
00298 GZ_GRAPH_EXPORT gzVoid setTextureUnits( gzULong size=1 );
00299 GZ_GRAPH_EXPORT gzULong getTextureUnits();
00300
00301
00302 GZ_GRAPH_EXPORT gzArray<gzVec3> & getCoordinateArray();
00303
00304
00305 GZ_GRAPH_EXPORT gzFloat getPointSize();
00306 GZ_GRAPH_EXPORT gzVoid setPointSize(gzFloat size);
00307
00308 GZ_GRAPH_EXPORT gzFloat getLineWidth();
00309 GZ_GRAPH_EXPORT gzVoid setLineWidth(gzFloat size);
00310
00311 GZ_GRAPH_EXPORT gzVoid setViewParams(gzFloat midTVal, gzFloat smallTVal );
00312
00313
00314 protected:
00315
00316
00317
00318 friend class gzLODContainerItem;
00319 friend class gzLODContainer;
00320 friend class gzLODItem;
00321
00322 GZ_GRAPH_EXPORT gzVoid outputIndex(gzULong index);
00323 GZ_GRAPH_EXPORT gzVoid outputIndexSplit(gzLODContainerItem *item);
00324 GZ_GRAPH_EXPORT gzVoid outputIndex(gzLODContainerItem *item);
00325
00326 GZ_GRAPH_EXPORT gzVoid isectorIndexSplit(gzLODContainerItem *item,gzIntersectorAction *isector,gzContext *context);
00327 GZ_GRAPH_EXPORT gzVoid isectorIndex(gzLODContainerItem *item,gzIntersectorAction *isector,gzContext *context);
00328
00329 GZ_GRAPH_EXPORT gzVoid calculateMaxIndex();
00330
00331 GZ_GRAPH_EXPORT gzVoid virtual calculateIntersections(gzIntersectorAction *isector , gzContext *context);
00332
00333
00334
00335 gzDouble m_start_s , m_start_t;
00336 gzDouble m_stop_s , m_stop_t;
00337 gzDouble m_step_s , m_step_t;
00338 gzUShort m_max_index_s , m_max_index_t;
00339
00340 gzVec3 m_eye,m_geneye;
00341
00342 gzArray<gzBool> m_useTexture;
00343 gzBool m_useColor:1,m_useNormal:1;
00344 gzFloat m_pointSize;
00345 gzFloat m_lineWidth;
00346
00347
00348
00349 gzArray<gzVec3> m_coordinates;
00350 gzArray<gzVec3> m_normals;
00351 gzArray<gzVec4> m_colors;
00352 gzArray< gzArray<gzVec2> > m_tex_coordinates;
00353
00354
00355
00356 gzFloat m_LODfactor;
00357 gzArray<gzLODItem> m_lodArray;
00358 gzLODItem *m_lodAddress;
00359 gzVec3 *m_coordAddress;
00360 gzUShort m_counter,m_lastCounter;
00361
00362 gzFloat m_midTVal,m_smallTVal;
00363
00364 gzArray<gzULong> m_indexArray;
00365 gzULong *m_indexAdress;
00366 gzULong m_indexCounter;
00367
00368 gzRefPointer<gzLODContainer> m_lodContainer;
00369
00370 };
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 gzVoid GZ_GRAPH_EXPORT gzUnifyDynamicLOD(gzMatrix<gzParametricGeometry *> &matrix);
00391
00392
00393 #endif
00394