To subclass from an imported object you would do the same thing as subclassing from an OTF object. I'm posting an example script that shows how to do this. It also shows how to subclass from an EventClass also. One thing to note when subclassing from a VizNode and EventClass is that both classes have a
callback function, so you have to explicitly specify which version you want to call when using it. The sample script shows how to do this.
Code:
import viz
viz.go()
#Define class that inherits from VizNode and EventClass
class MyNodeClass(viz.VizNode,viz.EventClass):
def __init__(self):
#Create some node
self.node = viz.add('ball.wrl')
#Initialize base classes
viz.VizNode.__init__(self,self.node.id)
viz.EventClass.__init__(self)
#Since both VizNode and EventClass have a "callback" function
#we have to explicitly specify the EventClass "callback" function
viz.EventClass.callback(self,viz.TIMER_EVENT,self.mytimer)
self.starttimer(0,0.01,viz.FOREVER)
def mytimer(self,num):
self.node.rotate(0,1,0,90*viz.elapsed(),viz.RELATIVE_LOCAL)
#Create an instance of my custom class
myclass = MyNodeClass()
#Perform basic node operations on custom class
myclass.translate(0,1,4)