Odd behaviour with view.hlookat /adjusthlookat and HELP, please

  • I'm starting a pano with a view.hlookat of 0.
    krpano returns returns positive or negative values for view.hlookat depending in which direction I start to turn my view.

    BUT if I use adjusthlookat (for the reasons it was created for) the player returns only positive values, which will cause an unwanted behaviour if one uses these values to determine the absolute "distance" from view.hlookat="0"

    To be more consistent adjusthlookat should deliver values from 0 to 180 and (-179) to (-1) instead of values from 0-360.

    Here you can see what happens:
    Just using view.hlookat


    Which would be fine if one wouldn't turn more then 360 degrees. But of course we want the image to be in the same place no matter how often we turn around.

    So this is why I would use adjusthlookat

    Code
    <events onviewchanged="
    			
    			adjusthlookat(view.hlookat);
    			sub(variable,0,get(view.hlookat));
    			set(hotspot[spot1].ox,get(variable));"  />


    Which is ok as long as you turn counterclockwise, but as soon as you move to the opposite ...

    ... well, here is where the HELP part starts *w00t*

    How can I create a workaround or how could the rather simple code above be modified to get the wanted result?
    Just from a logical aspect I see more then one solutions, but to put these into a working code is way above my possibilities.
    So if you don't mind, please give me some hints.

    Thank you
    Jürgen

  • Hi,

    this call here is wrong for two reasons:

    Code
    adjusthlookat(view.hlookat);
    1. reason:

      • the adjustlookat() action needs a 'value' as parameter
      • when putting a variable there, the behavior is undefined
    2. reason:

      • even with the correct syntax, which would be - adjusthlookat(get(view.hlookat)) - this call still wouldn't make sense - adjusting the current hlookat value for the shortest distance to itself will no change anything...


    if you want hlookat values from -180 to +180, just call it this way:

    Code
    adjusthlookat(0);

    best regards,
    Klaus

  • AHHH! Thank you, Klaus.
    Perfect as always.
    And so simple *thumbsup*
    Of course I looked at the documentation to figure out what adjustlookat() does, but I found the descrption to be a bit "basic" *rolleyes*
    But maybe that's just me, and anyone with more skills in scrpting and coding will instantly know what that means.

    So up to the next features I want to add ... *whistling*

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!