HUtilityShadow.h
Go to the documentation of this file.
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 // HUtilityShadow.h : interface of the HUtilityShadow classes
11 // Set of utility methods for shadow creations
12 
17 #ifndef _HUTILITYSHADOW_H
18 #define _HUTILITYSHADOW_H
19 
20 #ifdef H_PACK_8
21 #pragma pack(push)
22 #pragma pack(8)
23 #endif
24 
25 #include "HTools.h"
26 
27 
28 class HBaseView;
29 class HPixelRGB;
30 class HPixelRGBA;
31 
32 
37 {
41 };
42 
43 
45 
93 class MVO_API HShadow
94 {
95 public:
96 
102  HShadow(HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey, float ObjectModellingMatrix[] = 0);
103 
107  void CalculateTotalModelExtents();
108 
110  void GetModelExtents(HPoint &ObjectBoundingMin, HPoint &ObjectBoundingMax)
111  {
112  ObjectBoundingMin = m_ObjectBoundingMin;
113  ObjectBoundingMax = m_ObjectBoundingMax;
114  }
115 
117  void GetShadowLightPos(HPoint &lightpos) { lightpos = m_ShadowLightPos; }
119  void GetShadowGroundPlane(HPlane &plane) { plane = m_ShadowGroundPlane; }
121  HC_KEY GetShadowKey() { return m_ShadowSegmentKey; }
122 
124  void SetShadowLightPos(HPoint lightpos) { m_ShadowLightPos = lightpos; }
126  void SetShadowGroundPlane(HPlane plane) { m_ShadowGroundPlane = plane; }
127 
129  void SetShadowBrightness(int ShadowBrightness) { m_ShadowBrightness = ShadowBrightness; }
131  int GetShadowBrightness() { return m_ShadowBrightness; }
132 
133 protected:
146  float m_ObjectModellingMatrix[16];
154  void ShowModellingMatrix(HC_KEY segkey, float oldmatrix[], float newmatrix[]);
155 
163  void ComputeObjectExtents(HPoint &min, HPoint &max, HPoint points[], int numpoints);
164 
170  void RotateToGroundPlane(HPlane plane, float matrix[]);
171 
178  void ShadowMatrix2(float matrix[], HPlane plane, HPoint d);
179 
183  HC_KEY IsolateShell();
184 
188  void RestoreShell();
189 
190 
195  bool HasShell(HC_KEY segKey);
196 
197 private:
198  void CalculateModelExtents(HC_KEY SegKey, float totalmatrix[]);
199  void SetIdentityMatrix(float matrix[]);
200  void ShadowMatrix(float mm[], HPlane plane, HPoint light);
201 
202 
203 };
204 
206 
209 class MVO_API HSmoothShadow : public HShadow
210 {
211 
212 public:
217  HSmoothShadow(HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey, bool UseOglShadow = false);
218  virtual ~HSmoothShadow();
222  void CleanUp();
223 
230  void Create(ShadowPlaneType ptype, int TextureSize = 0, int FilterSize = -1, int filter[] = 0);
231 
235  void Create();
236 
238  int GetFilterSize() { return m_FilterSize; }
239 
241  int GetTextureSize() { return m_TextureSize; }
242 
247  void SetTextureSize(int TextureSize) { m_TextureSize = TextureSize; }
248 
254  void SetFilter(int filter[], int FilterSize) { m_filter = filter; m_FilterSize = FilterSize; }
255 
258  void UnDefineShadowTexture();
261  static void UnDefineAllShadowTextures(HC_KEY modelsegmentkey);
262 
267  void SetAllowOpenglShadow(bool AllowOpenglShadow) { m_bAllowOpenglShadow = AllowOpenglShadow; }
268 protected:
271  int *m_filter;
272  HC_KEY m_ImageKey;
275  char m_texname[MVO_SMALL_BUFFER_SIZE];
277 
280  void CalculateTotalShadowExtents();
281 
287  void CalculateShadowExtents(HC_KEY segkey,float *totalmatrix);
288 
292  void CreateSoftShadow();
293 
297  void CreateShadowTexture();
298 
307  void SmoothImage(HPixelRGB *origImage, HPixelRGBA **smoothImage, int width, int height, int filterSize, int filter[]);
308 
309 private:
310  void CalculateOneShadowExtent(HC_KEY shellkey, float *modellingMatrix);
311 
312 };
313 
314 
316 class MVO_API HHardShadow : public HShadow
317 {
318 
319 public:
321  HHardShadow(HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey) : HShadow(ModelSegmentKey, ShadowBaseSegmentKey) {}
322 
323  virtual ~HHardShadow() {};
324 
325 
330  void Create(ShadowPlaneType ptype);
331 
335  virtual void Create();
336 
337 protected:
338 
342  void CreateHardShadow();
343 
344 };
345 
346 
347 
348 #ifdef H_PACK_8
349 #pragma pack(pop)
350 #endif
351 
352 #endif
353 
354 
355 
HPoint m_ShadowBoundingMax
max value of shadow bounding volume
Definition: HUtilityShadow.h:274
The HPixelRGB class is the data type of a rgb pixel.
Definition: HGlobals.h:473
int m_ShadowBrightness
Definition: HUtilityShadow.h:138
void GetShadowLightPos(HPoint &lightpos)
Definition: HUtilityShadow.h:117
int GetShadowBrightness()
Definition: HUtilityShadow.h:131
HPoint m_ObjectBoundingMin
Definition: HUtilityShadow.h:143
int GetTextureSize()
Definition: HUtilityShadow.h:241
This class has been deprecated.
Definition: HUtilityShadow.h:209
self-explanatory
Definition: HUtilityShadow.h:39
bool m_bFirstCoordinate
Definition: HUtilityShadow.h:134
HC_KEY m_ImageKey
key to shadow image
Definition: HUtilityShadow.h:272
void SetShadowBrightness(int ShadowBrightness)
Definition: HUtilityShadow.h:129
void GetShadowGroundPlane(HPlane &plane)
Definition: HUtilityShadow.h:119
int m_FilterSize
size of filter matrix
Definition: HUtilityShadow.h:270
bool m_bAllowOpenglShadow
use opengl offscreen buffer
Definition: HUtilityShadow.h:276
void SetShadowLightPos(HPoint lightpos)
Definition: HUtilityShadow.h:124
The HPixelRGBA class is the data type of a rgba pixel.
Definition: HGlobals.h:511
HHardShadow(HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey)
Definition: HUtilityShadow.h:321
int * m_filter
filter matrix
Definition: HUtilityShadow.h:271
int m_TextureSize
size of texture extents
Definition: HUtilityShadow.h:269
void GetModelExtents(HPoint &ObjectBoundingMin, HPoint &ObjectBoundingMax)
Definition: HUtilityShadow.h:110
HPoint m_ShadowBoundingMin
min value of shadow bounding volume
Definition: HUtilityShadow.h:273
HC_KEY m_ShadowSegmentKey
Definition: HUtilityShadow.h:137
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:121
This class has been deprecated.
Definition: HUtilityShadow.h:93
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:332
void SetShadowGroundPlane(HPlane plane)
Definition: HUtilityShadow.h:126
ShadowPlaneType
Definition: HUtilityShadow.h:36
void SetTextureSize(int TextureSize)
Definition: HUtilityShadow.h:247
HC_KEY m_ModelSegmentKey
Definition: HUtilityShadow.h:136
HPlane m_ShadowGroundPlane
Definition: HUtilityShadow.h:141
self-explanatory
Definition: HUtilityShadow.h:40
void SetAllowOpenglShadow(bool AllowOpenglShadow)
Definition: HUtilityShadow.h:267
HPoint m_ObjectBoundingMax
Definition: HUtilityShadow.h:144
HPoint m_ShadowLightPos
Definition: HUtilityShadow.h:140
self-explanatory
Definition: HUtilityShadow.h:38
int GetFilterSize()
Definition: HUtilityShadow.h:238
This class has been deprecated.
Definition: HUtilityShadow.h:316
HC_KEY GetShadowKey()
Definition: HUtilityShadow.h:121
The HPlane class is the data type of a plane.
Definition: HGlobals.h:335
void SetFilter(int filter[], int FilterSize)
Definition: HUtilityShadow.h:254