Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HUtilityShadow.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$
00013 //
00014 
00015 // HUtilityShadow.h : interface of the HUtilityShadow classes
00016 // Set of utility methods for shadow creations
00017  
00022 #ifndef _HUTILITYSHADOW_H
00023 #define _HUTILITYSHADOW_H
00024 
00025 #ifdef H_PACK_8
00026 #pragma pack(push)
00027 #pragma pack(8)
00028 #endif
00029 
00030 #include "HTools.h"
00031  
00032 
00033 class HBaseView;
00034 class HPixelRGB;
00035 class HPixelRGBA;
00036 
00037 
00041 enum ShadowPlaneType
00042 {
00043     XZ_PLANE,   
00044     XY_PLANE,   
00045     YZ_PLANE    
00046 };
00047  
00048  
00050 
00098 class MVO_API HShadow
00099 {
00100 public:
00101 
00107     HShadow(HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey, float *ObjectModellingMatrix = 0);
00108 
00112     void CalculateTotalModelExtents();
00113 
00115     void GetModelExtents(HPoint &ObjectBoundingMin, HPoint &ObjectBoundingMax)
00116     {
00117         ObjectBoundingMin = m_ObjectBoundingMin;
00118         ObjectBoundingMax = m_ObjectBoundingMax;
00119     }
00120 
00122     void GetShadowLightPos(HPoint &lightpos) { lightpos = m_ShadowLightPos; }
00124     void GetShadowGroundPlane(HPlane &plane) { plane = m_ShadowGroundPlane; }
00126     HC_KEY GetShadowKey() { return m_ShadowSegmentKey; }
00127 
00129     void SetShadowLightPos(HPoint lightpos) { m_ShadowLightPos = lightpos; }
00131     void SetShadowGroundPlane(HPlane plane) { m_ShadowGroundPlane = plane; }
00132 
00134     void SetShadowBrightness(int ShadowBrightness) { m_ShadowBrightness = ShadowBrightness; }
00136     int GetShadowBrightness() { return m_ShadowBrightness; }
00137   
00138 protected:
00139     bool  m_bFirstCoordinate;               
00141     HC_KEY m_ModelSegmentKey;               
00142     HC_KEY m_ShadowSegmentKey;              
00143     int m_ShadowBrightness;                 
00145     HPoint m_ShadowLightPos;                
00146     HPlane m_ShadowGroundPlane;             
00148     HPoint m_ObjectBoundingMin;             
00149     HPoint m_ObjectBoundingMax;             
00151     float m_ObjectModellingMatrix[16];      
00159     void ShowModellingMatrix(HC_KEY segkey, float * oldmatrix, float * newmatrix);
00160 
00168     void ComputeObjectExtents(HPoint &min, HPoint &max, HPoint *points, int numpoints);
00169 
00175     void RotateToGroundPlane(HPlane plane, float *matrix);
00176 
00183     void ShadowMatrix2(float *matrix, HPlane plane, HPoint d);
00184 
00188     HC_KEY IsolateShell();
00189 
00193     void RestoreShell();
00194 
00195 
00200     bool HasShell(HC_KEY segKey);
00201 
00202 private:
00203     void CalculateModelExtents(HC_KEY SegKey, float *totalmatrix);
00204     void SetIdentityMatrix(float *matrix);
00205     void ShadowMatrix(float *mm, HPlane plane, HPoint light);
00206 
00207 
00208 };
00209 
00211 
00214 class  MVO_API HSmoothShadow : public HShadow
00215 {
00216 
00217 public:
00222     HSmoothShadow(HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey, bool UseOglShadow = false);
00223     virtual ~HSmoothShadow();
00227     void CleanUp();
00228   
00235     void Create(ShadowPlaneType ptype, int TextureSize = 0, int FilterSize = -1, int *filter = 0); 
00236 
00240     void Create();
00241 
00243     int GetFilterSize() { return m_FilterSize; }
00244 
00246     int GetTextureSize() { return m_TextureSize; }
00247 
00252     void SetTextureSize(int TextureSize) { m_TextureSize = TextureSize; }
00253 
00259     void SetFilter(int *filter, int FilterSize) { m_filter = filter; m_FilterSize = FilterSize; }
00260 
00263     void UnDefineShadowTexture();
00266     static void UnDefineAllShadowTextures(HC_KEY modelsegmentkey);
00267 
00272     void SetAllowOpenglShadow(bool AllowOpenglShadow) { m_bAllowOpenglShadow = AllowOpenglShadow; }
00273 protected:
00274     int m_TextureSize;                                      
00275     int m_FilterSize;                                       
00276     int *m_filter;                                          
00277     HC_KEY m_ImageKey;                                      
00278     HPoint m_ShadowBoundingMin;                             
00279     HPoint m_ShadowBoundingMax;                             
00280     char m_texname[MVO_SMALL_BUFFER_SIZE];                                  
00281     bool m_bAllowOpenglShadow;                              
00282 
00285     void CalculateTotalShadowExtents();
00286   
00292     void CalculateShadowExtents(HC_KEY segkey,float *totalmatrix);
00293 
00297     void CreateSoftShadow();
00298 
00302     void CreateShadowTexture();
00303 
00312     void SmoothImage(HPixelRGB *origImage, HPixelRGBA **smoothImage, int width, int height, int filterSize, int *filter);
00313 
00314 private:
00315     void CalculateOneShadowExtent(HC_KEY shellkey, float *modellingMatrix);
00316 
00317 };
00318 
00319 
00321 class  MVO_API HHardShadow : public HShadow
00322 {
00323 
00324 public:
00326     HHardShadow(HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey) : HShadow(ModelSegmentKey, ShadowBaseSegmentKey)  {}
00327 
00328     virtual ~HHardShadow() {};
00329 
00330     
00335     void Create(ShadowPlaneType ptype); 
00336 
00340     virtual void Create();
00341 
00342 protected:
00343 
00347     void CreateHardShadow();
00348   
00349 };
00350 
00351 
00352 
00353 #ifdef H_PACK_8
00354 #pragma pack(pop)
00355 #endif
00356 
00357 #endif
00358 
00359 
00360