Sie sind nicht angemeldet.

1

Samstag, 21. Juli 2012, 00:59

Blending Cubes / XML Slider Example "Tuning"

Hello Forum,

I`d like to have a Panorama with 3 Pictures and the cube blending must be automatic without the slider.
The part with implementing 3 Pictures I just did with help of Klaus.
Here is the Code:

Zitat

<events name="babbelbox" onxmlcomplete="setupprogress();" />

<view hlookat="125.246219"
vlookat="7.626991"
fisheye="0.22"
fov="100"
fovmin="50"
fovmax="100"
/>

<plugin name="slider_bg" url="slider_background.png" align="bottom" x="0" y="62" handcursor="false" zorder="1" />

<plugin name="slider_grip" url="slider_grip.png" align="left" edge="center" parent="slider_bg" x="0" zorder="2"
dragging="if(pressed,
sub(dx, mouse.stagex, drag_stagex);
add(newx, drag_currentx, dx);
if(newx LT 0, set(newx,0));
if(newx GT plugin[slider_bg].pixelwidth, copy(newx,plugin[slider_bg].pixelwidth));
copy(x,newx);
div(val, newx, plugin[slider_bg].pixelwidth);
setblend(get(val));
delayedcall(0,dragging());
);"
ondown="copy(drag_currentx,x); copy(drag_stagex,mouse.stagex); dragging();"
/>


<action name="addface">
addhotspot(%1);
if(isdesktop,
set(hotspot[%1].url, %CURRENTXML%/desktop/%2);
,
set(hotspot[%1].url, %CURRENTXML%/mobile/%2);
);
set(hotspot[%1].ath, %3);
set(hotspot[%1].atv, %4);
set(hotspot[%1].width, 1000);
set(hotspot[%1].height, 1000);
set(hotspot[%1].distorted, true);
set(hotspot[%1].enabled, false);
if(isflash, set(hotspot[%1].visible, false));
set(hotspot[%1].alpha, 0.0);
set(hotspot[%1].details, 16);
set(hotspot[%1].onloaded, incprogress(); );
inc(files_to_load);
</action>




<action name="addcube">
addface(face_%1_F, '%1_f.jpg', 0, 0);
addface(face_%1_L, '%1_l.jpg', -90, 0);
addface(face_%1_R, '%1_r.jpg', +90, 0);
addface(face_%1_B, '%1_b.jpg', +180, 0);
addface(face_%1_Z, '%1_u.jpg', 0, -90);
addface(face_%1_N, '%1_d.jpg', 0, +90);
</action>


<action name="setalpha" devices="flash">
set(%1.alpha, %2);
if(%1.alpha == 0.0, set(%1.visible,false), set(%1.visible,true));
</action>

<action name="setalpha" devices="html5">
<!-- safari has some framerate stops/problems when toggling the visibility - so keep here the spots always visible -->
set(%1.alpha, %2);
</action>


<action name="setcubealpha">
setalpha(hotspot[face_%1_F], %2);
setalpha(hotspot[face_%1_L], %2);
setalpha(hotspot[face_%1_R], %2);
setalpha(hotspot[face_%1_B], %2);
setalpha(hotspot[face_%1_Z], %2);
setalpha(hotspot[face_%1_N], %2);
</action>


<action name="start">

addcube(pano1);
addcube(pano2);
addcube(pano3);

setblend(0);
</action>


<action name="setblend" devices="flash">
<!-- %1 = 0 ... 1
0.0 .. 0.5 => b1=0..1, b2=1..0, b3=0
0.5 .. 1.0 => b1=0, b2=1..0, b3=0..1
-->
if(%1 LT 0.5,
mul(blend2, %1, 2);
sub(blend1, 1, blend2);
set(blend3, 0);
,
set(blend1, 0);
sub(blend3, %1, 0.5);
mul(blend3, 2);
sub(blend2, 1, blend1);
);
setcubealpha(pano1, get(blend1));
setcubealpha(pano2, get(blend2));
setcubealpha(pano3, get(blend3));
</action>

<action name="setblend" devices="html5">
if(%1 LT 0.5,
mul(blend2, %1, 2);
sub(blend1, 1, blend2);
set(blend3, 0);
,
set(blend1, 0);
sub(blend3, %1, 0.5);
mul(blend3, 2);
sub(blend2, 1, blend1);
);
copy(hotspot[face_pano1_F].alpha, blend1);
copy(hotspot[face_pano1_L].alpha, blend1);
copy(hotspot[face_pano1_R].alpha, blend1);
copy(hotspot[face_pano1_B].alpha, blend1);
copy(hotspot[face_pano1_Z].alpha, blend1);
copy(hotspot[face_pano1_N].alpha, blend1);
copy(hotspot[face_pano2_F].alpha, blend2);
copy(hotspot[face_pano2_L].alpha, blend2);
copy(hotspot[face_pano2_R].alpha, blend2);
copy(hotspot[face_pano2_B].alpha, blend2);
copy(hotspot[face_pano2_Z].alpha, blend2);
copy(hotspot[face_pano2_N].alpha, blend2);
copy(hotspot[face_pano3_F].alpha, blend3);
copy(hotspot[face_pano3_L].alpha, blend3);
copy(hotspot[face_pano3_R].alpha, blend3);
copy(hotspot[face_pano3_B].alpha, blend3);
copy(hotspot[face_pano3_Z].alpha, blend3);
copy(hotspot[face_pano3_N].alpha, blend3);
</action>



<action name="setupprogress">
set(files_to_load,0);
set(files_loaded,0);
showtext(start loading..., loadinginfo);

start();
</action>

<action name="incprogress">
inc(files_loaded);

txtadd(msg, '...loading ', get(files_loaded), '/', get(files_to_load), '...');

if(files_loaded == files_to_load, set(msg,'...loading done...'); set(textstyle[loadinginfo].showtime, 0.5));

showtext(get(msg), loadinginfo);
</action>


<textstyle name="loadinginfo" origin="center" edge="center" yoffset="10" textalign="center" background="false" border="false" fontsize="20" textcolor="0xFFFFFF" bold="false" effect="glow(0xFFFFFF,0.7,4,2);glow(0x000000,1,4,2);dropshadow(3,45,0x000000,2,0.6);" showtime="999.0" fadetime="1.0"/>

But how can I implement the automatic cube blending? It must be iPhone compatible...

2

Samstag, 28. Juli 2012, 01:48

for example so:

Quellcode

1
2
3
4
5
6
7
8
9
10
<krpano version="1.0.8.14" onstart="set(newx,0);delayedcall(1,blend(););">
....
<action name="blend">
if(newx LT 1,
  wait(0.05);
  inc(newx, 0.02);
  setblend(get(newx));
  blend();
);
</action>


Greetz

Mil

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »milemann« (28. Juli 2012, 02:04)


3

Samstag, 28. Juli 2012, 11:44

Thank you very much milemann. :)

This is very good, the only thing is it does'nt work simultaneous with the autorotation.
And it should be a infinity loop so that when the action has finished it has to start again.

Is this possible?
thx

4

Samstag, 28. Juli 2012, 14:43

hi!

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<action name="blend">
if(newx LT 1,
  wait(0.05);
  inc(newx, 0.02);
  setblend(get(newx));
  blend();
  ,
  blend_back();
);
</action>

<action name="blend_back">
 if(newx GT 0,
   wait(0.05);
   dec(newx, 0.02);
   setblend(get(newx));
   blend_back();
  ,
   blend();
 );
</action>


the blending speed you could change adjusting wait time/inc-dec value.

greetz

mil

5

Samstag, 28. Juli 2012, 17:22

Ok thanks, there is only one problem...
I can not control the panorama and the rest of my plugins with the mouse anymore. *cry*

When I only use the blend action without blend_back I can use the mouse after the action is finished...

6

Samstag, 28. Juli 2012, 18:07

so, than change "wait" with "delayedcall":

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<action name="blend">
if(newx LT 1,
  delayedcall(0.05, 
  inc(newx, 0.02);
  setblend(get(newx));
  blend();
  );
  ,
  blend_back();
);
</action>

<action name="blend_back">
  if(newx GT 0,
    delayedcall(0.05,
	dec(newx, 0.02);
	setblend(get(newx));
	blend_back();
      );
    ,
     blend();
  );
</action>


greetz

mil

7

Sonntag, 29. Juli 2012, 11:33

Thank you very much, it works perfect!