This class has been deprecated. More...

#include <HUtilityShadow.h>

Public Member Functions

void CalculateTotalModelExtents ()
void GetModelExtents (HPoint &ObjectBoundingMin, HPoint &ObjectBoundingMax)
int GetShadowBrightness ()
void GetShadowGroundPlane (HPlane &plane)
HC_KEY GetShadowKey ()
void GetShadowLightPos (HPoint &lightpos)
 HShadow (HC_KEY ModelSegmentKey, HC_KEY ShadowBaseSegmentKey, float ObjectModellingMatrix[]=0)
void SetShadowBrightness (int ShadowBrightness)
void SetShadowGroundPlane (HPlane plane)
void SetShadowLightPos (HPoint lightpos)

Protected Member Functions

void ComputeObjectExtents (HPoint &min, HPoint &max, HPoint points[], int numpoints)
bool HasShell (HC_KEY segKey)
HC_KEY IsolateShell ()
void RestoreShell ()
void RotateToGroundPlane (HPlane plane, float matrix[])
void ShadowMatrix2 (float matrix[], HPlane plane, HPoint d)
void ShowModellingMatrix (HC_KEY segkey, float oldmatrix[], float newmatrix[])

Protected Attributes

bool m_bFirstCoordinate
HC_KEY m_ModelSegmentKey
HPoint m_ObjectBoundingMax
HPoint m_ObjectBoundingMin
float m_ObjectModellingMatrix [16]
int m_ShadowBrightness
HPlane m_ShadowGroundPlane
HPoint m_ShadowLightPos
HC_KEY m_ShadowSegmentKey

Detailed Description

This class has been deprecated.

This class has been deprecated. The HShadow class aids in creating soft and hard shadows of a given scene

Here is an example of how to use it:

HC_KEY shadowkey;
HC_Open_Segment_By_Key(m_pView->GetSceneKey()); //we first need to create a separate segment for the shadow geometry...
    shadowkey = HC_KCreate_Segment("shadows");
HSmoothShadow myShadow(m_pView->GetModel()->GetModelKey(), shadowkey);

Smooth shadows are created by projecting the geometry to the desired plane (from a given light direction) and converting the result to a texture map on which a softening filter is applied myshadow = new HSmoothShadow(m_pView->GetModel()->GetModelKey(), shadowkey);

Apart from the model key (geometry that should be shadowed) and the key for the shadow segment we can also specify the size of the texture map (can effectively only be set to 64, 128 or 256) to avoid distortion as well as a smoothing filter that is applied at each pixel of the shadow texture (see below for the default filter matrix) Those values can either be set in the Create call or the default parameters can be used with the only requirement being to identify a ground plane (Most HSF files have an XY ground plane) as follows:


This function also calculates the world space extents of the model to automatically find a suitable light/plane position. If you want to supply your own arbitrary light/plane position simply call the overloaded create function without any parameter and use SetShadowLightPos and SetShadowGroundPlane respectively. After this call has completed the shadow should be visible. If the scene changes a new call to Create() is required in the case of the smooth shadow to recreate the texture. To adjust the brightness of the shadow the function SetShadowBrightness() can be used (from 0 to 255).

Hard Shadows are creating with the same process (of course no texture/filter parameters). The difference is that no further calls to Create() are necessary unless a change of the light/plane position is desired.

Here are a few considerations when using that functionality: As soft shadows use a texture map of limited size the complexity/size of the scene can effect the quality/detail of the shadow. It might make sense to create a separate shadow for every object in the scene. However there is currently a blending problem when multiple shadows are overlapping. This should be fixed in the next release. The "smoothness" of the shadow is greatly affected by the size of the texturemap and the extends of the smoothness filter. On the other hand a larger texture/filter also increases the texture creation time. In the current implementation the shadow texture is scaled so that it goes a bit beyond the model extents. This might be not the perfect solution for certain models though...

Hard shadows are created by projecting the given scene with a "shadow matrix". This in effect doubles the complexity of the scene so it might make sense to use an LOD technique on the model. This could also be selectively applied on the shadows segment only (not tested yet).

Constructor & Destructor Documentation

◆ HShadow()

HShadow::HShadow ( HC_KEY  ModelSegmentKey,
HC_KEY  ShadowBaseSegmentKey,
float  ObjectModellingMatrix[] = 0 


ModelSegmentKeyKey of top-level segment that shadows should be applied to
ShadowBaseSegmentKeyKey of segment that contains the shadow geometry
ObjectModellingMatrixNetModellingMatrix of the shadow segment; zero by default

Member Function Documentation

◆ CalculateTotalModelExtents()

void HShadow::CalculateTotalModelExtents ( )

Calculates the total extents of the model in world space

◆ ComputeObjectExtents()

void HShadow::ComputeObjectExtents ( HPoint min,
HPoint max,
HPoint  points[],
int  numpoints 

Computes axis alligned bounding box of pointcloud

minminimum extents of bounding box
maxmaximum extents of bounding box
pointspoint cloud data

◆ GetModelExtents()

void HShadow::GetModelExtents ( HPoint ObjectBoundingMin,
HPoint ObjectBoundingMax 

Returns the extents of the model

◆ GetShadowBrightness()

int HShadow::GetShadowBrightness ( )

Returns the shadow brightness

◆ GetShadowGroundPlane()

void HShadow::GetShadowGroundPlane ( HPlane plane)

Returns the shadow ground plane

◆ GetShadowKey()

HC_KEY HShadow::GetShadowKey ( )

Returns the key of the shadow segment

◆ GetShadowLightPos()

void HShadow::GetShadowLightPos ( HPoint lightpos)

Returns the light position

◆ HasShell()

bool HShadow::HasShell ( HC_KEY  segKey)
segKeySegment key to look in.
Whether any shells exist in a specified segment.

◆ IsolateShell()

HC_KEY HShadow::IsolateShell ( )

Moves shell out of view for "fitworld" calculation

◆ RestoreShell()

void HShadow::RestoreShell ( )

Restores shadow shell position

◆ RotateToGroundPlane()

void HShadow::RotateToGroundPlane ( HPlane  plane,
float  matrix[] 

Rotates Plane to a given Vector

planeto rotate
matrixrotation matrix

◆ SetShadowBrightness()

void HShadow::SetShadowBrightness ( int  ShadowBrightness)

Set the shadow brightness

◆ SetShadowGroundPlane()

void HShadow::SetShadowGroundPlane ( HPlane  plane)

Set the shadow ground plane

◆ SetShadowLightPos()

void HShadow::SetShadowLightPos ( HPoint  lightpos)

Set the light position

◆ ShadowMatrix2()

void HShadow::ShadowMatrix2 ( float  matrix[],
HPlane  plane,
HPoint  d 

Computes shadow matrix based on shadow plane and light position

matrixModelling Matrix
planeshadow plane
dlight position

◆ ShowModellingMatrix()

void HShadow::ShowModellingMatrix ( HC_KEY  segkey,
float  oldmatrix[],
float  newmatrix[] 

Returns combined modelling matrix

segkeyKey of the segment for which the modelling matrix needs to be retrieved
oldmatrixbase matrix for multiplication. Passed by reference.
newmatrixcombined matrix. Passed by reference. Returned to user.

Member Data Documentation

◆ m_bFirstCoordinate

bool HShadow::m_bFirstCoordinate

Internal Use

◆ m_ModelSegmentKey

HC_KEY HShadow::m_ModelSegmentKey

Internal Use

◆ m_ObjectBoundingMax

HPoint HShadow::m_ObjectBoundingMax

Internal Use

◆ m_ObjectBoundingMin

HPoint HShadow::m_ObjectBoundingMin

Internal Use

◆ m_ObjectModellingMatrix

float HShadow::m_ObjectModellingMatrix[16]

Internal Use

◆ m_ShadowBrightness

int HShadow::m_ShadowBrightness

Internal Use

◆ m_ShadowGroundPlane

HPlane HShadow::m_ShadowGroundPlane

Internal Use

◆ m_ShadowLightPos

HPoint HShadow::m_ShadowLightPos

Internal Use

◆ m_ShadowSegmentKey

HC_KEY HShadow::m_ShadowSegmentKey

Internal Use

The documentation for this class was generated from the following file: