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)
Bases: lwsdk.lwsdk.IHandlerFuncs, lwsdk.lwsdk.IInterfaceFuncs, lwsdk.lwsdk.IGizmoFuncs, lwsdk.lwsdk.IItemFuncs
Proxy of C++ PCore::IFrameBuffer class
Prepare to receive the next frame. Returns an error message string if an error occurs, otherwise it returns None.
Close the frame buffer. Called when the rendering session is complete.
!! NOT DOCUMENTED !!
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.
A Python-only method that will extract a single pixel from the indicated buffer.
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 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.
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
.
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.
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 }
|