WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 15 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 02-13-2005, 01:10 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC