Frame Buffer Class

Note

These interface classes are not intended for direct usage; rather they should be inherited by your own subclass. (See Anatomy of a LightWave Python Plug-in)

Handler

class lwsdk.IFrameBuffer

Bases: lwsdk.lwsdk.IHandlerFuncs, lwsdk.lwsdk.IInterfaceFuncs, lwsdk.lwsdk.IGizmoFuncs, lwsdk.lwsdk.IItemFuncs

Proxy of C++ PCore::IFrameBuffer class

 begin() → LWError

Prepare to receive the next frame. Returns an error message string if an error occurs, otherwise it returns None.

 close()

Close the frame buffer. Called when the rendering session is complete.

 getPixelMap() → LWPixmapID

!! NOT DOCUMENTED !!

 get_buffer(void buffer, int length, int type) → PyObject

This Python-only "helper" method retrieves the entire contents of the indicated buffer into Python space so it can be used locally. While this consumes more memory, it improves processing speed over retrieving a single pixel at a time with IFrameBuffer::get_pixel().

The return value is a sequence of data whose type depends upon the IFrameBuffer::type setting, and is as wide as the width argument to the IFrameBuffer::open() method.

 get_pixel(void buffer, int index, int type) → PyObject

A Python-only method that will extract a single pixel from the indicated buffer.

 open(int arg0, int arg1) → LWError

Initialize the frame buffer. Called when a rendering session begins. Returns an error message string if an error occurs, otherwise it returns None.

arg0 is the width of the buffer data, and arg1 is the height (i.e., number of rows).

 pause()

Pause awaiting user input. This is called for F9 and manually advanced frames, but not during automatic rendering. Typically the frame buffer displays the image here and then waits for the user to dismiss the display before returning from this function.

 type → int

This value indicates the data type of the individual pixel values in the buffers. It will be either lwsdk.LWFBT_UBYTE or lwsdk.LWFBT_FLOAT.

 write(void arg0, void arg1, void arg2, void arg3) → LWError

Receive the next scanline of the current frame. The scanlines for each frame are sent in order from top to bottom. The buffer arguments arg0, arg1, arg2, and arg3 are opaque pointers to arrays of color channel values red, green, blue and alpha. There are exactly width values (provided to IFrameBuffer::open()) for each channel, one for each pixel in a scanline, and the values are either unsigned byte or float, depending on the IFrameBuffer::type setting. Returns an error message string, or None.

Use either IFrameBuffer::get_pixel() or IFrameBuffer::get_buffer() to retrieve the data within the pointers.

Factory

class lwsdk.FrameBufferFactory(name, klass)

Bases: lwsdk.lwsdk.IFrameBufferFactory

Default Python Factory for IFrameBuffer

 create(context)
 destroy(instance)

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class framebuffer(lwsdk.IFrameBuffer):
    def __init__(self, data):
        super(framebuffer, self).__init__()

        # 'data' is a tuple that contains:
        #   - data[0] is the 'context' (a camera item id)
        #   - data[1] is the 'type' of each pixel element
        #     in the buffers (either LWFBT_UBYTE or LWFBT_FLOAT)
[...]
    # LWFrameBuffer ---------------------------------------
    def draw_canvas(self, control, data, mode):
       x = control.hotx()
       y = control.hoty()
       self._raster_funcs.blitPanel(self._buffer, 0, 0, self._panel, x, y, self._width, self._height)

    def open(self, width, height):
        self._width = width
        self._height = height

        self._buffer = self._raster_funcs.create(self._width, self._height, 0)
[...]
ServerRecord = { lwsdk.FrameBufferFactory("LW_PyFrameBuffer", framebuffer) : ServerTagInfo }

Table Of Contents

Previous topic

Item Motion Class

Next topic

Custom Object Class

This Page