i guess this is a better question:
i want to draw a line between the coordinates an object was at two seconds ago and the coordinates the object is at now. so i ran a timer to repeat every 2 seconds. the problem is obvious, and i would imagine the solution is equally so. i just can't figure it out.
the first time the function runs, i am told the variable 'oldLoc' is not defined. but if i define it in the first line of the function, it will be initialized every time the function is run and it will always be '[0,0,0]'. how can i work around this? i figure i could run a counter that assigns an arbitrary coordinate to 'oldLoc' the first time the function is run. but no matter how i do it, that counter is reset (initialized) every time the function is invoked.
hope this makes sense. thanks!
Code:
def mytimer(num):
newLocs = []
for x in range(numLights):
newLoc = balls[x].get(viz.POSITION)
newLocs.append(newLoc)
viz.startlayer(viz.LINES)
viz.vertexcolor(1,0,1)
viz.linewidth(1)
#print 'newLocs[',x,']',newLocs[x]
viz.vertex(newLoc)
viz.vertex(0,0,0)
tail = viz.endlayer()
tails.append(tail)
tail.size(0,0,0,1,viz.TIME)
oldLocs = newLocs