#1
|
|||
|
|||
Moving multiple objects with ppt
Hello,
Just FYI I am new to python and Worldviz. So far in my program I have created 3 images. A ball, a pillar, and a stage. My goal is to move the ppt sensor up, which will move the ball straight up and at the same time I want the pillar to move in the opposite direction. So in refrence... as ball moves up on the y axis positively the pillar moves down on the y axis negatively. The stage represtents the x axis which is position on y axis 0 and this represents the starting positions of my ball and pillar. What I need to know is there any code that will make this happen? is this possible with python? and if so how can I set this code up to work? feel free to contact me at bdoerfer@uwm.edu Sorry for no indentations. This forum is not allowing me to. Thanks for any input. Below is the code that i have used: import viz import vizinfo viz.go() viz.move(0,0,-7) viz.clearcolor(viz.GRAY) PORT_PPT = 6 numLights = viz.input('How many lights are you tracking?') numLights = min(8,numLights) colors = [ [0, 1, 0.545], [1, 0, 1], [0, 1, 1], [1, 1, 0.545], [1, 0, 0], [0, 0.545, 1], [1, 0.545, 0], [0.545, 0, 1], ] sensors = [] balls = [] labels = [] for x in range(numLights): #Create Stage stage = viz.add('tut_ground.wrl') stagepos = stage.get(viz.POSITION) #Create sensor ppt = viz.add('vizppt.dls') sensors.append(ppt) #Create ball ball = viz.add('white_ball.wrl') ball.scale(1,1,1) ball.color(colors[x]) balls.append(ball) ball.link(ppt) ball.pptColor = colors[x] ball.curColor = colors[x] ballpos = ball.get(viz.POSITION) #Create Pillar pillar = viz.add('pillarWRL.wrl') pillar.link(ppt) pillarpos = pillar.get(viz.POSITION) def ontimer(num): for i in range(numLights): if sensors[i].get()[7]: ball.color(ball.curColor) else: ball.color(viz.BLACK) viz.callback(viz.TIMER_EVENT,ontimer) def onbutton(obj,state): if obj == showLight: for label in labels: label.visible(state) elif obj == allWhite: for ball in balls: if state: ball.curColor = viz.WHITE else: ball.curColor = ball.pptColor ball.color(ball.curColor) elif obj == showBad: viz.killtimer(0) if state: viz.starttimer(0,0,viz.FOREVER) viz.callback(viz.BUTTON_EVENT,onbutton) def mytimer(num): print ppt.get() viz.callback(viz.TIMER_EVENT, mytimer) viz.starttimer(0,0.5, viz.FOREVER) |
#2
|
|||
|
|||
So it sounds like the ball just needs to be linked directly to the ppt and for the pillar you just want to negate the y coordinate. You could use the link.swapPos method for that
Code:
#create two links ballLink = viz.link(ppt, ball) pillarLink = viz.link(ppt, pillar) #negate the y coordiante pillarLink.swapPos([1,-2,3]) |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Lightwave objects rotation problem | hosier | Vizard | 6 | 02-13-2009 01:04 PM |
tracking with multiple LEDS | dan12345 | Precision Position Tracker (PPT) | 7 | 04-02-2008 11:44 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 |