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 :
<!--
krpano 1.0.8.11
object movie rotate/zoom/move example skin
-->
<krpano version="1.0.8" onstart="objectvr_init()" >
<!-- objectvr options
xframes [natural integer] the number of frames in each row (number of frames for a complete ath excursion)
yframes [natural integer] the number of frames in each column (number of frames for a complete atv excursion)
startframe [natural integer] the frame number for the initial view of the object
hlimit [boolean] limit the horizontal rotation (set to true for partial object vr's with limited atv rotation)
autorotate [boolean] enable autorotation, action objectvr_autorotate(); must be run after enabling
autorotatedelay [float] time between frame updates for autorotation
-->
<objectvr />
<autorotate speed="200.0" waittime="2" />
<view fovtype="DFOV"
limitview="fullrange"
maxpixelzoom="1.0"
/>
<control zoomtocursor="true"
zoomoutcursor="true"
mousetype="moveto"
mousespeed="0"
/>
<display flash10="on"
movequality="HIGH" stillquality="HIGHSHARP"
movequality10="HIGH" stillquality10="HIGH"
/>
<events onenterfullscreen="set(plugin[openfs].visible,false); set(plugin[closefs].visible,true);"
onexitfullscreen ="set(plugin[openfs].visible,true); set(plugin[closefs].visible,false);"
onmousedown="objectvr_halt_autorotate();mdown();"
onmouseup="mup();"
onidle="objectvr_autorotate();"
onkeydown="onkeydown();"
onkeyup="onkeyup();"
onresize="objectvr_update_panning();"
onviewchange="if (objectvr.fullviewfov === null,
if (view.fov != 90,
copy(objectvr.fullviewfov,view.fov);
roundval(objectvr.fullviewfov,1);
set(events.onviewchange,null);
);
);"
/>
<action name="objectvr_init">
if (objectvr.startframe !== null,
copy(image.frame,objectvr.startframe);
<!--else-->,
div(image.frame,image.frames,2);
);
if (objectvr.yframes === null,
if (objectvr.xframes === null,
objectvr_guess_aspect_ratio();
if (objectvr.xframes GT 72,
if (objectvr.yframes == 1,
error("pow function not available in this version of krpano, use 1.0.8.11 or newer OR set object.xframes");
);
);
<!--else-->,
div(objectvr.yframes,image.frames,objectvr.xframes);
roundval(objectvr.yframes);
);
<!--else-->,
if (objectvr.xframes === null,
div(objectvr.xframes,image.frames,objectvr.yframes);
roundval(objectvr.xframes);
);
);
if (objectvr.xframes === null,
div(objectvr.xframes,image.frames,objectvr.yframes);
roundval(objectvr.xframes);
);
if (objectvr.yframes == 1,
set(plugin[rotateupbg].visible,false);
set(plugin[rotatedownbg].visible,false);
);
if (objectvr.xframes == 1,
set(plugin[rotateleftbg].visible,false);
set(plugin[rotaterightbg].visible,false);
);
if (objectvr.hlimit != true,
set(objectvr.xframemax,1);
copy(objectvr.xframemin,objectvr.xframes);
<!--else-->,
copy(objectvr.xframemax,objectvr.xframes);
set(objectvr.xframemin,1);
);
sub(objectvr.yframemax,objectvr.yframes,1);
sub(objectvr.xframe,image.frame,1);
mod(objectvr.xframe,objectvr.xframes);
inc(objectvr.xframe);
div(objectvr.yframe,image.frame,objectvr.xframes);
sub(objectvr.yframe,0.5);
roundval(objectvr.yframe);
div(objectvr.deltah,360,objectvr.xframes);
copy(idletime,autorotate.waittime);
copy(objectvr.autorotate,autorotate.enabled);
set(autorotate.enabled,false);
mul(objectvr.xmin,objectvr.yframe,objectvr.xframes);
inc(objectvr.xmin);
add(objectvr.xmax,objectvr.xmin,objectvr.xframes);
dec(objectvr.xmax);
objectvr_update_panning();
</action>
<action name="objectvr_guess_aspect_ratio">
mul(objectvr.xframes,image.frames,2);
inc(objectvr.xframes);
pow(objectvr.xframes,0.5);
dec(objectvr.xframes);
roundval(objectvr.xframes);
div(objectvr.yframes,image.frames,objectvr.xframes);
roundval(objectvr.yframes);
mul(action[%0].tmp,objectvr.xframes,objectvr.yframes);
if (action[%0].tmp != image.frames,
set(objectvr.xframes,36);
div(objectvr.yframes,image.frames,objectvr.xframes);
roundval(objectvr.yframes);
set(action[%0].tryagain,false);
if (objectvr.yframes GT 18,
set(action[%0].tryagain,true);
);
mul(action[%0].tmp,objectvr.xframes,objectvr.yframes);
if (action[%0].tmp != image.frames,
set(action[%0].tryagain,true);
);
if (action[%0].tryagain,
set(objectvr.xframes,48);
div(objectvr.yframes,image.frames,objectvr.xframes);
roundval(objectvr.yframes);
set(action[%0].tryagain,false);
if (objectvr.yframes GT 24,
set(action[%0].tryagain,true);
);
mul(action[%0].tmp,objectvr.xframes,objectvr.yframes);
if (action[%0].tmp != image.frames,
set(action[%0].tryagain,true);
);
if (action[%0].tryagain,
set(objectvr.yframes,1);
copy(objectvr.xframes,image.frames);
);
);
);
</action>
<!-- objectvr mouse rotate action -->
<action name="mdown">
if(control.mousespeed == 0,
set(mbdown, true);
set(xlastframepos,null);
set(ylastframepos,null);
objectrotate();
);
</action>
<action name="mup">
set(mbdown, false);
</action>
<action name="objectrotate">
div(mxpos, mouse.x, stagewidth);
mul(xframepos, mxpos, objectvr.xframes);
roundval(xframepos);
div(mypos, mouse.y, stageheight);
mul(yframepos, mypos, objectvr.yframes);
roundval(yframepos);
if(xlastframepos == null, copy(xlastframepos,xframepos));
if(ylastframepos == null, copy(ylastframepos,yframepos));
sub(xframemove, xlastframepos, xframepos);
copy(xlastframepos,xframepos);
sub(yframemove, ylastframepos, yframepos);
copy(ylastframepos,yframepos);
set(xrotatedirection, right);
if(xframemove LT 0, mul(xframemove,xframemove,-1); set(xrotatedirection, left); );
set(yrotatedirection, up);
if(yframemove LT 0, mul(yframemove,yframemove,-1); set(yrotatedirection, down); );
if(mbdown,
if(yframemove != 0,
if(yrotatedirection == down,
dec(objectvr.yframe,get(yframemove),0,0);
,
inc(objectvr.yframe,get(yframemove),get(objectvr.yframemax),get(objectvr.yframemax));
);
mul(objectvr.xmin,objectvr.yframe,objectvr.xframes);
inc(objectvr.xmin);
add(objectvr.xmax,objectvr.xmin,objectvr.xframes);
dec(objectvr.xmax);
);
sub(objectvr.xframe,image.frame,1);
mod(objectvr.xframe,objectvr.xframes);
inc(objectvr.xframe);
if(xframemove != 0,
if(xrotatedirection == left,
dec(objectvr.xframe,get(xframemove),1,get(objectvr.xframemin));
,
inc(objectvr.xframe,get(xframemove),get(objectvr.xframes),get(objectvr.xframemax));
);
);
mul(action[%0].tmp,objectvr.yframe,objectvr.xframes);
add(image.frame,action[%0].tmp,objectvr.xframe);
delayedcall(0.01,objectrotate());
);
</action>
<action name="startrotateleft">
set(rotating,true);
rotateleft();
</action>
<action name="startrotateright">
set(rotating,true);
rotateright();
</action>
<action name="startrotateup">
set(rotating,true);
rotateup();
</action>
<action name="startrotatedown">
set(rotating,true);
rotatedown();
</action>
<action name="rotateleft">
if (objectvr.hlimit != true,
dec(image.frame,1,get(objectvr.xmin),get(objectvr.xmax));
<!--else-->,
dec(image.frame,1,get(objectvr.xmin),get(objectvr.xmin));
);
delayedcall(0.02, if(rotating,rotateleft()) );
</action>
<action name="rotateright">
if (objectvr.hlimit != true,
inc(image.frame,1,get(objectvr.xmax),get(objectvr.xmin));
<!--else-->,
inc(image.frame,1,get(objectvr.xmax),get(objectvr.xmax));
);
delayedcall(0.02, if(rotating,rotateright()) );
</action>
<action name="rotatedown">
if (objectvr.yframe LT objectvr.yframemax,
inc(objectvr.yframe,1,get(objectvr.yframes));
inc(objectvr.xmin,get(objectvr.xframes));
inc(objectvr.xmax,get(objectvr.xframes));
inc(image.frame,get(objectvr.xframes));
);
delayedcall(0.02, if(rotating,rotatedown()) );
</action>
<action name="rotateup">
if (objectvr.yframe GT 0,
dec(objectvr.yframe,1,0);
dec(objectvr.xmin,get(objectvr.xframes));
dec(objectvr.xmax,get(objectvr.xframes));
dec(image.frame,get(objectvr.xframes));
);
delayedcall(0.02, if(rotating,rotateup()) );
</action>
<action name="stoprotate">
set(rotating,false);
</action>
Display More
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!