Object VR with left/right AND up/down rotation

  • There have been a couple of requests for multi-row object movies, so I've taken the liberty of modifying Klaus' objectskin.xml code to support rotations about both the Y and X axes. Klaus' original file can be found in the templates/xml/skin directory of the krpanotools 1.0.8.11 release. The new code allows one to turn the object not only left and right, but also up and down. It also supports user controllable autorotation (the autorotate.enabled, autorotate.waittime and autorotate.speed attributes are supported ). I've changed the code so that the user is not forced into panning mode when zoomed in, instead one can pan by pressing the space bar while moving the cursor. Please note that version 1.0.8.11 of the viewer is required as I make one use of the new square root function.

    Note: This file is split across two posts due to the character length limitation of the forum. This is part 1 of 2 :

    Note: This file is split across two posts due to the character length limitation of the forum. This was part 1 of 2, see here for part 2
    edit 6/19/10--various autorotate bug fixes and improvements per feedback from massimo and bags. Thanks guys!

    Edited once, last by pinsane (June 19, 2010 at 11:40 AM).

  • Note: This file is split across two posts due to the character length limitation of the forum. This is part 2 of 2, see here for part 1

    Note: This file is split across two posts due to the character length limitation of the forum. This was part 2 of 2, see here for part 1
    edit 6/19/10--various autorotate bug fixes and improvements per feedback from massimo and bags. Thanks guys!

    Edited once, last by pinsane (June 19, 2010 at 11:44 AM).

  • The object VR is composed of a series of photographs that are ordered in a specific manner that allows the action to properly access a specific picture. These photos are ordered by name, a simple way to do this is to name them pic0001.tif, pic0002.tif, pic0003.tif, etc. The kmakemultires program uses the names of the file supplied to put the frames in order.

    When naming your files, you should use leading zero padding in your name, that is, all numbers should be represented by the same number of digits, using leading zeros to fill out the number. For example, if you have 196 pictures, your numbers should always be represented with 3 digits (because 196 uses three digits). Thus name your files image001.tif, image002.tif, ... ,image009.tif,image010.tif,image011.tif, ... ,image099.tif,image100.tif,image101.tif, ... ,image191.tif,image192.tif. Because kmakemultires sorts the file names using alphabetic sorting, files named using leading zeros will be sorted correctly and produce the proper ordering for your frames. If you instead choose to name things image1.tif, image2.tif, ... ,image191.tif,image192.tif, the current versions of kmakemultires (1.0.8.10 or 1.0.8.11) will incorrectly sort your frames image1.tif,image10.tif,image11.tif,image12.tif, etc.

    For a 2 axes object vr, we can consider the pictures to be organized in a grid. Each row of the grid contains a complete counterclockwise revolution around the object at a given altitude. Each column of the grid contains a vertical transition from a high altitude (limited by -90 degrees--the top of the object) to a low altitude (limited by 90 degrees--the bottom of the object). To use an analogy with a standard panorama each row contains all pictures with a given ath while each column contains all pictures with a particular atv. Each picture is names starting from the upper left corner, moving across each row and then returning to the leftmost column of the next row when a given row is completed.

    Let's call the angle change between each picture in a row deltah; this is the incremental angle change about the y axis. We'll refer to the angle changes in each column as deltav; this is the incremental angle change about the x axis. The smaller the angle change between pictures, the smoother the objectvr will turn but the larger the number of pictures that need to be captured. 360 must be evenly divisible by the horizontal angle between pictures (ie. 360/deltah must be an integer) to avoid jerkiness when rotating around the object. Similarly 180 must be evenly divisible by the vertical angle between pictures (ie 180/deltav must be an integer). Many people use 10 degrees as the delta angle, but I prefer the smoother 7.5 degrees.

    If you wish to provide full coverage of an object (a view from every perspective), and want the deltav to equal the deltah (which provides uniform rotations in each direction) then the number of photographs required is:
    number of pictures per row = 360/deltah
    number of pictures per column = 180/deltav+1
    The +1 for the column is required because you don't wrap all the way around the sphere, so to get coverage of both the top and bottom of the object, you need to add 1 row.

    Here's the layout and numbering of the pictures for a 7.5 degree example:

    Code
    atv\ath    -172.5	   -165.0	  -157.5	...	      0		...	   165.0	   172.6	   180
    -90.0	pic0001.tif	pic0002.tif	pic0003.tif	...	pic0024.tif	...	pic0046.tif	pic0047.tif	pic0048.tif
    -82.5	pic0049.tif	pic0050.tif	pic0051.tif	...	pic0072.tif	...	pic0094.tif	pic0095.tif	pic0096.tif
    -75.0	pic0097.tif	pic0098.tif	pic0099.tif	...	pic0120.tif	...	pic0142.tif	pic0143.tif	pic0144.tif
     ...        ...		     ...	     ...	...	     ...	...	     ...	     ...	     ...
       0	pic0577.tif	pic0578.tif	pic0579.tif		pic0600.tif	...	pic0622.tif	pic0623.tif	pic0624.tif
     ...        ...		     ...	     ...	...	     ...	...	     ...	     ...	     ...
     75.0	pic1057.tif	pic1058.tif	pic1059.tif	...	pic1080tif	...	pic1102.tif	pic1103.tif	pic1104.tif
     82.5	pic1105.tif	pic1106.tif	pic1107.tif	...	pic1128.tif	...	pic1150.tif	pic1151.tif	pic1152.tif
     90.0	pic1153.tif	pic1154.tif	pic1155.tif	...	pic1176.tif	...	pic1998.tif	pic1999.tif	pic1200.tif

    Given that each photograph is taken 7.5 degrees apart, the size of the grid is 48 photographs wide (48 * 7.5 = 360 degrees) and 25 photos up and down. 25 photos are needed to cover from zenith to nadir (24 * 7.5 = 180 degrees plus one extra so that both the zenith and nadir are covered).

    Each row of photographs starts from behind the object of interest (atv = -172 degrees), travels around the object in a counterclockwise manner and finishes exactly behind the object at (atv = 180 degrees). If you sequence through the photographs in any row it will appear that the object is turning clockwise 360 degrees from a constant altitude.

    Each column shows the same atv value for the object, but goes from top (ath=-90) to bottom (ath=90) in 7.5 degree increments.

    Once every picture is properly named, you can use kmakemultires with the object.config file found in the templates directory. I've found that in windows, you can't use the droplet with a large number of files, so using the command line version is necessary.

    Good luck!

    steve

  • ...

    I think we upgrade Pinsane to professional.. Klaus?

    Great!

    Thanx Steve for your great TuT again *thumbup*
    You get a full weekend free drinks in the 'bar'.

    Cheers

    Tuur *thumbsup*

  • hi there --

    awesome (and working) code example... many thanks!

    i don't see, easily, how to have a full 360 rotation in vertical orientation. i have an object which will need to rotate fully vertically, and limited horizontally. Ideas? A pointer to what to modify in the code would be fine -- it appears to me to limit the y rotation by default, to the number of rows minus 1. *question*

    thanks in advance!

Participate now!

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