You are not logged in.

1

Saturday, April 3rd 2010, 4:54pm

hotspots again

hello,
I want flyout hotspots to fly out, wait a litle bit and then merge to another scene depending on which hotspot was clicked.
I'm not sure where to do that ( to check is the flyout image out )
I guess there is a wait instruction so I could do it in the onclick, wait a bit so the image would have probably flown out and then check the state of it.
does that seem right or how else would you do that ?
cheers

mick

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

2

Sunday, April 4th 2010, 1:56pm

Hi mick,

Quoted

I want flyout hotspots to fly out, wait a litle bit and then merge to another scene depending on which hotspot was clicked.
Perhaps this code will do:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<hotspot name="spot"
	url="image1.jpg"
	distorted="true"
	ath="45"
	atv="54"
	scale="0.5"
	rx="-22.5" ry="-26.25" rz="-50.1"
	backup_rx="0"
	backup_ry="0"
	backup_rz="0"
	backup_scale="0"
	flying="0.0"
	onclick="if(flying == 0.0, flyout() ; truc(get(name)) );"
	/>

<action name="truc">
	delayedcall(2, set(hotspot[%1].keep,true);
		loadpano(grid.xml, null, MERGE, BLEND(2));
		set(hotspot[%1].onclick, flyback(); tween(hotspot[%1].alpha,0,,,removehotspot(%1) ))
		);
</action>


SAlut.

3

Sunday, April 4th 2010, 2:23pm

Hi,

does that wait 2 seconds.
I think that is similar
<action name="teststate" >
wait(2);
loadscene(scene2, null, MERGE, BLEND(1)))
</action>
but I thought properly I should check that the flystate was out. I don't know how to do that. *unsure*
cheers

mick

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

4

Sunday, April 4th 2010, 4:35pm

Hi mick,

Quoted

but I thought properly I should check that the flystate was out. I don't know how to do that.
So, it seems your are using the code from the flyout more hotspots example....
Then, you can check the flystate variable... for example:

Source code

1
if(flystate == 2, dosomething()  );

But, I think there is no need to check for the flystate... Doing so, the code could be really difficult to achieve...
Try this modified flyout more hotspots example:

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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!--
	krpano 1.0.8
	- flyout more hotspots example
	- when one hotspot is flying out, all others will fly back in
-->

<krpano version="1.0.8" onstart="showtext('[b][i]krpano[br]flyout more hotspots example[/i][/b]', infostyle);">

	<!-- text style for startup text -->
	<textstyle name="infostyle"
	       	origin="center" edge="center" yoffset="-100" textalign="center" background="false" border="false"
	       	fontsize="40" textcolor="0xFFFFFF" bold="false" effect="glow(0xFFFFFF,0.7,4,2);glow(0x000000,1,4,2);dropshadow(3,45,0x000000,2,0.6);"
	       	showtime="4.0" fadeintime="1.0" fadetime="1.0"
	       	/>

	<!-- use only a grid preview pano (to save download space) -->
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" details="16" />

	<!-- view settings -->
	<view hlookat="12" vlookat="40" fov="105" />


	<!-- use a <style> to share the same attriubtes for all hotspots -->
	<style name="flyoutimage"
	   	distorted="true"
	   	backup_rx="0"
	   	backup_ry="0"
	   	backup_rz="0"
	   	backup_scale="0"
	   	backup_zorder="0"
	   	flying="0.0"
	   	flystate="0"
	   	onclick="if(flystate == 0, flyout_by_name(get(name)), flyback_by_name(get(name)) );"
	   	/>

	<hotspot name="spot1" style="flyoutimage"
         	url="image1.jpg"
         	zorder="1"
         	ath="45"
         	atv="54"
         	scale="0.5"
         	rx="-22.5" ry="-26.25" rz="-50.1"
         	onloaded="set(onclick,if(flystate == 0, flyout_by_name(get(name)); truc(get(name)), flyback_by_name(get(name))) );"
         	/>

	<action name="truc">
		wait(2);
		set(hotspot[%1].keep,true);trace(hotspot[%1].keep);
		loadscene(scene2, null, MERGE, BLEND(1));
		set(hotspot[%1].onclick, 'flyback_by_name(%1); tween(hotspot[%1].alpha,0,,,removehotspot(%1) )');
	</action>

	<hotspot name="spot2" style="flyoutimage"
	     	url="image2.jpg"
	     	zorder="2"
	     	ath="60"
	     	atv="54"
	     	scale="0.5"
	     	rx="-22.5" ry="-26.25" rz="-50.1"
	     	/>

	<hotspot name="spot3" style="flyoutimage"
	     	url="image3.jpg"
	     	zorder="3"
	     	ath="75"
	     	atv="58"
	     	scale="0.5"
	     	rx="-22.5" ry="-26.25" rz="-50.1"
	     	/>


	<!--
		flyout/flyback actions
		(for more stylish in/out animations play with different tweentypes and times)
	-->

	<action name="flyout_by_name">
		<!-- make all other hotspots flying back -->
		flyback_others();

		<!--
			for best control set 4 fly states:
			0 = normal
			1 = while flying out
			2 = out
			3 = while flying back
		-->

		<!-- save original position/rotation -->
		if(hotspot[%1].flystate == 0,
			copy(hotspot[%1].backup_rx, 	hotspot[%1].rx);
			copy(hotspot[%1].backup_ry, 	hotspot[%1].ry);
			copy(hotspot[%1].backup_rz, 	hotspot[%1].rz);
			copy(hotspot[%1].backup_scale,  hotspot[%1].scale);
			copy(hotspot[%1].backup_zorder, hotspot[%1].zorder);
		  );

		<!-- set new state -->
		set(hotspot[%1].flystate,1);
		set(hotspot[%1].zorder,99);

		<!-- tween the rotations values to 0 for a flat screen view -->
		tween(hotspot[%1].rx, 0);
		tween(hotspot[%1].ry, 0);
		tween(hotspot[%1].rz, 0);
		tween(hotspot[%1].scale, 1.5);

		<!--
			tween 'flying' to 1.0,
			this makes the hotspot independent from the panorama rotation and scaling
		-->
		tween(hotspot[%1].flying, 1.0, 0.5, default, set(hotspot[%1].flystate,2); );
	</action>


	<action name="flyback_by_name">
		if(hotspot[%1].flystate != 3,
			set(hotspot[%1].flystate,3);

			<!-- tween back to the stored backup values -->
			tween(hotspot[%1].rx,	get(hotspot[%1].backup_rx)	);
			tween(hotspot[%1].ry,	get(hotspot[%1].backup_ry)	);
			tween(hotspot[%1].rz,	get(hotspot[%1].backup_rz)	);
			tween(hotspot[%1].scale, get(hotspot[%1].backup_scale) );

			copy(hotspot[%1].zorder, hotspot[%1].backup_zorder);

			<!-- tween 'flying' also back to 0.0 -->
			tween(hotspot[%1].flying, 0.0, 0.5, default, set(hotspot[%1].flystate,0); );
		  );
	</action>


	<action name="flyback_others">
		if(%1 != nextloop, set(i,0));
		
		if(hotspot[%i].style == flyoutimage,
			if(hotspot[%i].flystate != 0, flyback_by_name(get(hotspot[%i].name)); );
		  );
		  
		inc(i);
		if(i LT hotspot.count, flyback_others(nextloop); );
	</action>


</krpano>


The lines added are:

Source code

42
43
44
45
46
47
48
49
50
51
52
.......
         	onloaded="set(onclick,if(flystate == 0,  flyout_by_name(get(name)); truc(get(name)), flyback_by_name(get(name)))  );"
         	/>

	<action name="truc">
	 	wait(2);
		 set(hotspot[%1].keep,true);trace(hotspot[%1].keep);
		loadscene(scene2, null, MERGE, BLEND(1))
		 set(hotspot[%1].onclick, 'flyback_by_name(%1);  tween(hotspot[%1].alpha,0,,,removehotspot(%1) )');
	 </action>
.......

in line 43 --- because all the flying hotspots use a <style> to share the same attributes for all hotspots, we set the onclick to our new needs (call a new action: truc() )....
lines 46 to 51 --- the new action...
  • first we wait 2 seconds
  • then we set the hotspot to be kept....This way the hotspot can merge with the new scene....
  • then, we loads the new scene...
  • and finally, we set the onclick of the hotspot to fly back and remove it...

Hope this can help... let me know...

SAlut

5

Sunday, April 4th 2010, 6:39pm

hi,
yes that is helping, I will try to improve the behaviour I have.
ideally,
a panorama with various hotspots (pictures on walls). when clicked picture flysout and merges with a new scene( same image), when something clicked scene merges back with flownout hotspot and first scene, hotspot flysback.
cheers

mick

6

Tuesday, May 18th 2010, 2:26pm

I leave it for a bit, go back and I have forgotten everything *cry*
can somebody remind me when to use commas and semi colons ?
as above

Source code

1
onloaded="set(onclick,if(flystate == 0, flyout_by_name(get(name)); truc(get(name)), flyback_by_name(get(name))) );"

does the if statement have an else because of the ;

cheers

mick

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

7

Tuesday, May 18th 2010, 11:39pm

Hi mick,
if( condition , trueaction , falseaction);
it is like :
if ( condition is true (first coma) then do trueaction else (second coma) do falseaction);

The semi colons is the separator from each action:
onclick="action(dosomething); action(dosomethingmore); action(etc);"
or:
<action name="aname">
action(dosomething);
action(dosomethingmore)
;
action(etc)
;
</action>

Hope this help...

SAlut.

8

Wednesday, May 19th 2010, 10:17am

hi,
thanks, that's clear.
I haven't got clear what is the mechanism that the name in your first example

truc(get(name)) );"

is passed to the hotspot in the action.

<action name="truc">
delayedcall(2, set(hotspot[%1].keep,true);

cheers

mick

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

9

Wednesday, May 19th 2010, 8:56pm

Hi mick,

Source code

1
2
3
4
<hotspot name="spot1"
....
onloaded="truc(get(name));" 
/>


Because it is called inside the hotspot, get(name) retrieves the value of the name of that hotspot (name="spot1")....


Source code

1
2
3
4
5
6
7
<hotspot name="spot1"
 ....
 onloaded="dothis();" 
 />
<action name="dothis">
trace(get(name));
</action>


The same apply in this code because the call of dothis() is from the hotspot....

Hope it is clear and help in a way *smile* ...

SAlut.

10

Wednesday, May 19th 2010, 10:50pm

hi , thanks.


I understood the first example, the second is new.
So %1 represents the name of the hotspot and is the first parameter of the action truc ?

so it can be applied to anything inside the action truc ?
I'm a bit unclear about this.

cheers

mick

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

11

Wednesday, May 19th 2010, 11:04pm

Hi mick,

Quoted

So %1 represents the name of the hotspot and is the first parameter of the action truc ?
Correct ;-) !!!

Quoted

so it can be applied to anything inside the action truc ?
Yes ;-) !!!

SAlut.

12

Monday, March 6th 2017, 10:44am

Hi,
How did you find the value of rx,ry and rz,

I am also working on the hotspot but confused with these values.

If any one have any idea how to find the value of rx, ry, rz please help me.

Thanks in advance.