From: James C. W. <jfc...@ya...> - 2010-06-01 15:34:37
|
Hi all, Sorry to bring this up again, but I've encountered another problem with my auto-panning function. Namely, the camera slows down exponentially as it rotates. This is because the local variables "autoPan_speedAZ" and "autoPan_speedEL" are updated every repitetion, so that the camera doesn't lose track of its target if the user moves the view themselves. Is there a way to make up for the decrease in speed? Thanks, James CW ************CODE*************** function autoPan(autoPan_tarAZ, autoPan_tarEL, autoPan_length) local autoPan_rate = 0.025 local autoPan_viewAZ, autoPan_viewEL = pipmak.getviewdirection() local autoPan_speedAZ, autoPan_speedEL = 0, 0 local autoPan_iterCount = nil pipmak.schedule( autoPan_rate, function() if autoPan_iterCount == nil then autoPan_iterCount = autoPan_length / autoPan_rate end autoPan_viewAZ, autoPan_viewEL = pipmak.getviewdirection() autoPan_speedAZ = (autoPan_tarAZ - autoPan_viewAZ) / autoPan_iterCount ) autoPan_speedEL = (autoPan_tarEL - autoPan_viewEL) / autoPan_iterCount ) if autoPan_viewAZ + 0.1 > autoPan_tarAZ and autoPan_viewAZ - 0.1 < autoPan_tarAZ and autoPan_viewEL + 0.1 > autoPan_tarEL and autoPan_viewEL - 0.1 < autoPan_tarEL then autoPan_iterCount = nil pipmak.setviewdirection(autoPan_tarAZ, autoPan_tarEL) return else pipmak.setviewdirection(autoPan_viewAZ + autoPan_speedAZ, autoPan_viewEL + autoPan_speedEL ) end return autoPan_rate end ) end |