EnvironmentHandler
Environment handlers render the backdrop, the points at infinity that aren't covered by
anything in the scene. This is the natural place to draw the sky, the distant horizon, or
a procedural nebula in space.
Handler Activation Function
XCALL_( int ) MyEnvironment( long version, GlobalFunc *global,
LWEnvironmentHandler *local, void *serverData );
The local argument to an environment handler's activation function is an
LWEnvironmentHandler.
typedef struct st_LWEnvironmentHandler {
LWInstanceFuncs *inst;
LWItemFuncs *item;
LWRenderFuncs *rend;
LWError (*evaluate) (LWInstance, LWEnvironmentAccess *);
unsigned int (*flags) (LWInstance);
} LWEnvironmentHandler;
The first three members of this structure point to the standard handler functions. In addition to these, an environment handler
provides an evaluation function and a flags function.
- evaluate( instance, access )
- This is where the environment handler does its work. At each time step in the animation,
the evaluation function is called for each affected pixel in the image. The access
argument, described below, contains information about the environment to be colored.
flags( instance )
- Returns an int. The flags are
LWENF_TRANSPARENT
Interface Activation Function
XCALL_( int ) MyInterface( long version, GlobalFunc *global,
??? *???, void *serverData );
TBD
Environment Access
This is the structure passed to the handler's evaluation function.
typedef struct st_LWEnvironmentAccess {
LWEnvironmentMode mode;
double h[2], p[2];
LWDVector dir;
double colRect[4][3];
double color[3];
} LWEnvironmentAccess;
- mode
- The context of the evaluation. Currently this distinguishes between rendering (EHMODE_REAL)
and lower quality previewing (EHMODE_PREVIEW).
h, p
- The extents, in polar coordinates, of a rectangular area of the backdrop. Heading h
is the angle around the Y axis and pitch p is the angle around the X axis.
They're expressed in radians. In preview mode, the area will be relatively large, while in
real mode the area will generally be the size of a pixel.
colRect
- In preview mode, this is where the evaluation function returns the color at the corners
of the rectangular area defined by h and p. The preview display
interpolates between these at points inside the rectangle.
colRect[0] gets the color of (h[0], p[0])
colRect[1] gets the color of (h[0], p[1])
colRect[2] gets the color of (h[1], p[0])
colRect[3] gets the color of (h[1], p[1])
- color
- In real mode, this is where the evaluation function returns the color of the rectangle
defined by h and p.
|