00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc. 00002 // 00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., 00004 // and considered a trade secret as defined under civil and criminal statutes. 00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of 00006 // unauthorized use or misappropriation of its trade secrets. Use of this information 00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under 00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use. 00009 00013 #ifndef _H_GLOBALS_H 00014 #define _H_GLOBALS_H 00015 00016 #ifdef H_PACK_8 00017 #pragma pack(push) 00018 #pragma pack(8) 00019 #endif 00020 00024 enum HFileIOResult 00025 { 00026 HIO_OK = 1, 00027 HIO_VersionMismatch = 2, 00028 HIO_Fail = 3, 00029 HIO_NotHandled = 4, 00030 HIO_BadFileName = 5, 00031 HIO_BadOptions = 6, 00032 HIO_BadLicense = 7, 00033 HIO_LibraryNotFound = 8 00034 }; 00035 00036 #define HFileInputResult HFileIOResult 00037 #define InputOK HIO_OK 00038 #define InputVersionMismatch HIO_VersionMismatch 00039 #define InputFail HIO_Fail 00040 #define InputNotHandled HIO_NotHandled 00041 #define InputBadFileName HIO_BadFileName 00042 #define InputBadOptions HIO_BadOptions 00043 #define InputBadLicense HIO_BadLicense 00044 #define InputLibraryNotFound HIO_LibraryNotFound 00045 00046 00047 #define HFileOutputResult HFileIOResult 00048 #define OutputOK HIO_OK 00049 #define OutputVersionMismatch HIO_VersionMismatch 00050 #define OutputFail HIO_Fail 00051 #define OutputNotHandled HIO_NotHandled 00052 #define OutputBadFileName HIO_BadFileName 00053 #define OutputBadOptions HIO_BadOptions 00054 #define OutputBadLicense HIO_BadLicense 00055 #define OutputLibraryNotFound HIO_LibraryNotFound 00056 00060 #define LAST_HFileInputResult InputBadOptions 00061 00064 #define LAST_HFileOutputResult OutputBadOptions 00065 00070 enum HSignal 00071 { 00072 HSignalDelete = 1, 00073 HSignalCameraPositionChanged = 2, 00074 HSignalSelected = 3, 00075 HSignalDeSelectedOne = 4, 00076 HSignalDeSelectedAll = 5, 00077 HSignalPaint = 6, 00078 HSignalClash = 7, 00079 HSignalRenderModeChanged = 8, 00080 HSignalResize = 9 00081 }; 00082 00086 #define LAST_HSignal HSignalClash 00087 00088 00092 enum HShadowMode 00093 { 00094 HShadowNone = 1, 00095 HShadowSoft = 2, 00096 HShadowHard = 3 00097 }; 00098 00102 enum HCutGeometryVisibility 00103 { 00104 HCutGeometryVisibilityNone = 0x0, 00105 HCutGeometryVisibilityFaces = 0x1, 00106 HCutGeometryVisibilityEdges = 0x2, 00107 HCutGeometryVisibilityAll = HCutGeometryVisibilityFaces | HCutGeometryVisibilityEdges 00108 }; 00109 00113 #define LAST_HShadowMode HShadowHard 00114 00116 00121 class MVO_API HPoint 00122 { 00123 public: 00124 float x; 00125 float y; 00126 float z; 00127 00129 HPoint() : x(0), y(0), z(0) {}; 00130 00132 HPoint(float X, float Y, float Z=0.0f) : x(X), y(Y), z(Z) {}; 00133 00135 HPoint(HPoint const * p) : x(p->x), y(p->y), z(p->z) {}; 00136 00138 HPoint(HPoint const & p) : x(p.x), y(p.y), z(p.z) {}; 00139 00141 void Set(float X, float Y, float Z=0.0f) { x=X; y=Y; z=Z; }; 00142 00144 void Set(HPoint *p) { x=p->x; y=p->y; z=p->z; }; 00145 00147 void Set(HPoint const *p) { x=p->x; y=p->y; z=p->z; }; 00148 00150 void Set(HPoint &p) { x=p.x; y=p.y; z=p.z; }; 00151 00153 void Set(const HPoint &p) { x=p.x; y=p.y; z=p.z; }; 00154 00160 void Add(float X, float Y, float Z=0.0){ x+=X; y+=Y; z+=Z; }; 00161 00162 HPoint const operator -(const HPoint &p2) const 00163 { 00164 return HPoint(x-p2.x, y-p2.y, z-p2.z); 00165 } 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 *(float const rhs) const 00173 { 00174 return HPoint(x*rhs, y*rhs, z*rhs); 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 += (HPoint const & rhs) 00183 { 00184 x += rhs.x; 00185 y += rhs.y; 00186 z += rhs.z; 00187 return *this; 00188 } 00189 00190 HPoint const & operator -= (HPoint const & rhs) 00191 { 00192 x -= rhs.x; 00193 y -= rhs.y; 00194 z -= rhs.z; 00195 return *this; 00196 } 00197 00198 HPoint const & operator *= (float const rhs) 00199 { 00200 x *= rhs; 00201 y *= rhs; 00202 z *= rhs; 00203 return *this; 00204 } 00205 00206 HPoint const & operator /= (float const rhs) 00207 { 00208 x /= rhs; 00209 y /= rhs; 00210 z /= rhs; 00211 return *this; 00212 } 00213 00214 bool operator ==(HPoint const & rhs) const 00215 { 00216 return Equal(&rhs); 00217 } 00218 00219 bool operator !=(HPoint const & rhs) const 00220 { 00221 return !Equal(&rhs); 00222 } 00223 00224 00226 #define HPOINT_EPSILON (1e-5f) //!< HPOINT_EPSILON 00227 00228 00230 bool Equal(HPoint const *p, float epsi = HPOINT_EPSILON) const { 00231 return (x - p->x < epsi) && (x - p->x > -epsi) 00232 && (y - p->y < epsi) && (y - p->y > -epsi) 00233 && (z - p->z < epsi) && (z - p->z > -epsi); 00234 }; 00235 00237 bool Equal(HPoint const &p, float epsi = HPOINT_EPSILON) const { 00238 return Equal(&p, epsi); 00239 }; 00240 }; 00241 00248 class MVO_API HPointKey : public HPoint 00249 { 00250 public: 00252 HPointKey() : HPoint(0, 0, 0) {}; 00253 00255 HPointKey(float X, float Y, float Z=0.0f) : HPoint(X, Y, Z) {}; 00256 00258 HPointKey(HPoint const * p) : HPoint(p->x, p->y, p->z) {}; 00259 00261 HPointKey(HPoint const & p) : HPoint(p.x, p.y, p.z) {}; 00262 00263 /* Define comparison operators so points can be used as keys in container classes. */ 00264 bool operator < (HPointKey const & rhs) const 00265 { 00266 if(x < rhs.x) 00267 return true; 00268 else if(x == rhs.x){ 00269 if(y < rhs.y) 00270 return true; 00271 else if(y == rhs.y){ 00272 if(z < rhs.z) 00273 return true; 00274 } 00275 } 00276 return false; 00277 } 00278 00279 bool operator > (HPointKey const & rhs) const 00280 { 00281 return !(*this < rhs); 00282 } 00283 00284 bool operator <= (HPointKey const & rhs) const 00285 { 00286 if( (*this) < rhs ){ 00287 return true; 00288 } 00289 else if( (*this) == rhs ){ 00290 return true; 00291 } 00292 return false; 00293 } 00294 00295 bool operator >= (HPointKey const & rhs) const 00296 { 00297 if( (*this) > rhs ){ 00298 return true; 00299 } 00300 else if( (*this) == rhs ){ 00301 return true; 00302 } 00303 return false; 00304 } 00305 }; 00306 00307 00310 class MVO_API HIntRectangle 00311 { 00312 public: 00313 int left; 00314 int right; 00315 int bottom; 00316 int top; 00317 }; 00318 00319 00321 00326 typedef class HPoint HVector; 00327 00328 00330 00333 class MVO_API HPlane 00334 { 00335 private: 00336 float m_a; 00337 float m_b; 00338 float m_c; 00339 float m_d; 00340 00341 public: 00342 HPlane(float const A = 0, float const B = 1, float const C = 0, float const D = 0) : 00343 m_a(A), m_b(B), m_c(C), m_d(D){ 00344 }; 00345 00346 HPlane(HVector const & normal, float const D) : 00347 m_a(normal.x), m_b(normal.y), m_c(normal.z), m_d(D){ 00348 }; 00349 00350 HPlane(HPlane const & p) : 00351 m_a(p.a()), m_b(p.b()), m_c(p.c()), m_d(p.d()){ 00352 }; 00353 00355 inline void Set(float A, float B, float C, float D) { a(A); b(B); c(C); d(D); } 00356 00360 inline double ClassifyPoint(HPoint const & p) const { return a() * p.x + b() * p.y + c() * p.z + d(); }; 00361 00365 inline void CalculateNormal(HPoint &normal) const 00366 { 00367 normal.Set(a(), b(), c()); 00368 HC_Compute_Normalized_Vector(&normal, &normal); 00369 }; 00370 00372 bool Equal(HPlane const *p, float epsi1 = HPOINT_EPSILON, float epsi2 = HPOINT_EPSILON) const { 00373 return (m_a - p->m_a < epsi1) && (m_a - p->m_a > -epsi1) 00374 && (m_b - p->m_b < epsi1) && (m_b - p->m_b > -epsi1) 00375 && (m_c - p->m_c < epsi1) && (m_c - p->m_c > -epsi1) 00376 && (m_d - p->m_d < epsi2) && (m_d - p->m_d > -epsi2); 00377 }; 00378 00379 00380 inline float a() const {return m_a;}; 00381 inline float b() const {return m_b;}; 00382 inline float c() const {return m_c;}; 00383 inline float d() const {return m_d;}; 00384 00385 inline void a(float A) {m_a = A;}; 00386 inline void b(float B) {m_b = B;}; 00387 inline void c(float C) {m_c = C;}; 00388 inline void d(float D) {m_d = D;}; 00389 }; 00390 00392 00395 class MVO_API HPlaneKey : public HPlane 00396 { 00397 public: 00398 HPlaneKey(float const A = 0, float const B = 1, float const C = 0, float const D = 0) : 00399 HPlane(A, B, C, D) { 00400 }; 00401 00402 HPlaneKey(HVector const & normal, float const D) : HPlane(normal, D) { 00403 }; 00404 00405 HPlaneKey(HPlane const & p) : HPlane(p) { 00406 }; 00407 00408 bool operator < (HPlane const & rhs) const { 00409 HVector n; 00410 00411 CalculateNormal(n); 00412 HPlane p1(n, d()); 00413 00414 rhs.CalculateNormal(n); 00415 HPlane p2(n, rhs.d()); 00416 00417 if(p1.a() < p2.a()) 00418 return true; 00419 else if(p1.a() == p2.a()){ 00420 if(p1.b() < p2.b()) 00421 return true; 00422 else if(p1.b() == p2.b()){ 00423 if(p1.c() < p2.c()) 00424 return true; 00425 else if(p1.c() == p2.c()){ 00426 if(p1.d() < p2.d()) 00427 return true; 00428 } 00429 } 00430 } 00431 return false; 00432 }; 00433 00434 bool operator == (HPlane const & rhs) const { 00435 HVector n; 00436 00437 CalculateNormal(n); 00438 HPlane p1(n, d()); 00439 00440 rhs.CalculateNormal(n); 00441 HPlane p2(n, rhs.d()); 00442 00443 if( p1.a() == p2.a() && 00444 p1.b() == p2.b() && 00445 p1.c() == p2.c() && 00446 p1.d() == p2.d()) 00447 return true; 00448 00449 return false; 00450 }; 00451 00452 bool operator >= (HPlane const & rhs) const { 00453 return !(*this < rhs); 00454 }; 00455 00456 bool operator > (HPlane const & rhs) const { 00457 return !(*this < rhs) && !(*this == rhs); 00458 }; 00459 00460 bool operator <= (HPlane const & rhs) const { 00461 return *this < rhs || *this == rhs; 00462 }; 00463 00464 bool operator != (HPlane const & rhs) const { 00465 return !(*this == rhs); 00466 }; 00467 }; 00468 00469 00471 class MVO_API HPixelRGB 00472 { 00473 private: 00474 unsigned char m_r; 00475 unsigned char m_g; 00476 unsigned char m_b; 00477 00478 public: 00479 HPixelRGB(unsigned char R = 0,unsigned char G = 0, unsigned char B = 0) : m_r(R), m_g(G), m_b(B) { 00480 }; 00481 00482 HPixelRGB(HPixelRGB const & p) : m_r(p.r()), m_g(p.g()), m_b(p.b()) { 00483 }; 00484 00485 inline unsigned char r() const {return m_r;}; 00486 inline unsigned char g() const {return m_g;}; 00487 inline unsigned char b() const {return m_b;}; 00488 00489 inline void r(unsigned char const R) {m_r = R;}; 00490 inline void g(unsigned char const G) {m_g = G;}; 00491 inline void b(unsigned char const B) {m_b = B;}; 00492 00494 inline void Set(unsigned char R, unsigned char G, unsigned char B){ 00495 r(R); 00496 g(G); 00497 b(B); 00498 }; 00499 00501 inline void Setf(float R, float G, float B){ 00502 r((unsigned char)(R*255.99f)); 00503 g((unsigned char)(G*255.99f)); 00504 b((unsigned char)(B*255.99f)); 00505 }; 00506 }; 00507 00509 class MVO_API HPixelRGBA : public HPixelRGB 00510 { 00511 private: 00512 unsigned char m_a; 00513 00514 public: 00515 HPixelRGBA( 00516 unsigned char const R = 0, 00517 unsigned char const G = 0, 00518 unsigned char const B = 0, 00519 unsigned char const A = 0) 00520 :HPixelRGB(R, G, B), m_a(A){ 00521 }; 00522 00523 HPixelRGBA(HPixelRGBA const & p):HPixelRGB(p.r(), p.g(), p.b()),m_a(p.a()){ 00524 }; 00526 inline void Set(unsigned char R, unsigned char G, unsigned char B, unsigned char A=0){ 00527 HPixelRGB::Set(R, G, B); 00528 a(A); 00529 }; 00530 00532 inline void Setf(float R, float G, float B, float A=0.0f){ 00533 HPixelRGB::Setf(R, G, B); 00534 a((unsigned char)(A*255.99f)); 00535 }; 00536 00537 inline unsigned char a() const {return m_a;}; 00538 inline void a(unsigned char const A) {m_a = A;}; 00539 }; 00540 00547 enum HSelectionHighlightMode { 00548 HighlightDefault, 00549 HighlightQuickmoves, 00550 InverseTransparency, 00551 ColoredInverseTransparency 00552 }; 00561 enum HRegionEdgeHighlightMode 00562 { 00563 NoEdges = 0, 00564 AllEdges, 00565 PerimeterEdges 00566 }; 00567 00568 enum HRegionFaceHighlightMode 00569 { 00570 FacesUnmodified = 0, 00571 FacesForcedOn, 00572 FacesForcedOff 00573 }; 00577 enum HRefSelType 00578 { 00579 RefSelSpriting, 00580 RefSelDefault, 00581 RefSelOff 00582 }; 00583 00584 00585 00586 #ifdef H_PACK_8 00587 #pragma pack(pop) 00588 #endif 00589 00590 #endif 00591 00592 00593 00594 00595 00596 00597