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.

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 202

Location: Leicester UK

  • Send private message

1

Friday, December 11th 2009, 6:30pm

Home made solution to find where to place hot spots

UPDATED 15-12-2009



DOWNLOAD:
Coordinates finder

INSTALLATION:
- Unzip in same directory as the HTML file
- Copy and paste the following code inside the HTML file, anywere between the tags <head></head>

Source code

1
<script type="text/javascript" src="coord_finder/double_click.js"></script>


-Copy and past the following code in your pano.xml file

Source code

1
<include url="%HTMLPATH%/coord_finder/coord_finder.xml"/>


INSTRUCTIONS:
- Right click on the panorama and select 'Coordinates finder - ON'
- Move the panorama and see how the values change
- Alternatively double click on the panorama to obtain the coordinates of that point
- To close it, click on the 'X' or right click and select 'Coordinates finder - OFF'

THANKS:
Michel you are a genius!
And of course thanks to Mr. K for Krpano!

NOTES:
I've included the textfield plugin in order to simplify the "intallation". It is the version 1.0.8-beta8
--------------------------------------------------------------------------------------------------

Hello everybody!

Recently a client asked to be able to create hotspots himself. So I am trying to make things really easy.
I have created an action to create hot spots, so he only has to edit one line in the xml file introducing some parameters.
Of course two of the parameters are "ath "and "atv" so I have made the following "home made hot spot editor":

http://clients.tourvista.co.uk/vt/orca/t…index_orca.html

Please ignore all the buttons, thumbnails and stuff... my "cool" editor consist on:

- A cross in the middle of the window: the plan is that he will move the panorama and choose where he wants to place the hot spot.
- A white button that shows the ath and atv coordinates when is clicked.

Ideally I would like to show the coordinates all the time without the hassle of clicking all the time. Also, if it is possible, I would like to show entire numbers (without decimals). Any ideas?

I know I could use "options.swf" to see those coordinates, but I don't want to confuse the client with such a mixture of parameters and numbers.

A really cool alternative would be to show a little box with the coordinates when he click twice somewhere on the panorama, but I have no idea how to achieve that!

My code is the following:

In the HTML file:

Source code

1
so.addVariable("onstart", "action(run_hs_editor); ");


In the xml file:

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
<!-- ***************** HOT SPOTS EDITOR  ********************** -->
	
	<action name="run_hs_editor">
	
	addplugin(hs_editor);
			set(plugin[hs_editor].url,%HTMLPATH%/files/panos/images/cross.png);
			set(plugin[hs_editor].zorder,5);
			set(plugin[hs_editor].align,center);
			set(plugin[hs_editor].handcursor,false);
			set(plugin[hs_editor].keep,true);	
			
	addplugin(click);
			set(plugin[click].url,%HTMLPATH%/files/panos/images/click.png);
			set(plugin[click].zorder,10);
			set(plugin[click].align,center);
			set(plugin[click].keep,true);	
			set(plugin[click].edge,topleft);	
			set(plugin[click].x,20);
			set(plugin[click].y,20);
			set(plugin[click].onclick,action(buildtext););			
	</action>

	<data name="coordinates"></data>
	
	<action name="buildtext">
	
	  txtadd(data[coordinates].content, get(view.hlookat), ' <br/> ', get(view.vlookat) );
	
		addplugin(hs_coordinates);
			set(plugin[hs_coordinates].url,%HTMLPATH%/files/krpano/textfield.swf);
			set(plugin[hs_coordinates].html,data:coordinates);
			set(plugin[hs_coordinates].width,120);
			set(plugin[hs_coordinates].height,35);
			set(plugin[hs_coordinates].zorder,11);
			set(plugin[hs_coordinates].background,false);
			set(plugin[hs_coordinates].align,center);
			set(plugin[hs_coordinates].x,122);
			set(plugin[hs_coordinates].y,40);
			set(plugin[hs_coordinates].keep,true);
	</action>



Thank you very much !

This post has been edited 5 times, last edit by "Tourvista" (Dec 15th 2009, 8:53pm)


michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

2

Friday, December 11th 2009, 6:38pm

Hi Tourvista,

Quoted

I would like to show entire numbers (without decimals).
There is a new action in krpano 1.0.8 beta 9:

Source code

1
roundval(val,precision);


Look here for more info: 1.0.8 beta 9 - fovtype setting

SAlut

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 202

Location: Leicester UK

  • Send private message

3

Friday, December 11th 2009, 7:01pm

Thanks for that Michel!

Unfortunately I've noticed that after a full rotation, the ath value keep on growing instead of reset to 0.
So after 5 full rotations it returns 1600!

*cry*

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

4

Friday, December 11th 2009, 7:59pm

Hi Tourvista,

Try the following code for your buildtext action:

Source code

1
2
3
4
5
6
7
8
9
	<action name="buildtext">
	
		mod(hdistance,get(view.hlookat),360);
		roundval(hdistance,0);
		set(vdistance,get(view.vlookat));
		roundval(vdistance,0);

		txtadd(data[coordinates].content, get(hdistance), ' <br/> ', get(vdistance) );
		......


note: I do not know why but the roundval(hdistance,0); adds a . after the value at first... *confused* KLAUS can you explain *question*
SAlut.

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 202

Location: Leicester UK

  • Send private message

5

Saturday, December 12th 2009, 12:56am

Genius! *cool*

It works!
It is true a "dot" appears when hlookat value is between -0.9 and 0.9
I am happy with the result so far.

Thanks!!!

bulp

Intermediate

Posts: 388

Location: Malaysia

  • Send private message

6

Saturday, December 12th 2009, 1:06pm

GREAT WORK!!! ..

im curently looking into tag! just like google tag or facebook tag that allowed visitor to put comments ...

this is possible ?



bulp...

machart

Trainee

Posts: 135

Location: Ostfriesland

  • Send private message

7

Saturday, December 12th 2009, 2:00pm

great thing!

is it possible to extend it to show the fov?
__close to the rainbow__
_D300S|Sunwayfoto|iMaci7|PM|APP|KRP_
www.panographie.net

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 202

Location: Leicester UK

  • Send private message

8

Saturday, December 12th 2009, 2:11pm

Hi all,

I have updated it.

In order to see it you have to right click and select "Corrdinates finder" (the first option)

If someone wants to use it or modify it you can download it here:

It contains an xml file and a folder with two graphics,
What I do is to add it to my virtual tours is to write the following:

Source code

1
<include url="coord_editor.xml"/>


If it doesn't work for you, check the path to the images.

PS: I've set it up to show a decimal in order to avoid the 0. issue
PS2: I've never heard of google or facebook tags (am I getting old fashion?) :-)
PS3: To show the fov look michel post underneath:

Cheers!

This post has been edited 2 times, last edit by "Tourvista" (Dec 12th 2009, 2:31pm)


michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

9

Saturday, December 12th 2009, 2:17pm

Hi machart,

This modified code will do ;-) :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	<action name="buildtext">
	
		mod(hdistance,get(view.hlookat),360);
		roundval(hdistance,0);
		set(vdistance,get(view.vlookat));
		roundval(vdistance,0);
		set(fovdistance,get(view.fov));
		roundval(fovdistance,0);

		txtadd(data[coordinates].content, get(hdistance), ' <br/> ', get(vdistance), ' <br/> ', get(fovdistance) );
	
		addplugin(hs_coordinates);
			set(plugin[hs_coordinates].url,%SWFPATH%/plugins/textfield.swf);
			set(plugin[hs_coordinates].html,data:coordinates);
			set(plugin[hs_coordinates].width,120);
			set(plugin[hs_coordinates].height,50);


note: line 16 -- set(plugin[hs_coordinates].height,50); (needed to make the fov visible)
also, the click.png should be adapted to fit with the new value (more height)

SAlut.

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

10

Saturday, December 12th 2009, 2:19pm

Hi tourvista,

That is great you share... Really great... *thumbup*

SAlut.

machart

Trainee

Posts: 135

Location: Ostfriesland

  • Send private message

11

Saturday, December 12th 2009, 3:01pm

ahh, thank you, guys! *thumbup*
__close to the rainbow__
_D300S|Sunwayfoto|iMaci7|PM|APP|KRP_
www.panographie.net

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 202

Location: Leicester UK

  • Send private message

12

Saturday, December 12th 2009, 3:14pm

Using Michel code, I have created a more propitiated interface:



You can download it here

Cheers!

13

Saturday, December 12th 2009, 11:30pm

@Tourvista & Michel

Quoted

note: I do not know why but the roundval(hdistance,0); adds a . after the value at first... *confused* KLAUS can you explain *question*
that's a flashplayer bug! (the as3 tofixed() function returns that)
I have now added a quick workaround for it (the next release will not have this problem)

best regards,
Klaus

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

14

Monday, December 14th 2009, 7:28pm

Hi Tourvista,

Great the context menu to activate the Coordinates finder *attention* *thumbup*
Perhaps you would edit your first post for tell about this change ... (the first time I has returned to the link, I was not able to see the cursor *g* )

Ideally I would like to show the coordinates all the time without the hassle of clicking all the time.
This can be done using the onviewchange event...

Source code

1
<events onviewchange="action(buildtext);"/>


A really cool alternative would be to show a little box with the coordinates when he click twice somewhere on the panorama, but I have no idea how to achieve that!
This can be done too ;-) ... an onDoubleClick event can be simulated using JavaScript. See this thread for more info: OnDoubleClick -- MoveTo() -- ScreenToSphere()

So, using the explained above, a possible code would be:
Add the following JavaScript code inside your html file:

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
<script type="text/javascript">
// <![CDATA[

function krpano() {
	return document.getElementById("krpanoSWFObject");
	}

function krpanodbclick(arg) {
	setTimeout("numclick = 0",300);
	numclick = numclick + 1;
	if (numclick == 2) {
		eval(arg);
		}
	}

function movetoscreentosphere() {

	var mousex = krpano().get("mouse.x");
	var mousey = krpano().get("mouse.y");
	var hvs = krpano().get("screentosphere("+mousex +","+mousey +")");
	var hva = hvs.split(",");

	var ath = Number( hva[0] );
	var atv = Number( hva[1] );

	krpano().call("moveto("+ ath +","+ atv +")");

	}

// ]]>
</script>

Add the xml file would be:

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
<!-- ***************** HOT SPOTS EDITOR  ********************** -->
	
	<contextmenu fullscreen="false">
		<item	name="coord_finder" 
				caption="Coordinates finder - ON" 	
				onclick="action(run_hs_editor); " 
				/>
	</contextmenu>
	
	<action name="run_hs_editor">
	
	copy(Back_onviewchange,events.onviewchange);
	copy(Back_onclick,events.onclick);
	
	set(events.onviewchange,action(buildtext););
	set(events.onclick,js(krpanodbclick(movetoscreentosphere())););	
	
	addplugin(hs_editor);
			set(plugin[hs_editor].url,%HTMLPATH%/images/cross.png);
			set(plugin[hs_editor].zorder,5);
			set(plugin[hs_editor].align,center);
			set(plugin[hs_editor].handcursor,false);
			set(plugin[hs_editor].keep,true);	
			
	addplugin(click);
			set(plugin[click].url,%HTMLPATH%/images/click.png);
			set(plugin[click].zorder,10);
			set(plugin[click].align,center);
			set(plugin[click].keep,true);	
			set(plugin[click].edge,topleft);	
			set(plugin[click].x,20);
			set(plugin[click].y,20);
			set(plugin[click].onclick,action(close_hs_editor););

	set(contextmenu.item[coord_finder].caption,Coordinates finder - OFF);
	set(contextmenu.item[coord_finder].onclick,action(close_hs_editor));
	
	action(buildtext);
	
	</action>
	
	<action name="close_hs_editor">
	
	set(events.onviewchange,get(Back_onviewchange));
	set(events.onclick,get(Back_onclick));
	
	removeplugin(hs_editor);				
	removeplugin(click);	
	removeplugin(hs_coordinates);

	set(contextmenu.item[coord_finder].caption,Coordinates finder - ON);
	set(contextmenu.item[coord_finder].onclick,action(run_hs_editor));
	
	</action>

	<data name="coordinates"></data>
	
	<action name="buildtext">
		
		mod(hdistance,get(view.hlookat),360);
		roundval(hdistance,0);
		set(vdistance,get(view.vlookat));
		roundval(vdistance,0);
		set(fovdistance,get(view.fov));
		roundval(fovdistance,0);

		txtadd(data[coordinates].content, get(hdistance), ' <br/> ', get(vdistance), ' <br/> ', get(fovdistance) );

		addplugin(hs_coordinates);
			set(plugin[hs_coordinates].url,%SWFPATH%/plugins/textfield.swf);
			set(plugin[hs_coordinates].html,data:coordinates);
			set(plugin[hs_coordinates].css,p{font-family:Arial;font-weight:bold;font-size:14;text-align:center;});
			set(plugin[hs_coordinates].width,40);
			set(plugin[hs_coordinates].height,50);
			set(plugin[hs_coordinates].zorder,11);
			set(plugin[hs_coordinates].background,false);
			set(plugin[hs_coordinates].align,center);
			set(plugin[hs_coordinates].x,135);
			set(plugin[hs_coordinates].y,45);
			set(plugin[hs_coordinates].keep,true);
	</action>


Some explanation of the xml...
changes for the contextmenu to make an Coordinates finder on/off :
line 5 -- changed the caption for the contextmenu item : Coordinates finder - ON
lines 35 -- setting the caption for the contextmenu item : Coordinates finder - OFF
lines 36 -- setting the onclick for the contextmenu item : action(close_hs_editor)
lines 51 -- setting the caption for the contextmenu item : Coordinates finder - ON
lines 52 -- setting the onclick for the contextmenu item : action(run_hs_editor)

changes inside the action(run_hs_editor):
lines 12 -- Back_onviewchange... a variable to retrieve the value of event onviewchange if already exist...
lines 13 -- Back_onclick... a variable to retrieve the value of event onclick if already exist...
lines 15 -- set the event onviewchange to call the action(buildtext); on each view change...
lines 16 -- set the event onclick to call the javascript js(krpanodbclick(movetoscreentosphere())); that simulate an ondoubleclick...
lines 33 -- change the onclick to close the Coordinates finder instead of display the coordinates...
lines 35,36 -- see above contextmenu
lines 38 -- caling the action(buildtext); to force displaying the coordinates at first...

Added a new action to close the Coordinates finder -- action(close_hs_editor):
line 44 -- set back the event onviewchange...
line 45 -- set back the event onclick...
lines 47-49 -- removing the plugings of the Coordinates finder
lines 51,52 -- see above contextmenu

OUF !!! That's all *smile* . I think all it's correct. Comments are welcome...

SAlut.

Tuur

Master

Posts: 2,356

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

15

Monday, December 14th 2009, 8:32pm

Like it !!

very nice!

Thanks!!

Tuur *thumbsup*

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

16

Monday, December 14th 2009, 9:25pm

Hi,

Thank you Tuur, the major merit is for Tourvista of course *thumbup* . I am just trying to improve the code and LEARN *attention* *smile* .

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

17

Monday, December 14th 2009, 10:47pm

Hi,

The code works correctly... but ;-) ....

There is a WARNING: using the xml code above: http://www.krpano.com/forum/wbb/index.ph…10173#post10173

Source code

1
WARNING: unknown action command: undefined


The problem appear when the onclick event is not defined at first...
line 45 try to redefine it back again and fails..

Source code

45
set(events.onclick,get(Back_onclick));


This does not happens with the onviewchange event ...

Source code

44
set(events.onviewchange,get(Back_onviewchange));


So, I do not understand why this happends with the onclick event...

I have noticed that when the events are not defined at first:
trace(events.onviewchange); ---> result on : null
trace(events.onclick); ---> result on : undefined

It seems the onviewchange event it is defined by default... then hi returns null...
but onclick event seems to not be defined by default and returns undefined....

I have tried many ways (IF...) to solve this WARNING without success...

KLAUS can you explain what is the problem and give a solution *question* *squint* Thank you in advance *thumbup*

SAlut.

18

Tuesday, December 15th 2009, 12:33am

KLAUS can you explain what is the problem and give a solution *question* *squint* Thank you in advance
Hi,

you're right!
the "onclick" event was not set to 'null' initially, but to the flash default 'undefined'...
(but that's not intended, in the next release it (and all other events) will be null at start)

with the krpano.swf from the tools 1.0.8 beta 9 you could fix
that warning for the moment for example with this check:

Source code

1
2
if(Back_onviewchange === undefined, set(Back_onviewchange,null));
if(Back_onclick === undefined, set(Back_onclick,null));


best regards,
Klaus

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

19

Tuesday, December 15th 2009, 12:43am

Hi Klaus,

Thank you *smile* === *thumbup*

I had tried:
if(events.onclick == undefined, set(Back_onclick,null));
and many others.... No one has worked. *g* *g* *g*

SAlut.

This post has been edited 1 times, last edit by "michel" (Dec 15th 2009, 2:41pm)


michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

20

Tuesday, December 15th 2009, 8:30pm

Hi Tourvista,

*thumbsup* great... your last edited DOWNLOAD and simple INSTALLATION process (UPDATED 15-12-2009 )... *thumbup*

Only one note: You have included the textfield.swf (to simplify the install I supose ;-) )... But I think you must notify the version you give!!! Because each version of Krpano needs his own version of plugins like the textfield.swf... KLAUS explains this somewhere but I am not able now to find where *sad* .

Also, you can add the following code after line 13 to avoid an WARNING on current versions of Krpano (see here )...

Source code

14
if(Back_onclick === undefined, set(Back_onclick,null));


If you are thinking in include a licence agreement, I will suggest this one ;-) : careware

SAlut. *smile*