Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HGlobals.h
Go to the documentation of this file.
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: f695bc0b2e4e32d2d1fec34de917c49a8a673c14 $
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 (bool)(
00237             (x - p->x < epsi) && (x - p->x > -epsi) &&
00238             (y - p->y < epsi) && (y - p->y > -epsi) &&
00239             (z - p->z < epsi) && (z - p->z > -epsi));
00240     };
00241 
00243     bool Equal(HPoint const &p, float epsi = HPOINT_EPSILON) const { 
00244         return Equal(&p, epsi);
00245     };
00246 };
00247  
00254 class MVO_API HPointKey : public HPoint
00255 {
00256 public:
00258     HPointKey() : HPoint(0, 0, 0) {};
00259 
00261     HPointKey(float X, float Y, float Z=0.0f) : HPoint(X, Y, Z) {};
00262     
00264     HPointKey(HPoint const * p) : HPoint(p->x, p->y, p->z) {};
00265     
00267     HPointKey(HPoint const & p) : HPoint(p.x, p.y, p.z) {};
00268 
00269     /* Define comparison operators so points can be used as keys in container classes. */
00270     bool const operator < (HPointKey const & rhs) const
00271     {
00272         if(x < rhs.x)
00273             return true;
00274         else if(x == rhs.x){
00275             if(y < rhs.y)
00276                 return true;
00277             else if(y == rhs.y){
00278                 if(z < rhs.z)
00279                     return true;
00280             }
00281         }
00282         return false;
00283     }
00284 
00285     bool const operator > (HPointKey const & rhs) const
00286     {
00287         return !(*this < rhs);
00288     }
00289 
00290     bool const operator <= (HPointKey const & rhs) const
00291     {
00292         if( (*this) < rhs ){
00293             return true;
00294         }
00295         else if( (*this) == rhs ){
00296             return true;
00297         }
00298         return false;
00299     }
00300 
00301     bool const operator >= (HPointKey const & rhs) const
00302     {
00303         if( (*this) > rhs ){
00304             return true;
00305         }
00306         else if( (*this) == rhs ){
00307             return true;
00308         }
00309         return false;
00310     }
00311 };
00312 
00313 
00316 class MVO_API HIntRectangle
00317 { 
00318 public:
00319     int left;   
00320     int right;  
00321     int bottom; 
00322     int top;    
00323 };
00324 
00325 
00327 
00332 typedef class HPoint HVector;
00333 
00334 
00336 
00339 class MVO_API HPlane
00340 {
00341 private:
00342     float       m_a;    
00343     float       m_b;    
00344     float       m_c;    
00345     float       m_d;    
00346 
00347 public:
00348     HPlane(float const A = 0, float const B = 1, float const C = 0, float const D = 0) : 
00349     m_a(A), m_b(B), m_c(C), m_d(D){
00350     };
00351     
00352     HPlane(HVector const & normal, float const D) : 
00353     m_a(normal.x), m_b(normal.y), m_c(normal.z), m_d(D){
00354     };
00355 
00356     HPlane(HPlane const & p) : 
00357     m_a(p.a()), m_b(p.b()), m_c(p.c()), m_d(p.d()){
00358     };
00359 
00361     inline void Set(float A, float B, float C, float D) { a(A); b(B); c(C); d(D); }
00362 
00366     inline double ClassifyPoint(HPoint const & p) const { return (a() * p.x + b() * p.y + c() * p.z + d()); };
00367 
00371     inline void CalculateNormal(HPoint &normal) const
00372     {
00373         normal.Set(a(), b(), c());
00374         HC_Compute_Normalized_Vector(&normal, &normal);
00375     };
00376 
00378     bool Equal(HPlane const *p, float epsi1 = HPOINT_EPSILON, float epsi2 = HPOINT_EPSILON) const { 
00379         return (bool)(
00380             (m_a - p->m_a < epsi1) && (m_a - p->m_a > -epsi1) &&
00381             (m_b - p->m_b < epsi1) && (m_b - p->m_b > -epsi1) &&
00382             (m_c - p->m_c < epsi1) && (m_c - p->m_c > -epsi1) &&
00383             (m_d - p->m_d < epsi2) && (m_d - p->m_d > -epsi2));
00384     };
00385 
00386 
00387     inline float a() const {return m_a;};
00388     inline float b() const {return m_b;};
00389     inline float c() const {return m_c;};
00390     inline float d() const {return m_d;};
00391 
00392     inline void a(float A) {m_a = A;};
00393     inline void b(float B) {m_b = B;};
00394     inline void c(float C) {m_c = C;};
00395     inline void d(float D) {m_d = D;};
00396 }; 
00397 
00399 
00402 class MVO_API HPlaneKey : public HPlane
00403 {
00404 public:
00405     HPlaneKey(float const A = 0, float const B = 1, float const C = 0, float const D = 0) : 
00406     HPlane(A, B, C, D) {
00407     };
00408     
00409     HPlaneKey(HVector const & normal, float const D) : HPlane(normal, D) {
00410     };
00411 
00412     HPlaneKey(HPlane const & p) : HPlane(p) {
00413     };
00414 
00415     bool operator < (HPlane const & rhs) const {
00416         HVector n;
00417 
00418         CalculateNormal(n);
00419         HPlane p1(n, d());
00420 
00421         rhs.CalculateNormal(n);
00422         HPlane p2(n, rhs.d());
00423 
00424         if(p1.a() < p2.a())
00425             return true;
00426         else if(p1.a() == p2.a()){
00427             if(p1.b() < p2.b())
00428                 return true;
00429             else if(p1.b() == p2.b()){
00430                 if(p1.c() < p2.c())
00431                     return true;
00432                 else if(p1.c() == p2.c()){
00433                     if(p1.d() < p2.d())
00434                         return true;
00435                 }
00436             }
00437         }
00438         return false;   
00439     };
00440 
00441     bool operator == (HPlane const & rhs) const {
00442         HVector n;
00443 
00444         CalculateNormal(n);
00445         HPlane p1(n, d());
00446 
00447         rhs.CalculateNormal(n);
00448         HPlane p2(n, rhs.d());
00449 
00450         if( p1.a() == p2.a() &&
00451             p1.b() == p2.b() &&
00452             p1.c() == p2.c() &&
00453             p1.d() == p2.d())
00454             return true;
00455 
00456         return false;
00457     };
00458 
00459     bool operator >= (HPlane const & rhs) const {
00460         return !(*this < rhs);
00461     };
00462 
00463     bool operator > (HPlane const & rhs) const {
00464         return !(*this < rhs) && !(*this == rhs);
00465     };
00466 
00467     bool operator <= (HPlane const & rhs) const {
00468         return (*this < rhs) || (*this == rhs);
00469     };
00470 
00471     bool operator != (HPlane const & rhs) const {
00472         return !(*this == rhs);
00473     };
00474 }; 
00475 
00476 
00478 class MVO_API HPixelRGB
00479 {
00480 private:
00481     unsigned char m_r; 
00482     unsigned char m_g; 
00483     unsigned char m_b; 
00484 
00485 public:
00486     HPixelRGB(unsigned char R = 0,unsigned char G = 0, unsigned char B = 0) : m_r(R), m_g(G), m_b(B) {
00487     };
00488 
00489     HPixelRGB(HPixelRGB const & p) : m_r(p.r()), m_g(p.g()), m_b(p.b()) {
00490     };
00491 
00492     inline unsigned char r() const {return m_r;};
00493     inline unsigned char g() const {return m_g;};
00494     inline unsigned char b() const {return m_b;};
00495 
00496     inline void r(unsigned char const R) {m_r = R;};
00497     inline void g(unsigned char const G) {m_g = G;};
00498     inline void b(unsigned char const B) {m_b = B;};
00499 
00501     inline void Set(unsigned char R, unsigned char G, unsigned char B){
00502         r(R);
00503         g(G);
00504         b(B);
00505     };
00506 
00508     inline void Setf(float R, float G, float B){
00509         r((unsigned char)(R*255.99f));
00510         g((unsigned char)(G*255.99f));
00511         b((unsigned char)(B*255.99f));
00512     };
00513 };
00514 
00516 class MVO_API HPixelRGBA : public HPixelRGB
00517 {
00518 private:
00519     unsigned char m_a; 
00520 
00521 public:
00522     HPixelRGBA(
00523         unsigned char const R = 0,
00524         unsigned char const G = 0,
00525         unsigned char const B = 0,
00526         unsigned char const A = 0) 
00527         :HPixelRGB(R, G, B), m_a(A){
00528     };
00529 
00530     HPixelRGBA(HPixelRGBA const & p):HPixelRGB(p.r(), p.g(), p.b()),m_a(p.a()){
00531     };
00533     inline void Set(unsigned char R, unsigned char G, unsigned char B, unsigned char A=0){
00534         HPixelRGB::Set(R, G, B);
00535         a(A);
00536     };
00537 
00539     inline void Setf(float R, float G, float B, float A=0.0f){
00540         HPixelRGB::Setf(R, G, B);
00541         a((unsigned char)(A*255.99f));
00542     };
00543 
00544     inline unsigned char a() const {return m_a;};
00545     inline void a(unsigned char const A) {m_a = A;};
00546 };
00547 
00554 enum HSelectionHighlightMode {
00555     HighlightDefault,   
00556     HighlightQuickmoves, 
00557     InverseTransparency,  
00558     ColoredInverseTransparency  
00559 };
00568 enum HRegionEdgeHighlightMode
00569 {
00570     NoEdges = 0,
00571     AllEdges,
00572     PerimeterEdges
00573 };
00574 
00575 enum HRegionFaceHighlightMode
00576 {
00577     FacesUnmodified = 0,
00578     FacesForcedOn,
00579     FacesForcedOff
00580 };
00584 enum HRefSelType
00585 {
00586     RefSelSpriting, 
00587     RefSelDefault   
00588 };
00589 
00590 
00591 
00592 #ifdef H_PACK_8
00593 #pragma pack(pop)
00594 #endif
00595 
00596 #endif
00597 
00598 
00599 
00600 
00601 
00602 
00603