00001 // 00002 // Copyright (c) 2000 by Tech Soft 3D, LLC. 00003 // The information contained herein is confidential and proprietary to 00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 // civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 // and criminal remedies in the event of unauthorized use or misappropriation 00007 // of its trade secrets. Use of this information by anyone other than 00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 // written non-disclosure agreement, expressly prescribing the scope and 00010 // manner of such use. 00011 // 00012 // $Id: 494d2972e3b1cc783f11edff65f287822c47dafc $ 00013 // 00014 00018 #ifndef _H_GLOBALS_H 00019 #define _H_GLOBALS_H 00020 00021 #ifdef H_PACK_8 00022 #pragma pack(push) 00023 #pragma pack(8) 00024 #endif 00025 00029 enum HFileIOResult 00030 { 00031 HIO_OK = 1, 00032 HIO_VersionMismatch = 2, 00033 HIO_Fail = 3, 00034 HIO_NotHandled = 4, 00035 HIO_BadFileName = 5, 00036 HIO_BadOptions = 6, 00037 HIO_BadLicense = 7, 00038 HIO_LibraryNotFound = 8 00039 }; 00040 00041 #define HFileInputResult HFileIOResult 00042 #define InputOK HIO_OK 00043 #define InputVersionMismatch HIO_VersionMismatch 00044 #define InputFail HIO_Fail 00045 #define InputNotHandled HIO_NotHandled 00046 #define InputBadFileName HIO_BadFileName 00047 #define InputBadOptions HIO_BadOptions 00048 #define InputBadLicense HIO_BadLicense 00049 #define InputLibraryNotFound HIO_LibraryNotFound 00050 00051 00052 #define HFileOutputResult HFileIOResult 00053 #define OutputOK HIO_OK 00054 #define OutputVersionMismatch HIO_VersionMismatch 00055 #define OutputFail HIO_Fail 00056 #define OutputNotHandled HIO_NotHandled 00057 #define OutputBadFileName HIO_BadFileName 00058 #define OutputBadOptions HIO_BadOptions 00059 #define OutputBadLicense HIO_BadLicense 00060 #define OutputLibraryNotFound HIO_LibraryNotFound 00061 00065 #define LAST_HFileInputResult InputBadOptions 00066 00069 #define LAST_HFileOutputResult OutputBadOptions 00070 00075 enum HSignal 00076 { 00077 HSignalDelete = 1, 00078 HSignalCameraPositionChanged = 2, 00079 HSignalSelected = 3, 00080 HSignalDeSelectedOne = 4, 00081 HSignalDeSelectedAll = 5, 00082 HSignalPaint = 6, 00083 HSignalClash = 7, 00084 HSignalRenderModeChanged = 8, 00085 HSignalResize = 9 00086 }; 00087 00091 #define LAST_HSignal HSignalClash 00092 00093 00097 enum HShadowMode 00098 { 00099 HShadowNone = 1, 00100 HShadowSoft = 2, 00101 HShadowHard = 3 00102 }; 00103 00107 enum HCutGeometryVisibility 00108 { 00109 HCutGeometryVisibilityNone = 0x0, 00110 HCutGeometryVisibilityFaces = 0x1, 00111 HCutGeometryVisibilityEdges = 0x2, 00112 HCutGeometryVisibilityAll = HCutGeometryVisibilityFaces | HCutGeometryVisibilityEdges 00113 }; 00114 00118 #define LAST_HShadowMode HShadowHard 00119 00121 00126 class MVO_API HPoint 00127 { 00128 public: 00129 float x; 00130 float y; 00131 float z; 00132 00134 HPoint() : x(0), y(0), z(0) {}; 00135 00137 HPoint(float X, float Y, float Z=0.0f) : x(X), y(Y), z(Z) {}; 00138 00140 HPoint(HPoint const * p) : x(p->x), y(p->y), z(p->z) {}; 00141 00143 HPoint(HPoint const & p) : x(p.x), y(p.y), z(p.z) {}; 00144 00146 void Set(float X, float Y, float Z=0.0f) { x=X; y=Y; z=Z; }; 00147 00149 void Set(HPoint *p) { x=p->x; y=p->y; z=p->z; }; 00150 00152 void Set(HPoint const *p) { x=p->x; y=p->y; z=p->z; }; 00153 00155 void Set(HPoint &p) { x=p.x; y=p.y; z=p.z; }; 00156 00158 void Set(const HPoint &p) { x=p.x; y=p.y; z=p.z; }; 00159 00165 void Add(float X, float Y, float Z=0.0){ x+=X; y+=Y; z+=Z; }; 00166 00167 HPoint const operator -(const HPoint &p2) const 00168 { 00169 return HPoint(x-p2.x, y-p2.y, z-p2.z); 00170 } 00171 00172 HPoint const operator +(const HPoint &p2) const 00173 { 00174 return HPoint(x+p2.x, y+p2.y, z+p2.z); 00175 } 00176 00177 HPoint const operator *(float const rhs) const 00178 { 00179 return HPoint(x*rhs, y*rhs, z*rhs); 00180 } 00181 00182 HPoint const operator /(float const rhs) const 00183 { 00184 return HPoint(x/rhs, y/rhs, z/rhs); 00185 } 00186 00187 HPoint const & operator += (HPoint const & rhs) 00188 { 00189 x += rhs.x; 00190 y += rhs.y; 00191 z += rhs.z; 00192 return *this; 00193 } 00194 00195 HPoint const & operator -= (HPoint const & rhs) 00196 { 00197 x -= rhs.x; 00198 y -= rhs.y; 00199 z -= rhs.z; 00200 return *this; 00201 } 00202 00203 HPoint const & operator *= (float const rhs) 00204 { 00205 x *= rhs; 00206 y *= rhs; 00207 z *= rhs; 00208 return *this; 00209 } 00210 00211 HPoint const & operator /= (float const rhs) 00212 { 00213 x /= rhs; 00214 y /= rhs; 00215 z /= rhs; 00216 return *this; 00217 } 00218 00219 bool operator ==(HPoint const & rhs) const 00220 { 00221 return Equal(&rhs); 00222 } 00223 00224 bool operator !=(HPoint const & rhs) const 00225 { 00226 return !Equal(&rhs); 00227 } 00228 00229 00231 #define HPOINT_EPSILON (1e-5f) //!< HPOINT_EPSILON 00232 00233 00235 bool Equal(HPoint const *p, float epsi = HPOINT_EPSILON) const { 00236 return (x - p->x < epsi) && (x - p->x > -epsi) 00237 && (y - p->y < epsi) && (y - p->y > -epsi) 00238 && (z - p->z < epsi) && (z - p->z > -epsi); 00239 }; 00240 00242 bool Equal(HPoint const &p, float epsi = HPOINT_EPSILON) const { 00243 return Equal(&p, epsi); 00244 }; 00245 }; 00246 00253 class MVO_API HPointKey : public HPoint 00254 { 00255 public: 00257 HPointKey() : HPoint(0, 0, 0) {}; 00258 00260 HPointKey(float X, float Y, float Z=0.0f) : HPoint(X, Y, Z) {}; 00261 00263 HPointKey(HPoint const * p) : HPoint(p->x, p->y, p->z) {}; 00264 00266 HPointKey(HPoint const & p) : HPoint(p.x, p.y, p.z) {}; 00267 00268 /* Define comparison operators so points can be used as keys in container classes. */ 00269 bool operator < (HPointKey const & rhs) const 00270 { 00271 if(x < rhs.x) 00272 return true; 00273 else if(x == rhs.x){ 00274 if(y < rhs.y) 00275 return true; 00276 else if(y == rhs.y){ 00277 if(z < rhs.z) 00278 return true; 00279 } 00280 } 00281 return false; 00282 } 00283 00284 bool operator > (HPointKey const & rhs) const 00285 { 00286 return !(*this < rhs); 00287 } 00288 00289 bool operator <= (HPointKey const & rhs) const 00290 { 00291 if( (*this) < rhs ){ 00292 return true; 00293 } 00294 else if( (*this) == rhs ){ 00295 return true; 00296 } 00297 return false; 00298 } 00299 00300 bool operator >= (HPointKey const & rhs) const 00301 { 00302 if( (*this) > rhs ){ 00303 return true; 00304 } 00305 else if( (*this) == rhs ){ 00306 return true; 00307 } 00308 return false; 00309 } 00310 }; 00311 00312 00315 class MVO_API HIntRectangle 00316 { 00317 public: 00318 int left; 00319 int right; 00320 int bottom; 00321 int top; 00322 }; 00323 00324 00326 00331 typedef class HPoint HVector; 00332 00333 00335 00338 class MVO_API HPlane 00339 { 00340 private: 00341 float m_a; 00342 float m_b; 00343 float m_c; 00344 float m_d; 00345 00346 public: 00347 HPlane(float const A = 0, float const B = 1, float const C = 0, float const D = 0) : 00348 m_a(A), m_b(B), m_c(C), m_d(D){ 00349 }; 00350 00351 HPlane(HVector const & normal, float const D) : 00352 m_a(normal.x), m_b(normal.y), m_c(normal.z), m_d(D){ 00353 }; 00354 00355 HPlane(HPlane const & p) : 00356 m_a(p.a()), m_b(p.b()), m_c(p.c()), m_d(p.d()){ 00357 }; 00358 00360 inline void Set(float A, float B, float C, float D) { a(A); b(B); c(C); d(D); } 00361 00365 inline double ClassifyPoint(HPoint const & p) const { return a() * p.x + b() * p.y + c() * p.z + d(); }; 00366 00370 inline void CalculateNormal(HPoint &normal) const 00371 { 00372 normal.Set(a(), b(), c()); 00373 HC_Compute_Normalized_Vector(&normal, &normal); 00374 }; 00375 00377 bool Equal(HPlane const *p, float epsi1 = HPOINT_EPSILON, float epsi2 = HPOINT_EPSILON) const { 00378 return (m_a - p->m_a < epsi1) && (m_a - p->m_a > -epsi1) 00379 && (m_b - p->m_b < epsi1) && (m_b - p->m_b > -epsi1) 00380 && (m_c - p->m_c < epsi1) && (m_c - p->m_c > -epsi1) 00381 && (m_d - p->m_d < epsi2) && (m_d - p->m_d > -epsi2); 00382 }; 00383 00384 00385 inline float a() const {return m_a;}; 00386 inline float b() const {return m_b;}; 00387 inline float c() const {return m_c;}; 00388 inline float d() const {return m_d;}; 00389 00390 inline void a(float A) {m_a = A;}; 00391 inline void b(float B) {m_b = B;}; 00392 inline void c(float C) {m_c = C;}; 00393 inline void d(float D) {m_d = D;}; 00394 }; 00395 00397 00400 class MVO_API HPlaneKey : public HPlane 00401 { 00402 public: 00403 HPlaneKey(float const A = 0, float const B = 1, float const C = 0, float const D = 0) : 00404 HPlane(A, B, C, D) { 00405 }; 00406 00407 HPlaneKey(HVector const & normal, float const D) : HPlane(normal, D) { 00408 }; 00409 00410 HPlaneKey(HPlane const & p) : HPlane(p) { 00411 }; 00412 00413 bool operator < (HPlane const & rhs) const { 00414 HVector n; 00415 00416 CalculateNormal(n); 00417 HPlane p1(n, d()); 00418 00419 rhs.CalculateNormal(n); 00420 HPlane p2(n, rhs.d()); 00421 00422 if(p1.a() < p2.a()) 00423 return true; 00424 else if(p1.a() == p2.a()){ 00425 if(p1.b() < p2.b()) 00426 return true; 00427 else if(p1.b() == p2.b()){ 00428 if(p1.c() < p2.c()) 00429 return true; 00430 else if(p1.c() == p2.c()){ 00431 if(p1.d() < p2.d()) 00432 return true; 00433 } 00434 } 00435 } 00436 return false; 00437 }; 00438 00439 bool operator == (HPlane const & rhs) const { 00440 HVector n; 00441 00442 CalculateNormal(n); 00443 HPlane p1(n, d()); 00444 00445 rhs.CalculateNormal(n); 00446 HPlane p2(n, rhs.d()); 00447 00448 if( p1.a() == p2.a() && 00449 p1.b() == p2.b() && 00450 p1.c() == p2.c() && 00451 p1.d() == p2.d()) 00452 return true; 00453 00454 return false; 00455 }; 00456 00457 bool operator >= (HPlane const & rhs) const { 00458 return !(*this < rhs); 00459 }; 00460 00461 bool operator > (HPlane const & rhs) const { 00462 return !(*this < rhs) && !(*this == rhs); 00463 }; 00464 00465 bool operator <= (HPlane const & rhs) const { 00466 return *this < rhs || *this == rhs; 00467 }; 00468 00469 bool operator != (HPlane const & rhs) const { 00470 return !(*this == rhs); 00471 }; 00472 }; 00473 00474 00476 class MVO_API HPixelRGB 00477 { 00478 private: 00479 unsigned char m_r; 00480 unsigned char m_g; 00481 unsigned char m_b; 00482 00483 public: 00484 HPixelRGB(unsigned char R = 0,unsigned char G = 0, unsigned char B = 0) : m_r(R), m_g(G), m_b(B) { 00485 }; 00486 00487 HPixelRGB(HPixelRGB const & p) : m_r(p.r()), m_g(p.g()), m_b(p.b()) { 00488 }; 00489 00490 inline unsigned char r() const {return m_r;}; 00491 inline unsigned char g() const {return m_g;}; 00492 inline unsigned char b() const {return m_b;}; 00493 00494 inline void r(unsigned char const R) {m_r = R;}; 00495 inline void g(unsigned char const G) {m_g = G;}; 00496 inline void b(unsigned char const B) {m_b = B;}; 00497 00499 inline void Set(unsigned char R, unsigned char G, unsigned char B){ 00500 r(R); 00501 g(G); 00502 b(B); 00503 }; 00504 00506 inline void Setf(float R, float G, float B){ 00507 r((unsigned char)(R*255.99f)); 00508 g((unsigned char)(G*255.99f)); 00509 b((unsigned char)(B*255.99f)); 00510 }; 00511 }; 00512 00514 class MVO_API HPixelRGBA : public HPixelRGB 00515 { 00516 private: 00517 unsigned char m_a; 00518 00519 public: 00520 HPixelRGBA( 00521 unsigned char const R = 0, 00522 unsigned char const G = 0, 00523 unsigned char const B = 0, 00524 unsigned char const A = 0) 00525 :HPixelRGB(R, G, B), m_a(A){ 00526 }; 00527 00528 HPixelRGBA(HPixelRGBA const & p):HPixelRGB(p.r(), p.g(), p.b()),m_a(p.a()){ 00529 }; 00531 inline void Set(unsigned char R, unsigned char G, unsigned char B, unsigned char A=0){ 00532 HPixelRGB::Set(R, G, B); 00533 a(A); 00534 }; 00535 00537 inline void Setf(float R, float G, float B, float A=0.0f){ 00538 HPixelRGB::Setf(R, G, B); 00539 a((unsigned char)(A*255.99f)); 00540 }; 00541 00542 inline unsigned char a() const {return m_a;}; 00543 inline void a(unsigned char const A) {m_a = A;}; 00544 }; 00545 00552 enum HSelectionHighlightMode { 00553 HighlightDefault, 00554 HighlightQuickmoves, 00555 InverseTransparency, 00556 ColoredInverseTransparency 00557 }; 00566 enum HRegionEdgeHighlightMode 00567 { 00568 NoEdges = 0, 00569 AllEdges, 00570 PerimeterEdges 00571 }; 00572 00573 enum HRegionFaceHighlightMode 00574 { 00575 FacesUnmodified = 0, 00576 FacesForcedOn, 00577 FacesForcedOff 00578 }; 00582 enum HRefSelType 00583 { 00584 RefSelSpriting, 00585 RefSelDefault, 00586 RefSelOff 00587 }; 00588 00589 00590 00591 #ifdef H_PACK_8 00592 #pragma pack(pop) 00593 #endif 00594 00595 #endif 00596 00597 00598 00599 00600 00601 00602