View Single Post
  #3  
Old 03-17-2009, 05:36 PM
durf durf is offline
Member
 
Join Date: Feb 2009
Posts: 61
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)
Reply With Quote