#1
|
|||
|
|||
reseting an object
Hello,
I am trying to reset an object. Right now when my sensor passes over and object and then sets the position to to -10 on the y axis. What I want to do is when my sensor leaves that object how do I reset that particular object to 0 on the y - axis. I have my objects arranged in an array which lays the objects out on the x and z -axis flat on the y -axis. The array is 4 x 5. Thanks for any help |
#2
|
|||
|
|||
Are you using viz.intersect to see whether or not the sensor is over the block?
You can continue to us viz.intersect to see whether or not the line drawn from below the sensor is still intersecting the block. If it is you don't need to do anything since the block has already been moved down. If it's not intersecting that object anymore the sensor has moved beyond it and you can reset the object's position. if you're still using the vizintersect code from the other thread you started than you could change it to something like this. Code:
currentBlock = None def moveBlock(): global currentBlock x,y,z = ball.getPosition() info = viz.intersect([x,y-1,z],[x,y-20,z]) if info.valid and currentBlock == None: currentBlock = info.object currentBlock.setPosition([0,-10,0], viz.REL_LOCAL) elif not info.valid and currentBlock is not None: currentBlock.setPosition([0,10,0], viz.REL_LOCAL) currentBlock = None vizact.ontimer(0,moveBlock) |
#3
|
|||
|
|||
Still not working... Below is the code I have created for it. Im thinking it has something to do with the array. Just getting confused with it.
Code:
import viz viz.go() OriginalPillar = viz.add('pillarWRL.wrl') OriginalPillar.visible(viz.OFF) viz.MainView.setPosition([0,10,-35]) #sets camera position viz.MainView.setEuler([0,2,0]) #sets camera pitch PORT_PPT = 6 numLights = viz.input('How many lights are you tracking?') numLights = min(8,numLights) for x in range(numLights): #creates sensor and call #Add ground ground = viz.add( 'tut_ground.wrl' ) ground.setPosition([0,-5,0]) #Create sensor ppt = viz.add('vizppt.dls') #Create ball ball = viz.add('white_ball.wrl') ball.scale(1,1,1) ballLink = viz.link(ppt, ball) #controls distance in virtual world ballLink.postScale([8,1,13],target = viz.LINK_FULL_OP) columns = [-20, -10, 0, 10, 20] rows = [0, 6, 12, 18] pillars = [] for x in columns: #creates an array of pillars for y in rows: pillar = OriginalPillar.copy() pillar.translate(0+x, 0, 0+y) pillar.setScale(1,1,1) pillar.visible(viz.OFF) pillars.append(pillar) number = 0 def showPillar(): #displays pillars global number pillars[number].visible(viz.ON) number +=1 vizact.ontimer2(.5,len(pillars)-1,showPillar) currentBlock = None def moveblock(): global currentBlock x,y,z = ball.getPosition() info = viz.intersect([x,y-1,z],[x,y-20,z]) if info.valid and currentBlock == None: currentBlock = info.object currentBlock.setPosition([0,-10,0], viz.REL_LOCAL) elif not info.valid and currentBlock is not None: currentBlock.setPosition([0,10,0], viz.REL_LOCAL) currentBlock = None vizact.ontimer(0, moveblock) |
#4
|
|||
|
|||
I think an intersection occurs with the ground and that interferes with code to move the pillars. Try disabling intersection on the ground
Code:
ground.disable(viz.INTERSECTION) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
retrieve Object names | Geoffrey | Vizard | 11 | 12-11-2009 05:26 AM |
Can you link the position of a tracker to the orientation of an object? | michaelrepucci | Vizard | 1 | 09-19-2008 11:23 AM |
Child Object Rotation | paulgoldberg | Vizard | 5 | 09-05-2006 12:33 PM |
when collision mode is on, can i "turn it off" for an individual object? | Vdoug | Vizard | 1 | 09-22-2005 01:14 PM |
rotate to object | jargon | Vizard | 1 | 08-08-2005 01:20 PM |