View Single Post
  #3  
Old 06-12-2012, 08:09 AM
snovob93 snovob93 is offline
Member
 
Join Date: Jun 2012
Posts: 6
So right now I have to create a whole new sensor to get it to work, which is what I've done here. That is fine, but I don't know how to control it so that the first one will fade out as the new one comes in. With what I did below the first sphere automatically fades out, and the second sphere is always there. I only want one sphere to show up at a time.

However, If there is a way to keep one sensor and get it to move again and again when the marker and sensor touch each other that would be easier.



#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)


#proximity sensor-sphere
sphereSensor = vizproximity.Sensor(vizproximity.Box([0.5,0.5,0.5],center=[0,0.1,0]),source=sphere)

#Add main viewpoint as proximity target
target = vizproximity.Target(marker2)

#Add viewpoint target to manager
manager.addTarget(target)

#sphere movement 1
def ExitProximity(e):
PointB = vizact.moveTo([0,1.5,1],speed=2)
sphere.addAction(PointB)


manager.onExit(sphereSensor,ExitProximity)

#Fade Target 1 out
fadeout = vizact.fadeTo(0,speed=1)
vizact.onbuttondown('f',fadeout)
sphere.addAction(fadeout)

#Load Target 2
sphere2 = viz.add('ball.wrl')
shape = sphere.collideBox()
sphere2.setPosition([0,1.5,1])
viztask.waitActionEnd(sphere2,fadeout)

#proximity sensor-sphere2
sphere2Sensor = vizproximity.Sensor(vizproximity.Box([0.5,0.5,0.5],center=[0,0.1,0]),source=sphere2)

#Add sensors to manager (sphere)
manager.addSensor(sphereSensor)
manager.addSensor(sphere2Sensor)

#Sphere movement 2
def ExitProximity2(e):
PointC = vizact.moveTo([0,1.5,-2])
sphere2.addAction(PointC)

manager.onExit(sphere2Sensor,ExitProximity2)
Reply With Quote