r3zbuffe
real/frio/r3zbuffe.h
r3frio
Z buffer. Tool for resolution-idependent, aspect-ratio corrected drawing to z buffer. Drawing primitives support unlimited multi-channel interpolation. All drawing methods are safe to use i.e. take care of clipping. Usage: zb = R3ObjectCreate(R3CLID_ZBUFFER, R3TAG_END); R3GetAttrs(zb, R3ZBA_ErrorState, &error, R3RA_Done); if(error) return (FALSE); Notes: - The R3ZBM_DECLARECHANNELS method should be always called before using the Z buffer. - Both view coordinate drawing (2D coords + distance) and 3D drawing in model space are supported. For example, R3ZBM_PIXEL draws a point with given view coordinates+distance, whereas M-for-Model-prefixed method R3ZBM_MPIXEL uses unprojected 3D coordinates. - Floating point 2D drawing coordinates are mapped so that (0,0) corresponds to the top left corner and (1, h) is the bottom right corner, where 'h' depends on the pixel aspect ratio. - Due to dynamical nature, simple frequently repeatable operations may fail. For convenience, an error status attribute is provided. The error status can be set to zero (=no errors) by R3ZBM_INITIALIZE, or by reading the status, or by using R3SetAttrs. Check the status for example after all drawing actions. Using this approach makes the code shorter and faster.
r3Root
R3CLID_ROOT
r3Zbuffer
R3CLID_ZBUFFER - 750
INITIALIZE, DECLARECHANNELS, SETCHANNELS, RESETCHANNELS, DEFAULTDRAWOPTIONS, PIXEL, APIXEL, DISC, LINE, MPIXEL, MAPIXEL, MDISC, MLINE,
ErrorState, DataType, Particle, Width, Height, MonoMode, MonoRadius, ModelView, CameraSpace, Projection, LineType, Scale,
int R3RegisterZBufferClass(R3APP *app);
Pen indexes. Currently four pens supported (used in biliner interpolation)
R3ZBM_INITIALIZE
INITIALIZE
R3ZBM_INITIALIZE
obj.INITIALIZE();
Init z buffer to a new resolution & aspect
R3ZBM_DECLARECHANNELS
DECLARECHANNELS
R3ZBM_DECLARECHANNELS
R3INT, number of channels (0 if no interpolated channels needed)
R3INT*, ptr to an array of channel offsets or NULL
R3INT*, ptr to an array of channel sub counts or NULL
obj.DECLARECHANNELS(p1, p2, p3);
Defines the interpolated channels for drawing methods
R3ZBM_SETCHANNELS
SETCHANNELS
R3ZBM_SETCHANNELS
R3INT, pen index
obj.SETCHANNELS(p1, 0);
Defines channel values for a pen (a set of interpolation values)
R3ZBM_RESETCHANNELS
RESETCHANNELS
R3ZBM_RESETCHANNELS
R3INT, pen index
obj.RESETCHANNELS(p3);
Resets channel values of a pen to zero
R3ZBM_DEFAULTDRAWOPTIONS
DEFAULTDRAWOPTIONS
R3ZBM_DEFAULTDRAWOPTIONS
obj.DEFAULTDRAWOPTIONS();
Resets all drawing options (currently ZBA_MonoMode=FALSE, ZBA_LineType=R3ZLT_SEPARATE)
R3ZBM_PIXEL
PIXEL
R3ZBM_PIXEL
obj.PIXEL();
R3ZBM_APIXEL
APIXEL
R3ZBM_APIXEL
obj.APIXEL();
R3ZBM_DISC
DISC
R3ZBM_DISC
obj.DISC();
R3ZBM_LINE
LINE
R3ZBM_LINE
obj.LINE();
R3ZBM_MPIXEL
MPIXEL
R3ZBM_MPIXEL
obj.MPIXEL();
R3ZBM_MAPIXEL
MAPIXEL
R3ZBM_MAPIXEL
obj.MAPIXEL();
R3ZBM_MDISC
MDISC
R3ZBM_MDISC
obj.MDISC();
R3ZBM_MLINE
MLINE
R3ZBM_MLINE
obj.MLINE();
ErrorState
ErrorState
R3ZBA_ErrorState
Integer
R3INT
Status attribute: if nonzero, an error has occurred
jsobj.SetErrorState(value);
value = jsobj.GetErrorState();
R3INT value = ...;
R3SetAttrs(r3obj, R3ZBA_ErrorState, value, R3TAG_END);
R3INT value;
R3GetAttrs(r3obj, R3ZBA_ErrorState, &value, R3TAG_END);
DataType
DataType
R3ZBA_DataType
Integer
R3INT
a datatype for storing fade+additional channels (see r3typids.h)
jsobj.SetDataType(value);
R3INT value = ...;
R3SetAttrs(r3obj, R3ZBA_DataType, value, R3TAG_END);
Particle
Particle
R3ZBA_Particle
Object
R3OBJ*
value for the particle address stored in each written pixel
jsobj.SetParticle(value);
R3OBJ* value = ...;
R3SetAttrs(r3obj, R3ZBA_Particle, value, R3TAG_END);
Width
Width
R3ZBA_Width
Integer
R3INT
width of buffer (read only)
value = jsobj.GetWidth();
R3INT value;
R3GetAttrs(r3obj, R3ZBA_Width, &value, R3TAG_END);
Height
Height
R3ZBA_Height
Integer
R3INT
height of buffer (read only)
value = jsobj.GetHeight();
R3INT value;
R3GetAttrs(r3obj, R3ZBA_Height, &value, R3TAG_END);
MonoMode
MonoMode
R3ZBA_MonoMode
Boolean
R3BOOL
if true then overlapping pixels from same particle inside R3ZBA_MonoRadius distance eliminated
jsobj.SetMonoMode(value);
R3BOOL value = ...;
R3SetAttrs(r3obj, R3ZBA_MonoMode, value, R3TAG_END);
MonoRadius
MonoRadius
R3ZBA_MonoRadius
Number
R3FLOAT
distance that is used in overlap pixel elimination
jsobj.SetMonoRadius(value);
R3FLOAT value = ...;
R3SetAttrs(r3obj, R3ZBA_MonoRadius, value, R3TAG_END);
ModelView
ModelView
R3ZBA_ModelView
defines the projection matrix for 3d drawing
jsobj.SetModelView(value);
R3MATRIX value = ...;
R3SetAttrs(r3obj, R3ZBA_ModelView, &value, R3TAG_END);
CameraSpace
CameraSpace
R3ZBA_CameraSpace
defines the camera csys
jsobj.SetCameraSpace(value);
R3MATRIX value = ...;
R3SetAttrs(r3obj, R3ZBA_CameraSpace, &value, R3TAG_END);
Projection
Projection
R3ZBA_Projection
Integer
R3INT
see defines below
jsobj.SetProjection(value);
R3INT value = ...;
R3SetAttrs(r3obj, R3ZBA_Projection, value, R3TAG_END);
LineType
LineType
R3ZBA_LineType
Integer
R3INT
see defines below
jsobj.SetLineType(value);
R3INT value = ...;
R3SetAttrs(r3obj, R3ZBA_LineType, value, R3TAG_END);
Scale
Scale
R3ZBA_Scale
Number
R3FLOAT
read only, to find out 'zoom scale'. Useful when using 2D drawing methods. If a diameter is r and its distance from camera is d, projected size is proj_r = r*R3ZBA_Scale/div, where div is 1 in orthogonal, d in perspective.
value = jsobj.GetScale();
R3FLOAT value;
R3GetAttrs(r3obj, R3ZBA_Scale, &value, R3TAG_END);
modelview projection types
Line drawing styles (for controlling ZBM_LINE & MLINE):
Common datatype of fade + all other (sub) channels. As defined in r3typids.h
Number of channel items
R3CHADDR in raysample. NOTE: max raysample size 65 K !!!
channel sub count
r3channelmininfo /
0
Always R3FLOAT !
Declared here as R3FLOAT, may be actually other smaller datatype
Other channel data may follow fade, as specified in R3CINFO