Public Member Functions

GBufReader Class Reference

This reference page is linked to from the following overview topics: RPF Files and the G-Buffer.


Search for all occurrences

Detailed Description

See also:
Class GBuffer, Class GBufWriter, Structure GBufData, G-Buffer Channel Indices.

Description:
This class is available in release 3.0 and later only.

This is the object returned by GBuffer::CreateReader(). Methods of this class allow the G-Buffer data to be read.

Here is an example of reading multiple layer data from the G-Buffer using methods of this class.

void ReadExample(GBuffer *gb)
{
    float zr, UBYTE midr;
    GBufReader *rdr = gb->CreateReader();
    for (int y=0; y<10; y++) {
        rdr->StartLine(y);
        for (int x=5; x<100; x+=4) {
            int res = rdr->StartPixel(x);
            rdr->ReadChannelData(GB_Z,(void *)&zr);
            rdr->ReadChannelData(GB_MTL_ID,(void *)&midr);
            while (rdr->StartNextLayer()) {
                rdr->ReadChannelData(GB_Z,(void *)&zr);
                rdr->ReadChannelData(GB_MTL_ID,(void *)&midr);
            }
        }
    }
    gb->DestroyReader(rdr);
}
All methods of this class are implemented by the System.

#include <gbuf.h>

Inheritance diagram for GBufReader:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual int  StartLine (int y)=0
virtual BOOL  StartPixel (int x)=0
virtual BOOL  StartPixel (int x, int y)=0
virtual BOOL  StartNextLayer ()=0
virtual int  NextPixel ()=0
virtual BOOL  ReadChannelData (int chan, void *data)=0
virtual BOOL  ReadAllData (GBufData *data)=0
virtual BOOL  ModifyChannelData (int chan, void *data)=0
virtual BOOL  ModifyAllData (GBufData *data)=0
virtual void  DeleteThis ()=0
virtual INT_PTR  Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)

Member Function Documentation

virtual int StartLine ( int  y ) [pure virtual]
Remarks:
Call this method to start a new scan line. Call this method before the first scan line.
Parameters:
int y

The zero based index of the scan line to start.
Returns:
Returns -1 if there was no data for line, or the x value of first non-empty pixel.
virtual BOOL StartPixel ( int  x ) [pure virtual]
Remarks:
Call this method to start a new pixel. This method automatically starts the first layer.
Parameters:
int x

The zero based index of the pixel to start.
Returns:
Returns TRUE.
virtual BOOL StartPixel ( int  x,
int  y 
) [pure virtual]
Remarks:
This method is called to start a new line and pixel. This method is equivalent to:

StartLine(y);

return StartPixel(x);
virtual BOOL StartNextLayer ( ) [pure virtual]
Remarks:
This method is called to begin reading data from a new layer. Do not call this method before reading the first layer.
Returns:
TRUE if more data to read; otherwise FALSE.
virtual int NextPixel ( ) [pure virtual]
Remarks:
Call this method to prepare for reading the next pixel.
Returns:
Returns TRUE.
virtual BOOL ReadChannelData ( int  chan,
void *  data 
) [pure virtual]
Remarks:
Reads a data element from the specified channel of the G-Buffer from the current scan line and pixel.
Parameters:
The channel to read. One of the items from: G-Buffer Channel Indices.

void *data

Points to storage for the data.
Returns:
TRUE if data was available; otherwise FALSE.
virtual BOOL ReadAllData ( GBufData data ) [pure virtual]
Remarks:
Reads all the data from the G-Buffer into the GBufData structure passed from the current scan line and pixel.
Parameters:
GBufData *data

Points to storage for the data. See Structure GBufData.
Returns:
TRUE if data was available; otherwise FALSE.
virtual BOOL ModifyChannelData ( int  chan,
void *  data 
) [pure virtual]
Remarks:
This method allows values in the specified layer to be written. Note that it may seem strange, writing data from the reader, but developers asked for the capability of writing to the already created gbuffer, and it is much simpler to add this capability to the GBufReader than to GBufWriter, which is designed to construct gbuffers from scratch, not modify existing ones.
Parameters:
int chan

Specifies the channel to write to.

void *data

Points to the data to write.
Returns:
TRUE indicates success; FALSE indicates failure.
virtual BOOL ModifyAllData ( GBufData data ) [pure virtual]
Remarks:
This method allows values in the current layer to be written. Note that it may seem strange, writing data from the reader, but developers asked for the capability of writing to the already created gbuffer, and it is much simpler to add this capability to the GBufReader than to GBufWriter, which is designed to construct gbuffers from scratch, not modify existing ones.
Parameters:
GBufData *data

Points to the data to write.
Returns:
TRUE indicates success; FALSE indicates failure.
virtual void DeleteThis ( ) [pure virtual]
Remarks:
Deletes this reader object. Call this method when finished.
virtual INT_PTR Execute ( int  cmd,
ULONG_PTR  arg1 = 0,
ULONG_PTR  arg2 = 0,
ULONG_PTR  arg3 = 0 
) [inline, virtual]
Remarks:
This is a general purpose function that allows the API to be extended in the future. The 3ds Max development team can assign new cmd numbers and continue to add functionality to this class without having to 'break' the API.

This is reserved for future use.
Parameters:
int cmd

The command to execute.

ULONG arg1=0

Optional argument 1 (defined uniquely for each cmd).

ULONG arg2=0

Optional argument 2.

ULONG arg3=0

Optional argument 3.
Returns:
An integer return value (defined uniquely for each cmd).
Default Implementation:
{ return 0; }
{ return 0; } 

GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader
GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader GBufReader