r3zbuffe

r3zbuffe

Class

real/frio/r3zbuffe.h

Library

r3frio

Description:

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.

See Also

oops/r3root.h

Super Class

r3Root

R3CLID_ROOT

JavaScript

r3Zbuffer

Class Identifier

R3CLID_ZBUFFER - 750

Methods

INITIALIZE, DECLARECHANNELS, SETCHANNELS, RESETCHANNELS, DEFAULTDRAWOPTIONS, PIXEL, APIXEL, DISC, LINE, MPIXEL, MAPIXEL, MDISC, MLINE,

Attributes

ErrorState, DataType, Particle, Width, Height, MonoMode, MonoRadius, ModelView, CameraSpace, Projection, LineType, Scale,

Registration

int R3RegisterZBufferClass(R3APP *app);

Pen indexes. Currently four pens supported (used in biliner interpolation)

R3ZB_PEN0
R3ZB_PEN1
R3ZB_PEN2
R3ZB_PEN3

R3ZBM_INITIALIZE

Method

INITIALIZE

Identifier

R3ZBM_INITIALIZE

JavaScript

obj.INITIALIZE();

Description

Init z buffer to a new resolution & aspect

R3ZBM_DECLARECHANNELS

Method

DECLARECHANNELS

Identifier

R3ZBM_DECLARECHANNELS

Param 1:

R3INT, number of channels (0 if no interpolated channels needed)

Param 2:

R3INT*, ptr to an array of channel offsets or NULL

Param 3:

R3INT*, ptr to an array of channel sub counts or NULL

JavaScript

obj.DECLARECHANNELS(p1, p2, p3);

Description

Defines the interpolated channels for drawing methods

R3ZBM_SETCHANNELS

Method

SETCHANNELS

Identifier

R3ZBM_SETCHANNELS

Param 1:

R3INT, pen index

JavaScript

obj.SETCHANNELS(p1, 0);

Description

Defines channel values for a pen (a set of interpolation values)

R3ZBM_RESETCHANNELS

Method

RESETCHANNELS

Identifier

R3ZBM_RESETCHANNELS

Param 3:

R3INT, pen index

JavaScript

obj.RESETCHANNELS(p3);

Description

Resets channel values of a pen to zero

R3ZBM_DEFAULTDRAWOPTIONS

Method

DEFAULTDRAWOPTIONS

Identifier

R3ZBM_DEFAULTDRAWOPTIONS

JavaScript

obj.DEFAULTDRAWOPTIONS();

Description

Resets all drawing options (currently ZBA_MonoMode=FALSE, ZBA_LineType=R3ZLT_SEPARATE)

R3ZBM_PIXEL

Method

PIXEL

Identifier

R3ZBM_PIXEL

JavaScript

obj.PIXEL();

Description

R3ZBM_APIXEL

Method

APIXEL

Identifier

R3ZBM_APIXEL

JavaScript

obj.APIXEL();

Description

R3ZBM_DISC

Method

DISC

Identifier

R3ZBM_DISC

JavaScript

obj.DISC();

Description

R3ZBM_LINE

Method

LINE

Identifier

R3ZBM_LINE

JavaScript

obj.LINE();

Description

R3ZBM_MPIXEL

Method

MPIXEL

Identifier

R3ZBM_MPIXEL

JavaScript

obj.MPIXEL();

Description

R3ZBM_MAPIXEL

Method

MAPIXEL

Identifier

R3ZBM_MAPIXEL

JavaScript

obj.MAPIXEL();

Description

R3ZBM_MDISC

Method

MDISC

Identifier

R3ZBM_MDISC

JavaScript

obj.MDISC();

Description

R3ZBM_MLINE

Method

MLINE

Identifier

R3ZBM_MLINE

JavaScript

obj.MLINE();

Description

ErrorState

Attribute

ErrorState

Identifier

R3ZBA_ErrorState

JavaScript type

Integer

C type

R3INT

Description

Status attribute: if nonzero, an error has occurred

Syntax


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

Attribute

DataType

Identifier

R3ZBA_DataType

JavaScript type

Integer

C type

R3INT

Description

a datatype for storing fade+additional channels (see r3typids.h)

Syntax


jsobj.SetDataType(value);


R3INT value = ...;
R3SetAttrs(r3obj, R3ZBA_DataType, value, R3TAG_END);

Particle

Attribute

Particle

Identifier

R3ZBA_Particle

JavaScript type

Object

C type

R3OBJ*

Description

value for the particle address stored in each written pixel

Syntax


jsobj.SetParticle(value);


R3OBJ* value = ...;
R3SetAttrs(r3obj, R3ZBA_Particle, value, R3TAG_END);

Width

Attribute

Width

Identifier

R3ZBA_Width

JavaScript type

Integer

C type

R3INT

Description

width of buffer (read only)

Syntax


value = jsobj.GetWidth();


R3INT value;
R3GetAttrs(r3obj, R3ZBA_Width, &value, R3TAG_END);

Height

Attribute

Height

Identifier

R3ZBA_Height

JavaScript type

Integer

C type

R3INT

Description

height of buffer (read only)

Syntax


value = jsobj.GetHeight();


R3INT value;
R3GetAttrs(r3obj, R3ZBA_Height, &value, R3TAG_END);

MonoMode

Attribute

MonoMode

Identifier

R3ZBA_MonoMode

JavaScript type

Boolean

C type

R3BOOL

Description

if true then overlapping pixels from same particle inside R3ZBA_MonoRadius distance eliminated

Syntax


jsobj.SetMonoMode(value);


R3BOOL value = ...;
R3SetAttrs(r3obj, R3ZBA_MonoMode, value, R3TAG_END);

MonoRadius

Attribute

MonoRadius

Identifier

R3ZBA_MonoRadius

JavaScript type

Number

C type

R3FLOAT

Description

distance that is used in overlap pixel elimination

Syntax


jsobj.SetMonoRadius(value);


R3FLOAT value = ...;
R3SetAttrs(r3obj, R3ZBA_MonoRadius, value, R3TAG_END);

ModelView

Attribute

ModelView

Identifier

R3ZBA_ModelView

Type

r3Matrix

Description

defines the projection matrix for 3d drawing

Syntax


jsobj.SetModelView(value);


R3MATRIX value = ...;
R3SetAttrs(r3obj, R3ZBA_ModelView, &value, R3TAG_END);

CameraSpace

Attribute

CameraSpace

Identifier

R3ZBA_CameraSpace

Type

r3Matrix

Description

defines the camera csys

Syntax


jsobj.SetCameraSpace(value);


R3MATRIX value = ...;
R3SetAttrs(r3obj, R3ZBA_CameraSpace, &value, R3TAG_END);

Projection

Attribute

Projection

Identifier

R3ZBA_Projection

JavaScript type

Integer

C type

R3INT

Description

see defines below

Syntax


jsobj.SetProjection(value);


R3INT value = ...;
R3SetAttrs(r3obj, R3ZBA_Projection, value, R3TAG_END);

LineType

Attribute

LineType

Identifier

R3ZBA_LineType

JavaScript type

Integer

C type

R3INT

Description

see defines below

Syntax


jsobj.SetLineType(value);


R3INT value = ...;
R3SetAttrs(r3obj, R3ZBA_LineType, value, R3TAG_END);

Scale

Attribute

Scale

Identifier

R3ZBA_Scale

JavaScript type

Number

C type

R3FLOAT

Description

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.

Syntax


value = jsobj.GetScale();


R3FLOAT value;
R3GetAttrs(r3obj, R3ZBA_Scale, &value, R3TAG_END);

modelview projection types

R3ZBP_PERSPECTIVE
R3ZBP_ORTHOGONAL

Line drawing styles (for controlling ZBM_LINE & MLINE):

R3ZLT_SEPARATE
R3ZLT_CONTINUOUS

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