Custom Object 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.ICustomObj

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

Proxy of C++ PCore::ICustomObj class

 evaluate(LWCustomObjAccess arg0)

Draw the object on the interface using the information in the LWCustomObjAccess class instance (described below).

 flags() → unsigned int

Returns bit flags combined using bitwise-or.

Access

class lwsdk.LWCustomObjAccess(*args)

Bases: object

Proxy of C++ PCore::LWCustomObjAccess class

 circle(void arg1, double arg2, double arg3, int csys)

Draw a circle of the given radius around the specified center point using the current color and line pattern.

 disk(void arg1, double arg2, double arg3, int csys)

Draw a disk (filled circle) of the given radius around the specified center point using the current color.

 dispData → void

An opaque pointer to private data used by Layout. Pass this as the first argument to the drawing functions.

 flags → int

Contains bitfields with information about the context of the render request.

 line(void arg1, double arg2, double arg3, int csys)

Draw a line between the specified endpoints using the current color and line pattern.

 point(void arg1, double arg2, int csys)

Draw a point at the specified position. The point will be drawn in the color set by the most recent LWCustomObjAccess::setColor() call, or in the default color if no color was set.

 polyIndexed(void arg1, unsigned int numv, unsigned int verts, double arg2, int csys)

Draw a polygon where the vertices are given as indices into an array of vertices. The array of indices must contain at least numv indices. The array of vertices must contain at least all the points in the indices array. Not all vertices have to be used.

 polygon(void arg1, unsigned int numv, double arg2, int csys)

Draw a polygon using the given vertices. The array of vertices must contain at least numv points.

 quad(void arg1, double arg2, double arg3, double arg4, double arg5, int csys)

Draw a solid quadrangle with the specified vertices using the current color or texture.

 setCSysItem(void arg1, LWItemID item)

Sets the item used for relative coordinate systems, namely lwsdk.LWCSYS_OBJECT and lwsdk.LWCSYS_ICON. This overrides the default, if any.

 setColor(void arg1, float rgba)

Set the current drawing color, including the alpha level. Calling this is optional. By default, all drawing is done in the color set by the user in the Scene panel when the custom object isn't selected, and in yellow when the object is selected. Color settings don't persist between calls to the evaluation function, nor do they change the settings in the Scene panel.

 setDrawMode(void arg1, unsigned int mode)

Sets the current drawing mode.

 setPart(void arg1, unsigned int part)

Associate a part number with the following drawing. The parts can be numbered from 1 to 32 inclusive. A part number of 0 implies no particular part number association. This is currently only useful for implementing gizmos.

 setPattern(void arg1, int lpat)

Set the current line pattern.

 setTexture(void arg1, int arg2, unsigned char arg3)

Set the current image for texture mapping. This image is mapped onto quads drawn by the quad function. The size is the width (and height) of the image in pixels and must be a power of 2. The pixel data is an OpenGL image in lwsdk.GL_RGBA format and lwsdk.GL_UNSIGNED_BYTE data type. Each pixel is represented by a set of four contiguous bytes containing red, green, blue and alpha values ranging from 0 to 255.

 setUVs(void arg1, double arg2, double arg3, double arg4, double arg5)

Set the UVs for texture mapping. This sets the position of the texture image on each polygon drawn by the LWCustomObjAccess::quad() function until the next call to LWCustomObjAccess::setUVs().

 text(void arg1, double arg2, char arg3, int just, int csys)

Draw a single line of text using the current color and line pattern. The justify argument determines whether the text will be drawn to the left or right of the position, or centered on it.

 triangle(void arg1, double arg2, double arg3, double arg4, int csys)

Draw a solid triangle with the specified vertices using the current color.

 view → int

The view the object will be drawn in.

 viewDir → LWDVector

The viewing direction of the conceptual viewport camera.

 viewPos → LWDVector

The position of the conceptual viewport camera.

Factory

class lwsdk.CustomObjFactory(name, klass)

Bases: lwsdk.lwsdk.ICustomObjFactory

Default Python Factory for ICustomObj

 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
23
24
class basic_barn(lwsdk.ICustomObj):
    def __init__(self, context):
        super(basic_barn, self).__init__()

        self._itemid = context

    # LWCustomObjHandler ----------------------------------
    def evaluate(self, ca):
        global vert, edge
        for i in range(0, 15):
            ca.line(ca.dispData,
                    vert[edge[i][0]],
                    vert[edge[i][1]],
                    lwsdk.LWCSYS_OBJECT)

        ca.setPattern(ca.dispData, lwsdk.LWLPAT_DOT)

        for i in range(15, 17):
            ca.line(ca.dispData,
                    vert[edge[i][0]],
                    vert[edge[i][1]],
                    lwsdk.LWCSYS_OBJECT)
[...]
ServerRecord = { lwsdk.CustomObjFactory("LW_PyBasicBarn", basic_barn) : ServerTagInfo }

Table Of Contents

Previous topic

Frame Buffer Class

Next topic

Image Filter Class

This Page