WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-10-2009, 01:13 PM
durf durf is offline
Member
 
Join Date: Feb 2009
Posts: 61
multiple objects

Im trying to think of a faster way to write this code. I have 3 objects. All 3 objects work as a whole. For example. Object 1 fits inside of object 2 and object 2 fits inside of object 3. So image a telescope that collapses. Below is the code that goes with these objects. How can I make multiple instance of these objects without writing a ton of extra code. Like I dont want to do bottom, bottom2, bottom3...etc. But maybe that is the only way. Any suggestions? I can clarify more if need be.

Thanks


Code:
import viz
import vizact
import viztask
import random

viz.go()

PORT_PPT = 6

viz.add('tut_ground.wrl')

viz.MainView.setPosition([0,10,-35]) #sets camera position
viz.MainView.setEuler([0,2,0]) #sets camera pitch

bottom = viz.add('growthBOTTOM.wrl')
middle = viz.add('growthMIDDLE.wrl')
top = viz.add('growthTOP.wrl')

#sets them on the same x z axis but different on the y axis
bottom.setPosition([0,5,0])
bottom.scale(.2,.2,.2)
middle.setPosition([0,7,0])
middle.scale(.2,.2,.2)
top.setPosition([0,9,0])
top.scale(.2,.2,.2)

ppt1 = viz.add('vizppt.dls')

ball1 = viz.add('white_ball.wrl')
ball1.scale(1,1,1)
ballLink1 = viz.link(ppt1, ball1)
ballLink1.postScale([8,1,13],target = viz.LINK_FULL_OP)

def moveFlower():
	x,y,z = ball1.getPosition()
	

	if y <= 6:
		middle.setPosition([0,6,0])
		top.setPosition([0,7,0])

             #moves top piece with middle piece
	elif y < 6 and y <= 10:
		middle.setPosition([0,y,0])
		top.setPosition([0,y+1,0])

             #just moves top piece
	elif y > 10:
		middle.setPosition([0,10,0])
		top.setPosition([0,y,0])
		
vizact.ontimer2(0,viz.FOREVER,moveFlower)
Reply With Quote
  #2  
Old 04-10-2009, 02:42 PM
moooh moooh is offline
Member
 
Join Date: Dec 2008
Posts: 19
Sounds like all you need is to make a class to put the code in. Instantiate the class and you'll have a copy of the object that does not require code duplication.
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
Lightwave objects rotation problem hosier Vizard 6 02-13-2009 01:04 PM
Moving multiple objects with ppt durf Vizard 1 02-10-2009 04:03 PM
Problems with making multiple objects from one .wrl? mjabon Vizard 3 07-10-2007 02:23 PM
Could not find plugin to load objects... halley Vizard 1 05-30-2006 12:01 PM
putting objects on the screen jargon Vizard 7 05-24-2005 12:31 PM


All times are GMT -7. The time now is 06:29 PM.


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