WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-24-2009, 09:13 AM
reedev reedev is offline
Member
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 16
How do I add custom functions to a custom plugin?

Hi,

I am working on CustomNode plugin. I have my custom node up and running fine.

Now I would like to add my own functions to the plugin. Can anyone show me how that's done? It's not in the CustomNode example.

Thanks a lot.

Best regards
Raymond
Reply With Quote
  #2  
Old 01-26-2009, 06:46 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is a small example that uses the skydome plugin to show how to customize a plugin object. Usually you create your own Python module that specifies your class. In this example, create a file called SkyDome.py and add the following code to it:
Code:
import viz

class SkyDomeClass(viz.VizCustomChild):
	
	def myfunc(self):
		self.command(1)
		
viz.upgradeCustomNode('skydome.dlc',SkyDomeClass)

def addSkyDome():
	return viz.add('skydome.dlc')
The following code shows how to use your new module:
Code:
import viz
viz.go()

dome = addSkyDome()
dome.myfunc()
Reply With Quote
  #3  
Old 01-27-2009, 06:27 AM
reedev reedev is offline
Member
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 16
Hi,

Aha, ok, it's starting to make sense...
This command is then calling the C++ class func
void CommandCustomNode(void *custom) ? (from the CustomNode example)

Is there not a direct way of calling the CommandCustomNode() func? Isn't it exposed via the python module?

thanks
Raymond
Reply With Quote
  #4  
Old 01-27-2009, 08:07 AM
reedev reedev is offline
Member
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 16
Also, I would like to specify arguments when the plugin is loaded, so that I can specify these arguments to my constructor.

thanks,
Raymond
Reply With Quote
  #5  
Old 01-27-2009, 06:37 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
When you create the custom node object, you can optionally specify additional arguments:
Code:
mynode = viz.add('mynode.dlc',command,mesg,x,y,z,w)
You can also send additional commands to the node once it is created:
Code:
mynode.command(command,mesg,x,y,z,w)
The command, mesg, x, y, z, w values are part of the VizCustomNodeObj structure that is passed to your C++ function.
Reply With Quote
  #6  
Old 01-28-2009, 01:16 AM
reedev reedev is offline
Member
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 16
Hi,
So this way I don't need to create a python class, right?
I like the last way better.

Thanks a lot
Raymond
Reply With Quote
  #7  
Old 01-28-2009, 04:31 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You don't have to create a Python class for you custom nodes. Wrapping your custom commands with proper functions usually makes the code easier to read, and this is the main reason to do it. It's 100% optional though.
Reply With Quote
  #8  
Old 02-01-2009, 04:39 AM
reedev reedev is offline
Member
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 16
It's all clear to me right. And working :-)

Thanks a lot for your support.
Best regards
Raymond
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Vizard Sensor Plugin farshizzo Plug-in development 25 08-01-2019 01:24 AM
Custom Render .EXE export vaestebob Plug-in development 2 05-12-2008 08:55 AM
Could not find plugin to load objects... halley Vizard 1 05-30-2006 12:01 PM
animating custom faces: in search of "open_mouth" morphs vr_boyko Vizard 1 09-16-2004 11:30 AM
Creating Custom Avatar Heads farshizzo Vizard 22 09-12-2004 10:23 PM


All times are GMT -7. The time now is 04:23 PM.


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