Skip to content

Instantly share code, notes, and snippets.

@nrichards
Created February 23, 2012 07:35
Show Gist options
  • Save nrichards/1891329 to your computer and use it in GitHub Desktop.
Save nrichards/1891329 to your computer and use it in GitHub Desktop.
LightWave 11 - Python Plugin - Radial Move
# WARNING: Some or all of this may be wrong! This is a learning exercise created by a newbie!
#
# radial_move.py
# Modeler plugin
# Based entirely upon Radial_Move.ls by:
# FaLogFx http://forums.newtek.com/showthread.php?t=123806
# aka Michael Andersson micke@bmck.se
#
# LightWave plugins:
# http://forums.newtek.com/showthread.php?t=123672
#
# Python:
# http://en.wikipedia.org/wiki/Python_syntax_and_semantics
#
# BEGIN REQUIRED
# Load the LightWave SDK
import lwsdk
# Declare some mystery variables
__author__ = "Nick Richards"
__date__ = "Wed Feb 22 2012"
__copyright__ = "Free"
__version__ = "0.1"
__maintainer__ = "Zombies"
__email__ = "ncr100 on forums.newtek.com"
__status__ = "Ambitious"
__lwver__ = "11"
class radial_move(lwsdk.IDisplacement):
# You must define this __init__ thing
def __init__(self, context):
super(radial_move, self).__init__()
# Now in the class, provide my own overridden directives for the LWSDK-default functions
# The "IInterfaceFuncs" interface (prefix "inter_" aka LWInterfaceFuncs) deal with User Interface.
# Only callback function to override:
# ui()
def inter_ui(self):
dummy=0
# The "IRenderFuncs" interface (prefix "rend_" aka LWRenderFuncs) deal with (? Rendering ?).
# Choose to override any/all of these:
# init(), cleanup(), newTime()
def rend_newTime(self, frame, time):
dummy=0
# The "IHandlerFuncs" interface (prefix "inst_" aka LWInstanceFuncs) deal with (? ?).
# Choose to override any/all of these:
# load(), save(), copy(), descln()
def inst_load(self, state):
dummy=0
def inst_save(self, state):
dummy=0
def inst_copy(self, source):
dummy=0
def inst_descln(self):
dummy=0
# The "IItemFuncs" interface (prefix "item_" aka LWItemFuncs) deal with (? ?).
# Choose to override any/all of these:
# changeName(), changeID(), useItems()
def item_changeID(self, itemid_list):
dummy=0
# The "IDisplacement" interface (no prefix since we're directly implementing a LWDisplacement)
# deal with (? ?).
# Choose to override any/all of these:
# evaluate(), flags()
def flags(self):
dummy=0
def evaluate(self, displacement_access):
dummy=0
# (? Not sure what to do here ?)
"""class DisplacementFactory(IDisplacementFactory):
# Default Python Factory for IDisplacement
def __init__(self, name, klass):
super(DisplacementFactory, self).__init__()
self._instances = []
self._klass = klass
self._plugin_name = name
def create(self, context):
# return an instance of our 'klass'
instance = self._klass(context)
self._instances.append(instance)
return instance
def destroy(self, instance):
assert isinstance(instance, self._klass)
self._instances.remove(instance)
def name(self):
return self._plugin_name"""
# NOTE: This must be AFTER the "class radial_move" declaration, otherwise LW gives error.
# To declare a registration for the plugin, populate ServerTagInfo.
# (?) Define more (ServerTagInfo1, ServerTagInfo2, ...) to use below, exposing more plugins
# from just this one script.
ServerTagInfo = [
( "Python Radial Move", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
( "Radial Move(PY)", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )
]
# e.g. ServerTagInfo1 = [ (...), (...), (...) ]
# To identify how this plugin plugs-in to the available LWSDK factories which would activate
# it inside the app, declare ServerRecord as one of the following (omitting the "I" and
# add "Factory" to the end):
# IGeneric ICommandSequence IShader IObjReplacement IDisplacement ILayoutTool
# IChannel IItemMotion IMaster ICustomObj IImageFilter (? more ?)
# Using IDisplacement as "DisplacementFactory" below pulls in the following features:
# IHandlerFuncs, IInterfaceFuncs, IGizmoFuncs, IItemFuncs, IRenderFuncs (? where to learn this ?)
# NOTE: I might switch factories after I read RadialMove.ls more closely.
# radial_move here is a reference to the actual plugin class, the code, which you must
# declare below. (? may I hijack another class and augment its functionality ?)
# Add more plugins by adding more of these "Factory():ServerTagInfo" phrases each separated
# with a comma. (? try it to confirm ?)
ServerRecord = { lwsdk.DisplacementFactory("LW_PyRadialMove", radial_move) : ServerTagInfo }
# END REQUIRED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment