00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GU_RayPrimInfo_h__
00021 #define __GU_RayPrimInfo_h__
00022
00023 #include "GU_API.h"
00024 #include <UT/UT_Matrix4.h>
00025 #include <UT/UT_Matrix3.h>
00026 #include <UT/UT_Vector3.h>
00027 #include <UT/UT_Vector4Array.h>
00028 #include <UT/UT_Matrix.h>
00029 #include <UT/UT_BoundingBox.h>
00030
00031 #include "GU_RayRBezCurve.h"
00032 #include "GU_RayRBezSurf.h"
00033
00034 class GEO_Point;
00035 class GEO_Primitive;
00036 class GU_RayInfo;
00037 class GU_MinInfo;
00038 class GU_RayRBezCurve;
00039 class GU_RayRBezSurf;
00040 class TS_MetaExpression;
00041 class UT_BoundingRect;
00042 class GU_IsectCurveSet;
00043 class GU_IsectCurve;
00044
00045 class GU_API GU_Ray {
00046 public:
00047 GU_Ray(const UT_Vector3 &o, const UT_Vector3 &d, const UT_Matrix4 *mat = 0);
00048
00049 float globalDist(float t) const { return t / tscale; }
00050 float localDist(float t) const { return t * tscale; }
00051
00052 UT_Vector3 org, dir;
00053 float tscale;
00054 };
00055
00056
00057 int
00058 GU_getBilinearQuadIntersection(const UT_Vector3 &org,
00059 const UT_Vector3 &dir,
00060 const UT_Vector3 &A, const UT_Vector3 &B,
00061 const UT_Vector3 &C, const UT_Vector3 &D,
00062 const UT_Vector3 &norm,
00063 float &t, float &u, float &v, float &d2);
00064
00065
00066
00067
00068
00069 class GU_API GU_RayPrimInfo {
00070 public:
00071 GU_RayPrimInfo(const GEO_Primitive *prim);
00072
00073
00074 virtual int intersect(const UT_Vector3 &org,
00075 const UT_Vector3 &dir,
00076 GU_RayInfo &hitinfo);
00077
00078
00079 virtual int intersect(GU_RayPrimInfo *prim,
00080 GU_RayInfo &hitinfo);
00081 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00082 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00083
00084 void bumpRefCount(int dir);
00085 void getXYProjection(const UT_Vector3 &nml, int &x, int &y);
00086
00087
00088 virtual void init();
00089
00090 const GEO_Primitive *getPrim() const { return myPrim; }
00091
00092 public:
00093 const GEO_Primitive *myPrim;
00094 UT_BoundingBox bbox;
00095 float sortValue;
00096 int serial;
00097 unsigned refCount:29,
00098 degenerate:1,
00099 subclassflag:1,
00100 dirty:1;
00101
00102 protected:
00103 virtual ~GU_RayPrimInfo();
00104 };
00105
00106
00107
00108
00109
00110
00111 class GU_API GU_RayQuadricInfo : public GU_RayPrimInfo
00112 {
00113 public:
00114 GU_RayQuadricInfo(const GEO_Primitive *prim);
00115 virtual ~GU_RayQuadricInfo();
00116
00117 virtual int intersect(const UT_Vector3 &org,
00118 const UT_Vector3 &dir,
00119 GU_RayInfo &hitinfo);
00120 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &)
00121 { return -1; }
00122
00123 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00124 virtual int minimum(GU_RayPrimInfo * ,
00125 GU_MinInfo &)
00126 { return 0; }
00127 public:
00128 int circle(const GU_Ray &, GU_RayInfo &hi, UT_Vector3 &N);
00129 int sphere(const GU_Ray &, GU_RayInfo &hi, UT_Vector3 &N);
00130 int tube(const GU_Ray &, GU_RayInfo &hi, UT_Vector3 &N);
00131
00132 void minCircle(const UT_Vector3 &p, UT_Vector3 &minpt);
00133 void minSphere(const UT_Vector3 &p, UT_Vector3 &minpt);
00134 void minTube(const UT_Vector3 &p, UT_Vector3 &minpt);
00135
00136 UT_Matrix4 xform;
00137 UT_Matrix3 nmlXform;
00138 };
00139
00140
00141
00142
00143
00144
00145 class GU_API GU_RayTriangleInfo : public GU_RayPrimInfo
00146 {
00147 public:
00148 GU_RayTriangleInfo(const GEO_Primitive *prim,
00149 const GEO_Point *p0, const GEO_Point *p1,
00150 const GEO_Point *p2);
00151 virtual ~GU_RayTriangleInfo();
00152
00153 virtual void init();
00154
00155 virtual int intersect(const UT_Vector3 &org,
00156 const UT_Vector3 &dir,
00157 GU_RayInfo &hitinfo);
00158 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &) { return -1; }
00159 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00160 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00161
00162 public:
00163 const GEO_Point *myV[3];
00164 UT_Vector3 nml;
00165 float D;
00166 int x, y;
00167 };
00168
00169
00170 class GU_API GU_RayHTriangleInfo : public GU_RayPrimInfo
00171 {
00172 public:
00173 GU_RayHTriangleInfo(const GEO_Primitive *prim,
00174 const UT_Vector4 &p1, const UT_Vector4 &p2,
00175 const UT_Vector4 &p3);
00176 virtual ~GU_RayHTriangleInfo();
00177
00178 virtual void init();
00179
00180 virtual int intersect(const UT_Vector3 &org,
00181 const UT_Vector3 &dir,
00182 GU_RayInfo &hitinfo);
00183 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &) { return -1; }
00184 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00185 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00186
00187 public:
00188 UT_Vector3 myV[3];
00189 UT_Vector3 nml;
00190 float D;
00191 int x, y;
00192 };
00193
00194
00195
00196
00197
00198
00199 class GU_API GU_RayQuadInfo : public GU_RayPrimInfo
00200 {
00201 public:
00202 GU_RayQuadInfo(const GEO_Primitive *prim,
00203 const GEO_Point *p0, const GEO_Point *p1,
00204 const GEO_Point *p2, const GEO_Point *p3,
00205 float ustart = 0.0F, float ulength = 1.0F,
00206 float vstart = 0.0F, float vlength = 1.0F);
00207 virtual ~GU_RayQuadInfo();
00208
00209 virtual void init();
00210
00211 virtual int intersect(const UT_Vector3 &org,
00212 const UT_Vector3 &dir,
00213 GU_RayInfo &hitinfo);
00214 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &) { return -1; }
00215 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00216 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00217
00218 public:
00219 const GEO_Point *myV[4];
00220 UT_Vector3 nml;
00221
00222 float D;
00223 int x, y;
00224 float myUStart, myULength;
00225 float myVStart, myVLength;
00226 };
00227
00228 class GU_API GU_RayHQuadInfo : public GU_RayPrimInfo
00229 {
00230 public:
00231 GU_RayHQuadInfo(const GEO_Primitive *prim,
00232 const UT_Vector4 &p0, const UT_Vector4 &p1,
00233 const UT_Vector4 &p2, const UT_Vector4 &p3,
00234 float ustart = 0.0f, float ulen = 1.0f,
00235 float vstart = 0.0f, float vlen = 1.0f,
00236 int revnml = 0);
00237 virtual ~GU_RayHQuadInfo();
00238
00239 virtual void init();
00240
00241 virtual int intersect(const UT_Vector3 &org,
00242 const UT_Vector3 &dir,
00243 GU_RayInfo &hitinfo);
00244 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &) { return -1; }
00245 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00246 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00247
00248 public:
00249 UT_Vector3 myV[4];
00250 UT_Vector3 nml;
00251 int myRevNml;
00252
00253
00254
00255
00256
00257 float myUStart, myULength;
00258 float myVStart, myVLength;
00259 };
00260
00261
00262
00263
00264
00265
00266 class GU_API GU_RayPolyInfo : public GU_RayPrimInfo
00267 {
00268 public:
00269 GU_RayPolyInfo(const GEO_Primitive *);
00270 virtual ~GU_RayPolyInfo();
00271
00272 virtual int intersect(const UT_Vector3 &org,
00273 const UT_Vector3 &dir,
00274 GU_RayInfo &hitinfo);
00275 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &) { return -1; }
00276 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00277 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00278
00279 public:
00280 UT_Vector3 nml;
00281 float D;
00282 int x, y;
00283 };
00284
00285 class GU_API GU_RayHPolyInfo : public GU_RayPrimInfo
00286 {
00287 public:
00288 GU_RayHPolyInfo(const GEO_Primitive *,
00289 UT_Vector4Array &p);
00290 virtual ~GU_RayHPolyInfo();
00291
00292 virtual int intersect(const UT_Vector3 &org,
00293 const UT_Vector3 &dir,
00294 GU_RayInfo &hitinfo);
00295 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &) { return -1; }
00296 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00297 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00298
00299 public:
00300 int npts;
00301 float *xval;
00302 float *yval;
00303 UT_Vector3 nml;
00304 float D;
00305 int x, y;
00306 };
00307
00308
00309
00310
00311
00312
00313 class GU_API GU_RayMetaInfo : public GU_RayPrimInfo
00314 {
00315 public:
00316 GU_RayMetaInfo(TS_MetaExpression *expr);
00317 virtual ~GU_RayMetaInfo();
00318
00319 virtual int intersect(const UT_Vector3 &org,
00320 const UT_Vector3 &dir,
00321 GU_RayInfo &hitinfo);
00322 virtual int intersect(GU_RayPrimInfo *,GU_RayInfo &) { return -1; }
00323
00324 public:
00325 TS_MetaExpression *expr;
00326 };
00327
00328
00329
00330
00331
00332
00333
00334 class GU_API GU_RayPolyLineInfo : public GU_RayPrimInfo
00335 {
00336 public:
00337 GU_RayPolyLineInfo(const GEO_Primitive *, int span, int len);
00338 virtual ~GU_RayPolyLineInfo();
00339
00340 virtual int intersect(const UT_Vector3 &org, const UT_Vector3 &dir,
00341 GU_RayInfo &hitinfo);
00342 virtual int intersect(GU_RayPrimInfo *prim,
00343 GU_RayInfo &hitInfo);
00344 virtual int minimum(const UT_Vector3 &pt, GU_MinInfo &mininfo);
00345 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00346
00347 public:
00348 int mySpan;
00349 int myLen;
00350 };
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 class GU_API GU_RayCurveInfo : public GU_RayPrimInfo
00361 {
00362 public:
00363 GU_RayCurveInfo(const GEO_Primitive *curve)
00364 : GU_RayPrimInfo( curve ),
00365 myFirstSpanFlag(0), myLastSpanFlag(0) {}
00366 virtual ~GU_RayCurveInfo() {}
00367
00368 protected:
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 int intersectEndPointZone(const UT_Vector3 &org,
00386 const UT_Vector3 &dir,
00387 const GU_RayRBezCurve* curve,
00388 GU_RayInfo &hit_info) const;
00389
00390 public:
00391
00392
00393
00394 int myFirstSpanFlag : 1,
00395 myLastSpanFlag : 1;
00396 };
00397
00398 class GU_API GU_RayRBezCurveInfo : public GU_RayCurveInfo
00399 {
00400 public:
00401 GU_RayRBezCurveInfo(const GEO_Primitive *curve);
00402 virtual ~GU_RayRBezCurveInfo();
00403
00404 virtual int intersect(const UT_Vector3 &org,
00405 const UT_Vector3 &dir,
00406 GU_RayInfo &hitInfo);
00407 virtual int intersect(GU_RayPrimInfo *prim,
00408 GU_RayInfo &hitInfo);
00409 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00410 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00411 GU_RayRBezCurve *buildCurve();
00412
00413 public:
00414 int mySpan;
00415 GU_RayRBezCurve *myCurve;
00416 };
00417
00418 class GU_API GU_RayNURBCurveInfo : public GU_RayCurveInfo
00419 {
00420 public:
00421 GU_RayNURBCurveInfo(const GEO_Primitive *curve);
00422 virtual ~GU_RayNURBCurveInfo();
00423
00424 virtual int intersect(const UT_Vector3 &org,
00425 const UT_Vector3 &dir,
00426 GU_RayInfo &hitInfo);
00427 virtual int intersect(GU_RayPrimInfo *prim,
00428 GU_RayInfo &hitInfo);
00429 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &mininfo);
00430 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00431
00432 public:
00433 GU_RayRBezCurve myCurve;
00434 };
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444 class GU_API GU_RayRBezSurfInfo : public GU_RayPrimInfo
00445 {
00446 public:
00447 GU_RayRBezSurfInfo(const GEO_Primitive *surf);
00448 virtual ~GU_RayRBezSurfInfo();
00449
00450 virtual int intersect(const UT_Vector3 &org,
00451 const UT_Vector3 &dir,
00452 GU_RayInfo &hitInfo);
00453 virtual int intersect(GU_RayPrimInfo *prim,
00454 GU_RayInfo &hitinfo);
00455 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00456 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &hitinfo);
00457 virtual GU_RayRBezSurf *buildSurf();
00458
00459 public:
00460 int myUSpan, myVSpan;
00461 GU_RayRBezSurf *mySurf;
00462 };
00463
00464 class GU_API GU_RayNURBSurfInfo : public GU_RayPrimInfo
00465 {
00466 public:
00467 GU_RayNURBSurfInfo(const GEO_Primitive *surf);
00468 virtual ~GU_RayNURBSurfInfo();
00469
00470 virtual int intersect(const UT_Vector3 &org,
00471 const UT_Vector3 &dir,
00472 GU_RayInfo &hitInfo);
00473 virtual int intersect(GU_RayPrimInfo *prim,
00474 GU_RayInfo &hitinfo);
00475 virtual int minimum(const UT_Vector3 &p, GU_MinInfo &mininfo);
00476 virtual int minimum(GU_RayPrimInfo *prim, GU_MinInfo &hitinfo);
00477 public:
00478 GU_RayRBezSurf mySurf;
00479 };
00480
00481
00482
00483
00484
00485
00486
00487 class GU_API GU_RayMovingTriangleInfo : public GU_RayPrimInfo
00488 {
00489 public:
00490 GU_RayMovingTriangleInfo(const GEO_Primitive *prim0,
00491 const GEO_Point *p00, const GEO_Point *p01,
00492 const GEO_Point *p02,
00493 const GEO_Primitive *prim1,
00494 const GEO_Point *p10, const GEO_Point *p11,
00495 const GEO_Point *p12);
00496 virtual ~GU_RayMovingTriangleInfo();
00497
00498 virtual void init();
00499
00500 virtual int intersect(const UT_Vector3 &org,
00501 const UT_Vector3 &dir,
00502 GU_RayInfo &hitinfo);
00503
00504 private:
00505 int insertHit(const UT_Vector3 &org,
00506 const UT_Vector3 &dir,
00507 GU_RayInfo &hitinfo,
00508 float t, float nt);
00509
00510 public:
00511 const GEO_Point *myV0[3];
00512 const GEO_Point *myV1[3];
00513
00514 double a2, a1, a0;
00515 double b2, b1, b0;
00516 double c2, c1, c0;
00517 };
00518
00519
00520 #endif