#include <shadbuf.h>
Class Description
- See also:
- Class ShadowGenerator, Class RendContext,
Class RenderGlobalContext, Class
ObjLightDesc, Class Matrix3.
- Description:
- This class is used to generate a Shadow Buffer which may be
used to determine if a point is in shadow or not. The 3ds Max
shadow maps use this object internally, for example.
There is a global function that creates one of these ShadBufRenderer
objects. With one of these developers can call its Render()
method to generate (render) a Shadow Buffer.
The rendered shadow buffer stores a Z distance at every point in
the buffer. This can then be used to determine if something is in
shadow. To check a certain point you simply see if the Z value is
behind the one in the buffer. That is, a shadow buffer tells one,
from the point of view of a light, how far it is to the first
object for each pixel in the buffer. If the Z point of the thing
being shadowed is farther than (behind) the corresponding Z value
in the buffer then the thing is in shadow. If it's closer than it
is not in shadow.
The main Render()
method is typically called from the Update() method of class
ShadowGenerator which is
called on every frame to create a new shadow buffer.
To use this class you basically do the following:
Allocate an array of floating point values, one float for each
point in the shadow buffer:
buffer = new float[shadsize*shadsize];
Then create a default Shadow Buffer Renderer
using the global function provided:
ShadBufRenderer *sbr = NewDefaultShadBufRenderer();
Then you setup all the parameters for the view, etc prior to
calling the Render()
method to render the buffer. (These parameters are passed in to the
ShadowGenerator::Update()
method).
int nRendered = sbr->Render(rc, RGC, buffer, parallel,
shadsize, param, aspect, clipDist, ltDesc, worldToLight);
You can check the return value to determine if any objects were
intersected by the shadow volume. If none were, the shadow buffer
can be freed.
if (nRendered==0)
{
delete [] buffer;
sbr->DeleteThis();
buffer = NULL;
return 1;
}
All methods of this class are implemented by the system.
Member Function Documentation
- Parameters:
- RendContext
&rc
The RendContext
which is used for the progress bar API.
RenderGlobalContext
*RGC
Points to the RenerGlobalContext which is used to retireve
information about the global rendering enviornment (to get an
instance list).
float *buf
This is the buffer to render to. This is a pre-allocated array of
floats (shadsize*shadsize).
BOOL parallel
The projection type. TRUE if parallel projection; FALSE if
perspective projection.
int shadsize
The size of the buffer (shadsize by shadsize pixels).
float param
The view parameter. For a perspective this is the:field-of-view (in
radians). For a parallel view this is the width in world
coordinates.
float aspect
This is the aspect ratio of the buffer projection.
float clipDist
The clipping distance. This tells the shadow buffer renderer to not
consider objects farther than this distance from light.
ObjLightDesc *ltDesc
This is the descriptor for light that was passed in to
CreateShadowGenerator().
Matrix3
worldToLight
The world to light transformation matrix for the light.
- Returns:
- Returns the number of objects that the shadow volume
intersected. If this value is 0, the shadow buffer can be freed to
save memory.
virtual float Furthest |
( |
|
) |
[pure virtual] |
virtual float Closest |
( |
|
) |
[pure virtual] |
virtual void DeleteThis |
( |
|
) |
[pure virtual] |