Re: Smoothly rotating to another angle on pano nodes
Status: Alpha
Brought to you by:
cwalther
|
From: Christian W. <cwa...@gm...> - 2009-12-19 22:37:40
|
James C. Wilson wrote:
> When I run this code, Pipmak will smoothly rotate to either 90, 90, or
> 90, -90(disregarding panorama limits), and slowly spins.
> I can tell there's something wrong with this code, but I don't know what
> it is exactly, or how to fix it. Can anyone suggest a possible solution?
I probably can, if you can explain what exactly you want to achieve, or
what you expect this code to do. I can see that it approximately does
what you describe, but I can't tell in how far that is not what you expect.
A few comments on details that seem strange to me:
> local tarAZ, tarEL = 45, 45
> local viewAZ, viewEL = pipmak.getviewdirection()
> local speedAZ, speedEL
>
> if viewAZ > tarAZ then
> speedAZ = viewAZ / tarAZ
> elseif viewAZ < tarAZ then
> speedAZ = tarAZ / viewAZ
Are you aware that you may be dividing by zero here?
> end
You don't handle the case viewAZ == tarAZ here and leave speedAZ = nil
in that case, is that what you want?
> if viewEL > tarEL then
> speedEL = viewEL / tarEL
> elseif viewEL < tarEL then
> speedEL = tarEL / viewEL
> end
> hotspotmap "hotspotmap.png"
> hotspot {
> onmousedown = function()
> pipmak.schedule(
> 0.02,
> function()
> viewAZ, viewEL = pipmak.getviewdirection()
> if viewAZ == tarAZ and viewEL == tarEL then
> viewAZ, viewEL = tarAZ, tarEL
What's the point of this assignment? It has no effect since in the "if"
statement you just checked that its outcome is already true before.
> pipmak.setviewdirection( viewAZ + 0.8, viewEL * speedEL + 0.8 )
> end
> return 0.02
If you always return a number, the timer will repeat indefinitely, is
that what you want?
> end
> )
> end
> }
-Christian
|