Class GBufReader

3DS Max Plug-In SDK

Class GBufReader

See Also: Class GBuffer, Class GBufWriter, Structure GBufData, List of GBuffer Channels Indexes.

class GBufReader : public InterfaceServer

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.

Methods:

public:

Prototype:

virtual int StartLine(int y)=0;

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.

Return Value:

Returns -1 if there was no data for line, or the x value of first non-empty pixel.

Prototype:

virtual BOOL StartPixel(int x)=0;

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.

Return Value:

Returns TRUE.

Prototype:

virtual BOOL StartPixel(int x, int y)=0;

Remarks:

This method is called to start a new line and pixel. This method is equivalent to:

 StartLine(y);

 return StartPixel(x);

Prototype:

virtual BOOL StartNextLayer()=0;

Remarks:

This method is called to begin reading data from a new layer. Do not call this method before reading the first layer.

Return Value:

TRUE if more data to read; otherwise FALSE.

Prototype:

virtual int NextPixel()=0;

Remarks:

Call this method to prepare for reading the next pixel.

Return Value:

Returns TRUE.

Prototype:

virtual BOOL ReadChannelData(int chan, void *data)=0;

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: List of GBuffer Channels Indexes.

void *data

Points to storage for the data.

Return Value:

TRUE if data was available; otherwise FALSE.

Prototype:

virtual BOOL ReadAllData(GBufData *data)=0;

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.

Return Value:

TRUE if data was available; otherwise FALSE.

Prototype:

virtual BOOL ModifyChannelData(int chan, void *data)=0;

Remarks:

This method is available in release 4.0 and later only.

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.

Return Value:

TRUE indicates success; FALSE indicates failure.

Prototype:

virtual BOOL ModifyAllData(GBufData *data)=0;

Remarks:

This method is available in release 4.0 and later only.

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.

Return Value:

TRUE indicates success; FALSE indicates failure.

Prototype:

virtual void DeleteThis()=0;

Remarks:

Deletes this reader object. Call this method when finished.

Prototype:

virtual INT_PTR Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0);

Remarks:

This method is available in release 3.0 and later only.

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.

Return Value:

An integer return value (defined uniquely for each cmd).

Default Implementation:

{ return 0; }