You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

viewinz

Intermediate

  • "viewinz" started this thread

Posts: 145

Location: Wellington, New Zealand

Occupation: Trying to build an entire walkthrough of NZ for tourists

  • Send private message

1

Sunday, February 14th 2010, 9:49am

next/previous buttons

Hello,

I've been trying to create next and previous buttons that will load the previous or next scenes in a scenes document.

The code that is almost working is :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<action name="prenex">
trace(scene.count);
set(totalviews,get(scene.count));
set(i,0);
prenex2(get(i),%1,get(cview));
</action>

<action name="prenex2">
if(scene[%1].name==%3,
	set(v,%1);
	prenex3(%1,%2,get(totalviews))
,
	inc(i);
	prenex2(get(i),%2,%3);
);	
</action>

<action name="prenex3">
trace(%1___%2___%3);
if(%2==prev,
	if(%1==0,
		dec(totalviews);
		prenex_load(get(totalviews))
	,
		dec(v); 
		prenex_load(get(v))
	);
);
if(%2==next,
	if(%1==%3,
		prenex_load(0)
	,
		inc(v); 
		prenex_load(get(v))
	);
);

</action>

<action name="prenex_load">
trace(%1);
loadscene(get(scene[%1].name),null,MERGE,blend(0.3)),
</action>


The problem I think is that each time the current scene number (cview) is being reset to zero, so I can do next and previous scenes but not the ones after. Any ideas on how I can dynamically define scene numbers so I can set a list?

Cheers

2

Monday, February 15th 2010, 10:24pm

Hi,

here would be a fully automated solution (without any additional variables):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<action name="prevscene">
    if(%1 != findnext, sub(i,scene.count,1));
    txtadd(scenexml,'<krpano>',get(scene[%i].content),'</krpano>');
    if(scenexml == xml.content,
       dec(i);
       if(i LT 0, sub(i,scene.count,1));
       loadscene(get(scene[%i].name), null, MERGE, BLEND(1));
      ,
       dec(i);
       if(i GE 0, prevscene(findnext));
      );
</action>

<action name="nextscene">
    if(%1 != findnext, set(i,0));
    txtadd(scenexml,'<krpano>',get(scene[%i].content),'</krpano>');
    if(scenexml == xml.content,
       inc(i);
       if(i == scene.count, set(i,0));
       loadscene(get(scene[%i].name), null, MERGE, BLEND(1));
      ,
       inc(i);
       if(i LT scene.count, nextscene(findnext));
      );
</action>


just call either the 'prevscene' or 'nextscene' action,

best regards,
Klaus

viewinz

Intermediate

  • "viewinz" started this thread

Posts: 145

Location: Wellington, New Zealand

Occupation: Trying to build an entire walkthrough of NZ for tourists

  • Send private message

3

Monday, February 15th 2010, 11:57pm

Cheers Klaus, that is so much more elegant than the way I was doing it! And works perfectly thank you so much *thumbup* .

Tuur

Sage

Posts: 3,172

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

4

Tuesday, February 16th 2010, 12:05am

Interesting!

will this way also work with 'no scene' pano's? or is there an other code for that..

so like if 19.xml... next is 20.xml *confused*
*wacko*

Thanx
Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

VN2009

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

5

Tuesday, February 16th 2010, 1:20am

Klaus how in the did you get so smart? Does code just come naturally? my next and previos buttons work but not like that. i had to create 12 different actions then set the onclicks to set what the next onclick would load.

6

Wednesday, February 17th 2010, 1:43pm

Hi,
will this way also work with 'no scene' pano's? or is there an other code for that..
no, not that code, the informations about the scenes are all loaded and there and it's possible to check for them,
krpano can't know if there are other xml files out there,
but it would be possible to predefine a variable for the current xml and one for the number of the xml files and
then increase or decrease this variable and load the right xml file...


Klaus how in the did you get so smart? Does code just come naturally? my next and previos buttons work but not like that. i had to create 12 different actions then set the onclicks to set what the next onclick would load.
I have used a small trick for that:
internally when loading a scene, it's content is stored in the "xml.content" variable (inside a <krpano> tag),
then I loop through all scenes (known via "scene.count") and check if it is the current scene, and if yes,
the previous or next scene will be loaded,

another trick is - when the action is called without a parameter (%1), the counter variable (i) will be set to
the start value, and in the other case when it was called with parameter (findnext), the varialbe 'i' will be
not changed,
this allows small loopings,

best regards,
Klaus

7

Thursday, February 18th 2010, 12:57pm

Hi, Klaus

Possible to disable the Preview Button when you are in scene1, and the Next Button when you are in the last scene , eg scene6 ?

I try with the if but not working, I think I don't have the good syntax

8

Monday, February 22nd 2010, 3:31pm

Hi,
Possible to disable the Preview Button when you are in scene1, and the Next Button when you are in the last scene , eg scene6 ?
that's a bit more complex,
but here is an example code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<action name="enable_button">
    set(plugin[%1].enabled,%2);
    if(%2 == false, tween(plugin[%1].alpha, 0.2), tween(plugin[%1].alpha, 1.0));
</action>

<action name="update_prev_next_buttons">
    sub(maxsceneindex, scene.count, 1);
    if(%1 LE 0,             enable_button('prev scene', false), enable_button('prev scene', true));
    if(%1 GE maxsceneindex, enable_button('next scene', false), enable_button('next scene', true));
</action>

<action name="prevscene">
    if(%1 != findnext, sub(i,scene.count,1));
    txtadd(scenexml,'<krpano>',get(scene[%i].content),'</krpano>');
    if(scenexml == xml.content,
       dec(i);
       if(i GE 0, loadscene(get(scene[%i].name), null, MERGE, BLEND(1)); );
       update_prev_next_buttons(get(i));
      ,
       dec(i);
       if(i GE 0, prevscene(findnext));
      );
</action>

<action name="nextscene">
    if(%1 != findnext, set(i,0));
    txtadd(scenexml,'<krpano>',get(scene[%i].content),'</krpano>');
    if(scenexml == xml.content,
       inc(i);
       if(i LT scene.count, loadscene(get(scene[%i].name), null, MERGE, BLEND(1)); );
       update_prev_next_buttons(get(i));
      ,
       inc(i);
       if(i LT scene.count, nextscene(findnext));
      );
</action>


best regards,
Klaus

9

Monday, February 22nd 2010, 6:53pm

Wahou great code, I try this later and come back make a reply

Thank Klaus

10

Saturday, April 3rd 2010, 7:38pm

I have used a small trick for that:
internally when loading a scene, it's content is stored in the "xml.content" variable (inside a <krpano> tag),
then I loop through all scenes (known via "scene.count") and check if it is the current scene, and if yes,
the previous or next scene will be loaded,
Hi Klaus. I know this is a great solution but since I am thick could you please check why mine is not working

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<krpano version="1.0.8" logkey="false">
 <include url="%SWFPATH%/plugins.xml" />
	<include url="videotour0.xml"/>
	<plugin name="data" keep="true"/>
	
	<textstyle name="DEFAULT" alpha="1" bold="false" font="Arial" fontsize="16" italic="false" textcolor="0xff000000"/>
	
	<plugin name="logo" url="videotourdata/graphics/logo.png" keep="true" align="rightbottom" x="10" y="10" width="109" height="18" onclick="openurl(http://www.myomsk.info,_blank)"/>
	<plugin name="in" align="bottom" keep="true" ondown="set(movevectorz,-1);" onout="set(blendmode,normal);" onover="set(blendmode,add);" onup="set(movevectorz,0);" url="videotourdata/graphics/menu/menu0.png" x="-160" y="10"/>
	<plugin name="out" align="bottom" keep="true" ondown="set(movevectorz,+1);" onout="set(blendmode,normal);" onover="set(blendmode,add);" onup="set(movevectorz,0);" url="videotourdata/graphics/menu/menu1.png" x="-120" y="10"/>
	<plugin name="left" align="bottom" keep="true" ondown="set(movevectorx,-1);" onout="set(blendmode,normal);" onover="set(blendmode,add);" onup="set(movevectorx,0);" url="videotourdata/graphics/menu/menu2.png" x="-80" y="10"/>
	<plugin name="right" align="bottom" keep="true" ondown="set(movevectorx,+1);" onout="set(blendmode,normal);" onover="set(blendmode,add);" onup="set(movevectorx,0);" url="videotourdata/graphics/menu/menu3.png" x="-40" y="10"/>

	<plugin name="prevscene" align="bottom" keep="true"  onclick="action(prevscene);" onout="set(blendmode,normal);" onover="set(blendmode,add);" url="videotourdata/graphics/menu/menu4.png" x="0" y="10"/>
	<plugin name="nextscene" align="bottom" keep="true"  onclick="action(nextscene);" onout="set(blendmode,normal);" onover="set(blendmode,add);"  url="videotourdata/graphics/menu/menu5.png" x="40" y="10"/>


	<plugin name="home" align="bottom" blendmode="normal" keep="true" onclick="lookto(get(panoview.h),get(panoview.v),get(panoview.fov),smooth(100,20,50));" onout="set(blendmode,normal);" onover="set(blendmode,add);" url="videotourdata/graphics/menu/menu6.png" x="80" y="10"/>
	<plugin name="openfs" align="bottom" blendmode="screen" keep="true" onclick="set(fullscreen,true);" onout="set(blendmode,screen);" onover="set(blendmode,add);" url="videotourdata/graphics/menu/menu7.png" x="120" y="10"/>
	<plugin name="closefs" align="bottom" blendmode="screen" keep="true" onclick="set(fullscreen,false);" onout="set(blendmode,screen);" onover="set(blendmode,add);" url="videotourdata/graphics/menu/menu8.png" visible="false" x="120" y="10"/>
	<events onenterfullscreen="set(plugin[openfs].visible,false); set(plugin[closefs].visible,true);" onexitfullscreen="set(plugin[openfs].visible,true); set(plugin[closefs].visible,false);"/>
	<plugin name="autorotation" align="bottom" blendmode="screen" keep="true" onclick="switch(autorotate.enabled);" onout="set(blendmode,screen);" onover="set(blendmode,add);" url="videotourdata/graphics/menu/menu9.png" x="160" y="10"/>
	<action name="prevscene">
	if(%1 != findnext, sub(i,scene.count,1));
	txtadd(scenexml,'<krpano>',get(scene[%i].content),'</krpano>');
	if(scenexml == xml.content,
   	dec(i);
   	if(i LT 0, sub(i,scene.count,1));
   	loadscene(get(scene[%i].name), null, MERGE, BLEND(1));
  	,
   	dec(i);
   	if(i GE 0, prevscene(findnext));
  	);
</action>

<action name="nextscene">
	if(%1 != findnext, set(i,0));
	txtadd(scenexml,'<krpano>',get(scene[%i].content),'</krpano>');
	if(scenexml == xml.content,
   	inc(i);
   	if(i == scene.count, set(i,0));
   	loadscene(get(scene[%i].name), null, MERGE, BLEND(1));
  	,
   	inc(i);
   	if(i LT scene.count, nextscene(findnext));
  	);
</action>
</krpano>
	
	


Thank you

11

Wednesday, April 7th 2010, 10:58pm

Hi,
Hi Klaus. I know this is a great solution but since I am thick could you please check why mine is not working
do you have a link?
the posted code itself looks right,

best regards,
Klaus

12

Sunday, April 10th 2011, 8:34pm

Transitioning the images without stopping autorotate

Hi Klaus,
Any chance that you could better (improve) this code by allowing the scene to transition, or tween, into the next scene without stopping when autorotate is enabled? That would make it perfect for timelapse shots.
Thanks for the consideration.
Tony

13

Thursday, April 14th 2011, 3:52pm

Hi,
Any chance that you could better (improve) this code by allowing the scene to transition, or tween, into the next scene without stopping when autorotate is enabled? That would make it perfect for timelapse shots.
I'm already planing that, but this needs a bigger change in the core viewer engine, so it can still take some time,

best regards,
Klaus

14

Thursday, April 14th 2011, 7:32pm

Thanks for your dedication

Thanks for the update Klaus. I understand the complexity of that and figured it could prove more, well - complex. Thanks for your devotion. I'm in for the long run and can wait.
Tony

This post has been edited 1 times, last edit by "nefar1ous" (Apr 21st 2011, 4:58pm)


Tuur

Sage

Posts: 3,172

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

15

Monday, May 23rd 2011, 1:25am

Hi,

i try to make next picture button..

here some code.. but get stuck in the next_pic action (the buttons under the big picture :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<plugin name="btn_pic_next" url="../../skin/gallery_right.png" keep="true" visible="false" alpha="0.6" parent="base_pic" align="center" x="240" y="145" scale="0.2" zorder="100" onover="tween(alpha,1)" onout="tween(alpha,0.6)" onclick="next_pic();" />


<action name="next_pic" >
		if(plugin[firstthumb].visible == true, 
			removeplugin(firstthumb);
			inc(i);

			,
			inc(i);
			
			
			<!-- ???????????? tried a lot different things... but no succes -->
);

trace('name=',get(plugin[get(pn)].url)); 
	</action>	
	

<action name="open_gallery">
		
wait(2);
		tween(plugin[pic_bg].height,350,0.5);
		tween(plugin[pic_bg].width,100,0.5,,WAIT);
		tween(plugin[pic_bg].width,550,0.7,,WAIT);
	set(plugin[btn_pic_next].visible,true);
	set(plugin[btn_pic_previous].visible,true);
		addplugin(firstthumb);
			set(plugin[firstthumb].url, get(pic.thumb[thumb_0].url)); 						
			set(plugin[firstthumb].alpha, 1); 						
			set(plugin[firstthumb].visible, true); 						
			set(plugin[firstthumb].align, center);
			set(plugin[firstthumb].zorder, 100);
			set(plugin[firstthumb].x, 200);
			set(plugin[firstthumb].y, -20);
			set(plugin[firstthumb].effect,glow(0xFFFFFF,1,15,10000));
			set(plugin[firstthumb].roundedge,20);
	</action>

<action name="showpic">		
			if(plugin[firstthumb].visible == true, removeplugin(firstthumb););					

		removeplugin(get(pn));
		txtadd(pn,'thumb_',get(i)); 													
		addplugin(get(pn));
			set(plugin[get(pn)].url, get(pic.thumb[get(name)].url)); 						
			set(plugin[get(pn)].alpha, 1); 						
			set(plugin[get(pn)].visible, true); 						
			set(plugin[get(pn)].align, center);
			set(plugin[get(pn)].zorder, 100);
			set(plugin[get(pn)].x, 200);
			set(plugin[get(pn)].y, -20);
			set(plugin[get(pn)].effect,glow(0xFFFFFF,1,15,10000));
			set(plugin[get(pn)].roundedge,20);
	</action>	

<pic>
	
	<thumb name="thumb_0" 	url="../images/001.jpg"  title="Test" 			todo="lookat(240,0,50);showpic();" />
	<thumb name="thumb_1" 	url="../images/002.jpg"  title="Test"			todo="lookat(40,0,50);" />
	<thumb name="thumb_2" 	url="../images/003.jpg"  title="Test"			todo="lookat(340,0,50);" />
	<thumb name="thumb_3"  	url="../images/004.jpg"  title="another test"	todo="showpic();" />
	<thumb name="thumb_4" 	url="../images/005.jpg"  title="Test"			todo="showpic();" />
	<thumb name="thumb_5" 	url="../images/006.jpg"  title="Test"			todo="showpic();" />
	<thumb name="thumb_6" 	url="../images/007.jpg"	 title="Test"			todo="" />
	<thumb name="thumb_7" 	url="../images/008.jpg"  title="Test"			todo="showpic();" />
	<thumb name="thumb_8"   url="../images/009.jpg"	 title="keep testing"	todo="lookat(140,0,50);" />
	<thumb name="thumb_9"   url="../images/010.jpg"	 title="keep testing"	todo="lookat(140,0,50);" />
	<thumb name="thumb_10"  url="../images/011.jpg"  title="keep testing"	todo="lookat(140,0,50);" />
	<thumb name="thumb_11"  url="../images/012.jpg"  title="keep testing"	todo="lookat(140,0,50);" />
</pic>


*cry* *wacko*

full xml: http://www.virtualtuur.com/krpano/simple/9/gallery9.xml (but i'm editing some here.. so it changes..)

example: http://www.virtualtuur.com/krpano/simple/9/



Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

Tuur

Sage

Posts: 3,172

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

16

Monday, May 23rd 2011, 1:26am

Hi,

i try to make next picture button..

here some code.. but get stuck in the next_pic action (the buttons under the big picture :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<plugin name="btn_pic_next" url="../../skin/gallery_right.png" keep="true" visible="false" alpha="0.6" parent="base_pic" 
align="center" x="240" y="145" scale="0.2" zorder="100" onover="tween(alpha,1)" onout="tween(alpha,0.6)" onclick="next_pic();" />


<action name="next_pic" >
		if(plugin[firstthumb].visible == true, 
			removeplugin(firstthumb);
			inc(i);

			,
			inc(i);
			
			
			<!-- ???????????? tried a lot different things... but no succes -->
);

trace('name=',get(plugin[get(pn)].url)); 
	</action>	
	

<action name="open_gallery">
		
wait(2);
		tween(plugin[pic_bg].height,350,0.5);
		tween(plugin[pic_bg].width,100,0.5,,WAIT);
		tween(plugin[pic_bg].width,550,0.7,,WAIT);
	set(plugin[btn_pic_next].visible,true);
	set(plugin[btn_pic_previous].visible,true);
		addplugin(firstthumb);
			set(plugin[firstthumb].url, get(pic.thumb[thumb_0].url)); 						
			set(plugin[firstthumb].alpha, 1); 						
			set(plugin[firstthumb].visible, true); 						
			set(plugin[firstthumb].align, center);
			set(plugin[firstthumb].zorder, 100);
			set(plugin[firstthumb].x, 200);
			set(plugin[firstthumb].y, -20);
			set(plugin[firstthumb].effect,glow(0xFFFFFF,1,15,10000));
			set(plugin[firstthumb].roundedge,20);
	</action>

<action name="showpic">		
			if(plugin[firstthumb].visible == true, removeplugin(firstthumb););					

		removeplugin(get(pn));
		txtadd(pn,'thumb_',get(i)); 													
		addplugin(get(pn));
			set(plugin[get(pn)].url, get(pic.thumb[get(name)].url)); 						
			set(plugin[get(pn)].alpha, 1); 						
			set(plugin[get(pn)].visible, true); 						
			set(plugin[get(pn)].align, center);
			set(plugin[get(pn)].zorder, 100);
			set(plugin[get(pn)].x, 200);
			set(plugin[get(pn)].y, -20);
			set(plugin[get(pn)].effect,glow(0xFFFFFF,1,15,10000));
			set(plugin[get(pn)].roundedge,20);
	</action>	

<pic>
	
	<thumb name="thumb_0" 	url="../images/001.jpg"  title="Test" 			todo="lookat(240,0,50);showpic();" />
	<thumb name="thumb_1" 	url="../images/002.jpg"  title="Test"			todo="lookat(40,0,50);" />
	<thumb name="thumb_2" 	url="../images/003.jpg"  title="Test"			todo="lookat(340,0,50);" />
	<thumb name="thumb_3"  	url="../images/004.jpg"  title="another test"	todo="showpic();" />
	<thumb name="thumb_4" 	url="../images/005.jpg"  title="Test"			todo="showpic();" />
	<thumb name="thumb_5" 	url="../images/006.jpg"  title="Test"			todo="showpic();" />
	<thumb name="thumb_6" 	url="../images/007.jpg"	 title="Test"			todo="" />
	<thumb name="thumb_7" 	url="../images/008.jpg"  title="Test"			todo="showpic();" />
	<thumb name="thumb_8"   url="../images/009.jpg"	 title="keep testing"	todo="lookat(140,0,50);" />
	<thumb name="thumb_9"   url="../images/010.jpg"	 title="keep testing"	todo="lookat(140,0,50);" />
	<thumb name="thumb_10"  url="../images/011.jpg"  title="keep testing"	todo="lookat(140,0,50);" />
	<thumb name="thumb_11"  url="../images/012.jpg"  title="keep testing"	todo="lookat(140,0,50);" />
</pic>


*cry* *wacko*

full xml: http://www.virtualtuur.com/krpano/simple/9/gallery9.xml (but i'm editing some here.. so it changes..)

example: http://www.virtualtuur.com/krpano/simple/9/


i thought and am trying also something with copy and inc i ... *unsure*


Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

17

Saturday, May 28th 2011, 8:54pm

Great Work

This is really nice Tuur. When you finish it, I'd love to see. I nice option (in the end) would be to have it as a Pop Up from a button so you could turn it off and on.

Tuur

Sage

Posts: 3,172

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

18

Sunday, May 29th 2011, 12:58pm

it's there but not finished yet..

http://www.virtualtuur.com/krpano/simple/10

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

Similar threads