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.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

1

Wednesday, May 11th 2011, 12:57pm

arguments etc lesson, need help

Hi all,

i try to learn a bit more those arguments / placeholders stuff.. higher level coding..
I thought it would be nice to study on an photogallery..

as the base i took some code from http://www.krpano.com/forum/wbb/index.ph…23010#post23010

so ..

now i have http://www.virtualtuur.com/krpano/simple/1/
xml: http://www.virtualtuur.com/krpano/simple/1/gallery.xml

i like to make the layout like simple viewer-ish but also changable from xml..

the first thing i like to get now is how i can make the 3 rows getting straight (verticaly)

now is:

ooo
....ooo
.........ooo

but i want

ooo
ooo
ooo

i tried a lot but this is the best i can do using the variables...
mostly i understand what is going on here..... mostly

If there is a smarter way of putting this or getting this result, i like to know to learn..
I also tried it with the buildthumbs action from the vtour but that i could not get to work..

Any step wise help will be very much appreciated..
Maybe a teacher will help ? VN, Pinsane, Michel, Job, Aldo, Zephyr, Sachagriffin ???
I also read the tut from pinsane a couple of times and also studied some code from the downloads and the forum..
but i like to see some simple visual examples with code .. growing in difficultness... (is that english?) *g*

like:

i have a lot of thumbs...

1. how to get them in a row vertical or horizontal
2. how can i set a limit to the row (thumb count) and that it starts a new row
3. how to make a new , next, thumb field when the thumb count is 9

so lessons!
i'll host then so people can later look into it..

maybe even different things... not only a gallery...

Teacher stand up!
*g*

Tuur *thumbsup*

This post has been edited 5 times, last edit by "Tuur" (May 11th 2011, 5:15pm)


2

Wednesday, May 11th 2011, 1:29pm

I think is about

mul(thumb_x,thumb_x_step, %1);

but I don't know yet fix it

3

Wednesday, May 11th 2011, 1:34pm

Try to leave it
and replace
set(plugin[t_%1].x,get(thumb_x));
by
set(plugin[t_%1].x, 0);

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

4

Wednesday, May 11th 2011, 1:36pm

He Job,

yes that was my thought also ..

but when i take that out with the 2nd and 3th row i get

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

the 3 thumbs get in one place overlapping each other.. on the last position..

this is a specific problem that i like to get fixed but maybe we should start from scratch..?

to LEARN!

Tuur *thumbsup*

5

Wednesday, May 11th 2011, 1:39pm

Okay keep the first and change the second

I try to make the same at home and try to fix it

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

6

Wednesday, May 11th 2011, 1:39pm

oke
maybe reset the t_count.. after the first row and go on with the next thumbs.. or so but how..?

i tried an setup with the i NEXT thing... maybe that's the way, but i can't get it to work just to get a long row .. in the first place..

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

thanx

Tuur *thumbsup*

This post has been edited 1 times, last edit by "Tuur" (May 11th 2011, 1:55pm)


7

Wednesday, May 11th 2011, 2:17pm

nothing appear !

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

8

Wednesday, May 11th 2011, 2:27pm

That's problem1
Tuur *thumbsup*

9

Wednesday, May 11th 2011, 2:28pm

look inc of thumb_stage *whistling*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

10

Wednesday, May 11th 2011, 4:41pm

what do you mean Job?
Can you be more specific?

and where in which example?

Tuur

11

Wednesday, May 11th 2011, 4:44pm

No time now !

Perhaps next week *rolleyes*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

12

Wednesday, May 11th 2011, 4:45pm

well there are more masters here..

so to make it clear..
I have 3 different setups:

http://www.virtualtuur.com/krpano/simple/1
http://www.virtualtuur.com/krpano/simple/2
http://www.virtualtuur.com/krpano/simple/3

which one to go on with and how to get them like i asked in the first post of this thread..


Tuur *thumbsup*

13

Wednesday, May 11th 2011, 4:48pm

I think I need time for this and now I have a big work to deliver

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

14

Wednesday, May 11th 2011, 4:51pm

oke!
your help is always appreciated..
but anybody can kick in here to learn us dummy's to understand more of the argument thing and all the math and variables..

So simple viewer xml project.. to Learn step by step..
Maybe it's better to investigate what we want the xml core to do in total for this project?

What is the workaround/ workflow for these more complex things?

?

Tuur *thumbsup*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

15

Wednesday, May 11th 2011, 9:20pm

try:

Source code

1
2
3
4
5
6
7
<action name="add_thumbs">
  if(i === null, set(i,0));
  inc(i);		
  txtadd(tname,'thumb_', get(i));	 
  addthumb(get(pic.thumb[get(tname)])); 
  if(i LE pic.thumb.count, delayedcall(0.25, add_thumbs()));
</action>


addthumb then receives the name of the thumbnail so you can read its data, for instance pic.thumb[%1].url or pic.thumb[%1].title

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

16

Wednesday, May 11th 2011, 11:50pm

mmm...

just that changing didn't work so i played a bit and come to this... but i see nothing

i now have this:


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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<krpano version="1.0.8">

	<events onxmlcomplete="set(events.onxmlcomplete,null); create_gallery();"/>

	
<action name="create_gallery">

		nextthumb();
	</action>




<action name="nextthumb">

if(i === null, set(i,0));
  inc(i);		
  txtadd(tname,'thumb_', get(i));	 
  addthumb(get(pic.thumb[get(tname)])); 
  if(i LE pic.thumb.count, delayedcall(0.25, nextthumb()));
  
											
	</action>


<action name="addthumb">
	if(i LE 3,	
		
		set(plugin[t_%1].x,0);
		add(thumb_x_step,get(plugin[t_%1].x),80);
		mul(thumb_x,thumb_x_step, %1);
		copy(plugin[t_%1].keep,plugin[thumb_stage].keep);
			addplugin(t_%1);
		plugin[t_%1].loadstyle(thumbrow_1);
		set(plugin[t_%1].x,get(pic.thumb_x));
		set(plugin[t_%1].url,get(pic.thumb[%1].url) );
		set(plugin[t_%1].onhover,showtext(get(pic.thumb[%1].title)));
		set(plugin[t_%1].onover,set(pic.plugin[%1].alpha, 1.0));
		set(plugin[t_%1].onout,set(pic.plugin[%1].alpha, 0.8));
		set(plugin[t_%1].onclick,get(pic.thumb[%1].todo));
		
);



	if(i GE 4,	
		set(plugin[t_%1].x,0);
		add(pic.thumb_x_step,get(plugin[t_%1].x),80);
		mul(pic.thumb_x,pic.thumb_x_step, %1);
		copy(plugin[t_%1].keep,plugin[thumb_stage].keep);
			addplugin(t_%1);
		plugin[t_%1].loadstyle(thumbrow_2);
		
set(plugin[t_%1].x, 0);
		set(plugin[t_%1].url,get(pic.thumb[thumb_%1].url) );
		set(plugin[t_%1].onhover,showtext(get(pic.thumb[thumb_%1].title)));
		set(plugin[t_%1].onover,set(plugin[t_%1].alpha, 1.0));
		set(plugin[t_%1].onout,set(plugin[t_%1].alpha, 0.8));
		set(plugin[t_%1].onclick,get(pic.thumb[thumb_%1].todo));
		
);


	if(i GE 7,	
		set(plugin[t_%1].x,0);
		add(pic.thumb_x_step,get(plugin[t_%1].x),80);
		mul(pic.thumb_x,pic.thumb_x_step, %1);
		copy(plugin[t_%1].keep,plugin[thumb_stage].keep);
			addplugin(t_%1);
		plugin[t_%1].loadstyle(thumbrow_3);
		
set(plugin[t_%1].x, 0);
		set(plugin[t_%1].url,get(pic.thumb[thumb_%1].url) );
		set(plugin[t_%1].onhover,showtext(get(pic.thumb[thumb_%1].title)));
		set(plugin[t_%1].onover,set(plugin[t_%1].alpha, 1.0));
		set(plugin[t_%1].onout,set(plugin[t_%1].alpha, 0.8));
		set(plugin[t_%1].onclick,get(pic.thumb[thumb_%1].todo));
		
);  

							
</action>


<style name="thumbrow_1"  keep="true" visible="true" parent="thumb_stage" align="center" alpha="0.8"  onover="set(plugin[t_%1].alpha, 1.0)" onout="set(plugin[t_%1].alpha, 0.8)" onclick="get(thumb[thumb_%1].todo)"  effect="glow(0xFFFFFF,20.0,6,10000)" height="60" width="60"    y="-120"/>
<style name="thumbrow_2"  keep="true" visible="true" parent="thumb_stage" align="center" alpha="0.8"  onover="set(plugin[t_%1].alpha, 1.0)" onout="set(plugin[t_%1].alpha, 0.8)" onclick="get(thumb[thumb_%1].todo)"  effect="glow(0xFFFFFF,20.0,6,10000)" height="60" width="60"      y="-40"/>
<style name="thumbrow_3"  keep="true" visible="true" parent="thumb_stage" align="center" alpha="0.8"  onover="set(plugin[t_%1].alpha, 1.0)" onout="set(plugin[t_%1].alpha, 0.8)" onclick="get(thumb[thumb_%1].todo)"  effect="glow(0xFFFFFF,20.0,6,10000)" height="60" width="60"     y="40" />


<textstyle name="DEFAULT" 
	           font="Verdana" fontsize="13" italic="false"
	           border="false" background="false"
	           textcolor="0xFFFFFF"
	           effect="glow(0x000000,0.7,4,2);dropshadow(2,45,0x000000,2,1);"
			 
	           />

<pic>
	
<thumb name="thumb_1" title="Test"	url="../images/001.jpg" 	todo="" />
<thumb name="thumb_2" 	url="../images/002.jpg"  	todo="" />
<thumb name="thumb_3" 	url="../images/003.jpg" 	todo="" />
<thumb name="thumb_4" title="another test" 	url="../images/004.jpg" 	todo="" />
<thumb name="thumb_5" 	url="../images/005.jpg" 	todo="" />
<thumb name="thumb_6" 	url="../images/006.jpg" 	todo="" />
<thumb name="thumb_7" 	url="../images/007.jpg"		todo="" />
<thumb name="thumb_8" 	url="../images/008.jpg" 	todo="" />
<thumb name="thumb_9" title="keep testing"	url="../images/009.jpg"		todo="" />

</pic>
	
	
</krpano>



but no succes yet...

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

http://www.virtualtuur.com/krpano/simple/3/gallery3.xml
*cry*
*g*


Tuur *thumbsup*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

17

Thursday, May 12th 2011, 2:13pm

well:

txtadd(tname,'thumb_', get(i));
addthumb(get(pic.thumb[get(tname)]));

addthumb has the name of the thumbnail you want,

but in the addthumb action you do if i LE 3 etc

i think its better to put an extra parameter in add thumb and you do if %2 LE 3 etc
addthumb(get(pic.thumb[get(tname)]), get(i) );

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,387

Location: Netherlands

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

  • Send private message

18

Thursday, May 12th 2011, 4:08pm

Hi,

i don't really understand what you mean here..

were to put what...?
oke in the addthumb action i have 3 "if 's"...
should i make another one?
And what should that be then to do what?

or should i change the 3 existing "if's" ???

like

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if(%2 LE 3, addthumb(get(pic.thumb[get(tname)]), get(i) );
		set(plugin[t_%1].x,0);
		add(thumb_x_step,get(plugin[t_%1].x),80);
		mul(thumb_x,thumb_x_step, %1);
		copy(plugin[t_%1].keep,plugin[thumb_stage].keep);


			addplugin(t_%1);
		plugin[t_%1].loadstyle(thumbrow_1);
		set(plugin[t_%1].x,get(pic.thumb_x));
		set(plugin[t_%1].url,get(pic.thumb[%1].url) );
		set(plugin[t_%1].onhover,showtext(get(pic.thumb[%1].title)));
		set(plugin[t_%1].onover,set(plugin[%1].alpha, 1.0));
		set(plugin[t_%1].onout,set(plugin[%1].alpha, 0.8));
		set(plugin[t_%1].onclick,get(pic.thumb[%1].todo));

);

*confused*

i also don't understand why i don't see even one thumb.. or all of them on the same place. *confused*


i'm also unsure about this part..

Source code

1
2
3
4
		set(plugin[t_%1].x,0);
		add(thumb_x_step,get(plugin[t_%1].x),80);
		mul(thumb_x,thumb_x_step, %1);
		copy(plugin[t_%1].keep,plugin[thumb_stage].keep);


and do i need that thumb stage etc as is in the <!-- --> here..
http://www.virtualtuur.com/krpano/simple/3/gallery3.xml
i think yes to position the whole thing as i did in version 1..

well..


i would love just a few lines of good code to see something and that i can understand it and go on

Tuur *thumbsup*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

19

Thursday, May 12th 2011, 9:32pm

Instead of debugging your code, I thought I might as well write my own.

This will create a maximum of 4 column wide grid of images, based on a krpano array structure. I commented almost every line.

The runthrough: I create an array, onxmlcomplete I loop through the array. Using some modulus (mod()) tricks I create a grid of 4 images wide. The code is easy adaptable for 1 column or 100. If you want 1 single horizontal line, change columns to a high number. To create 1 vertical column, change column to 1.

Since krpano doesnt support math.Floor, I had to create a javascript function. So It wont work offline without local access permission.

javascript:

Source code

1
2
3
4
5
6
7
8
	<script>
	   function floor(num){
			krpanoObj = document.getElementById('krpanoSWFObject');
			num = Math.floor(parseInt(num));
			krpanoObj.set("floor", num);
			krpanoObj.call("trace("+num+"))");
	   }
	</script>


krpano

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
<krpano version="1.0.8.14" >
	<preview type="grid(cube,32,32,512,0x000000,0x111111,0x555555);" />
	
<events onxmlcomplete="build_thumbs()" />

<pic>
	<thumb name="thumb_0" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_1" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_2" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_3" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_4" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_5" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_6" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_7" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_8" url="../images/menu/menu-bg.png" title="a nice image" />
	<thumb name="thumb_9" url="../images/menu/menu-bg.png" title="a nice image" />
</pic>
<action name="build_thumbs">
	trace(pic.thumb.count); <!-- Traces 9, because there are 9 thumbs in pic -->
	set(columns, 4); <!-- Max columns, change to make it longer -->
	if(%1 != NEXT, set(i,0)); <!-- if the first parameter isn't next, then set the counter to 0 -->
	
	txtadd(tn, 'thumb_',  get(i)); <!-- puts thumb_ and i together so you get thumb_1, thumb_2 etc -->

	addplugin(get(tn)); <!-- creates a plugin called thumb_1 (same name as thumb) -->
        set(plugin[get(tn)].url, get(pic.thumb[get(tn)].url)); <!-- sets the url of the plugin the same as thumb url -->
	  set(plugin[get(tn)].onhover, showtext(get(pic.thumb[get(tn)].title))); <!-- sets the tooltipof the plugin the same as thumb title-->
	mod(tmp_mod, get(i), get(columns)); <!-- using i % columns, I can calculate which collumn tbe thumb should be -->
	mul(x_offset, get(tmp_mod), 60); <!-- picture height * outpu from prev calculation -->

	div(tmp_div, get(i), get(columns)); <!-- same trick for rows -->
	js(floor(get(tmp_div))); <!-- need to use Math.floor in javascript since krpano doesnt support it -->
	mul(y_offset, get(floor), 60); <!-- floor is the var set by js -->

	set(plugin[get(tn)].x, get(x_offset));
	set(plugin[get(tn)].y, get(y_offset));
	set(plugin[get(tn)].align, topleft);
inc(i); <!-- increase i by 1 -->
	if(i LT pic.thumb.count, build_thumbs(NEXT));
</action>

</krpano>

This post has been edited 1 times, last edit by "Zephyr" (May 13th 2011, 2:26pm)


Posts: 1,855

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

20

Thursday, May 12th 2011, 10:21pm

Showoff...
:)
It's nice to see real code by trained programmers. Stare at it long enough and you can eventually learn something.
Nice job!
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Similar threads