Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Montag, 19. Januar 2009, 23:36

set() with get()

Hi,

I am using the tour example provided with krpano and there is map plugin that uses some map points. In this example, when loading a panorama these actions are performed:
set(plugin[spotx].x,165);
set(plugin[spotx].y,71);
set(plugin[radar].x,165);
set(plugin[radar].y,71);
This code is then copy-pasted and adapted to match the coordinates of each point of the map.

Instead, I would like to do something like this:
set(plugin[spotx].x,get(plugin[spot1].x));
set(plugin[spotx].y,get(plugin[spot1].y));
set(plugin[radar].x,get(plugin[spot1].x));
set(plugin[radar].y,get(plugin[spot1].y));

This way, the values for the map spots are hard coded in only one place and I don't have to run all over the code if i want to change the location of one spot.

Unfortunately, it doesn't seem to work.
Any help please?

2

Dienstag, 20. Januar 2009, 20:28

Hi,

I'm currently working on this feature
at the moment I'm thinking about the best syntax for this,
the get() looks very good,

but I'm also thinking about a using only one special character
like &, $ or # for the direct variable access, because it should
be possible to use it everywhere, and using only one character
would keep the code more compact,

e.g.:

Quellcode

1
2
3
4
set(a, $b);
tween(a, &dest, &time);
loadpano(#pano1);
lookto(get(hotspot[h1].ath), get(hotspot[h1].atv), 50);


but the get() looks also very good,
any good ideas/suggestions, what would be the best?

best regards,
Klaus

3

Dienstag, 20. Januar 2009, 22:55

Hi,

To be honest, my first attempt was to put nothing.. something like this:

Quellcode

1
set(plugin[spotx].x,plugin[spot1].x);

I think this best resembles a variable behavior.

When this didn't work, I said ok.. maybe it's a function somewhere. Obviously... my first choice was get() ... since there is a set() *smile*
So i did this:

Quellcode

1
set(plugin[spotx].x,get(plugin[spot1].x));


When this didn't work either... i looked at the documentation online and then got to the forum.

Personally, I dislike the $ approach...it reminds me of PHP *g*
& will confuse any C/C++ coder *tongue*
The disadvantage I see from using only one character to address the variable is that although the code is more compact, it becomes more difficult to read... especially for a new person. Everybody figures out what set() and get() would do.. but I don't know how many would figure out that $, # or & does. They would finally get it... but not instantly.


So... I would go for the first method or the second. Compact code is not always easy

4

Mittwoch, 21. Januar 2009, 20:08

Hi,

your first attempt looks very good:

Quellcode

1
set(plugin[spotx].x,plugin[spot1].x);


simple and good
but then it would not be possible to set just the name of a
variable to other value...

at the moment I'm not sure if setting the name is necessary at all?
or if it could be a problem??

I'll think about this!
because this could be the best solution

best regards,
Klaus

5

Mittwoch, 21. Januar 2009, 20:17

The problem with this code

Quellcode

1
set(plugin[spotx].x,plugin[spot1].x);

is that you cannot know if you want to set plugin[spotx].x to the value of plugin[spot1].x or to the string "plugin[spot1].x".
In this case is clear, but there might be some situations where you cannot decide how to parse the xml (try and find the value of the variable, or just set to the given text).

I think this is maybe because strings are not contained between " ". I was VERY surprised reading my first xml and seeing that there are no "".
I'm not sure what happens if i try to do this for example:

Quellcode

1
showtext(This is a comma test, I hope it works)

Will this treat "I hope it works" as a second parameter to the action showtext?
I think putting strings between " " solves a lot of syntax problems but then again this could lead to some serious backwards compatibility issues.

6

Mittwoch, 21. Januar 2009, 20:46

Zitat

but there might be some situations where you cannot decide how to parse the xml
I know, but I'm not sure if there such situations exists at all...

It could work in this way:
1. check the internal datastructure (xml) for the variable
2. if it wasn't found it uses it as string

I didn't used " " for parameters in the beginning, because everything in the
xml is string, the " " made problems with the xml format, e.g. when using it in a attribute
which is also scoped with " " (I know using a single quote ' ' could solve it)

I think I will also add the possibility to use " " or ' ' for parameters
to mark them as string, then everything is be possible

about - backwards compatibility - if this will be a problem (needed be checked)
I can make this "feature" only available when "version" is set to "1.0.8" or a higher value,

best regards,
Klaus

7

Mittwoch, 21. Januar 2009, 22:25

I know, but I'm not sure if there such situations exists at all...
Well... there could be if you have some variable name and you actually want to send a string equal to the variable name. I know these are rare cases and can be easily avoided, but they can happen.

I agree on the problem with the xml format and " ". It's pretty tricky.

8

Freitag, 23. Januar 2009, 14:46

Great news!

Great news for me and possibly everybody *smile*
I found a way to do what I originally planned: eliminate the hard coding of map spots coordinates x and y

This is the magic load function in my virtual tour

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
   	<action name="load_generic">
    	push(plugin[ms_%1].x);
    	push(plugin[ms_%1].x);
    	pop(plugin[spotx].x);
    	pop(plugin[radar].x);        	
    	
    	push(plugin[ms_%1].y);
    	push(plugin[ms_%1].y);
    	pop(plugin[spotx].y);
    	pop(plugin[radar].y);
                   			
		loadpano(panos/%1.xml,null,MERGE,BLEND(2));	
		set(plugin[radar].heading,%2);
	</action>

It takes 2 parameters, one is a name of the new panorama and the second is a heading for the radar.

As you can see, i am using the stack to transfer values from one plugin to the other plugin. In this case I transfer the coordinates of the panorama map spot to the spotx and radar plugins.

An example of this action call is:

Quellcode

1
action(load_generic, entrance1, 0);

For this to work, I must have coherent names for my map spots and xml files. So in this case I have a panos/entrance1.xml to define that panorama and a ms_entrance1 for my map ("ms" means map spot).

This is much easier than having to set the spotx and radar locations by hand for each panorama.
Most likely I will never have to change the name of my map spot or panorama xml, but I am sure I have to change the locations.

9

Samstag, 24. Januar 2009, 16:20

problems with push/pop?

There seem to be some problems with push/pop.
I am using these actions to move from one panorama to the next one smoothly.

Quellcode

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
<action name="moveto_facility">
	action(startloading);
	looktohotspot(hs_facility, 10);
	action(load_generic, facility, 0);
	lookat(-123.43,5.24,10);
	wait(blend);
	oninterrupt(action(lookinterrupt));
	lookto(-123.43,5.24,60,smooth(50,50,50));
	action(loadingdone);
</action>

<action name="load_generic">    
	action(update_map, %1, %2);
	loadpano(panos/%1.xml,null,MERGE,BLEND(2));   
</action>

<!-- This action updates the location of the spotx and radar -->
<action name="update_map">
	   push(plugin[ms_%1].x);
	pop(plugin[spotx].x);
	push(plugin[ms_%1].y);
	pop(plugin[spotx].y);
    
	   push(plugin[ms_%1].x);
	pop(plugin[radar].x);        
	push(plugin[ms_%1].y);
	pop(plugin[radar].y);
    
	set(plugin[radar].heading,%2);                   
</action>


The normal stages of the transition should be:
1. Zoom In
2. Load the new panorama
3. Blend
4. Zoom Out

When i put action(update_map, %1, %2) in load_generic i get this:
1. Zoom In
2. Start loading
3. Blend AND Zoom Out simultaneously
It's like wait(blend) is being skipped.

I have tried several locations to call update map and the only place that didn't affect my transition is to put it at the end of the moveto_facility action. I know this is a solution, but I am interested about the reason why calling update_map in load_generic doesn't work.

I am using krpano 1.0.7
PS: Sorry for these long posts

10

Montag, 26. Januar 2009, 13:02

Hi,

when you put "action(update_map, %1, %2)" in load_generic it doesn't work?
and when you remove it, it worked?

hmm, sorry, I have no idea at the moment, I need to test that...
do you have the same behavior with the version 1.0.8 beta 5?

best regards,
Klaus

11

Montag, 26. Januar 2009, 13:55

Quellcode

1
2
 when you put "action(update_map, %1, %2)" in load_generic it doesn't work?
 and when you remove it, it worked?


Exactly. It behaved the same with version. 1.08b5.
I was as surprised as you are, they just don't seem to be related (push/pop with wait().
One other guess i have... how to you treat errors. Perhaps push/pop generate an exception and somehow it is caught at the wait(). I don't know... but i'll keep testing.

12

Mittwoch, 28. Januar 2009, 17:04

Today i had some free time and played with krpano again.

Regarding the push/pop problem with wait(blend), to see where the problem is i commented the entire update_map action content and started adding line by line and see when the behavior begins to fail.

Currently my update_map action is this:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
	<action name="update_map">
    	push(plugin[ms_%1].x);
    	pop(plugin[spotx].x);
    	push(plugin[ms_%1].y);
    	<!--
    	pop(plugin[spotx].y);
    	
    	push(plugin[ms_%1].x);
    	pop(plugin[radar].x);        	
    	push(plugin[ms_%1].y);
    	pop(plugin[radar].y);    	
    	-->
    	
		set(plugin[radar].heading,%2);                   			
	</action>

With this action, the behavior is still correct (it waits to blend the new panorama before starting the lookto).

If i add the next line ( pop(plugin[spotx].y); ) the behavior suddenly changes as in my previous posts (wait(blend) doesn't actually wait).
It doesn't matter where I am popping the value from the stack, the problem is that I do a second pop. I tested it by replacing in my code above the line pop(plugin[spotx].x) with pop(plugin[spotx].y) and it kept working.

So it's not a problem of where/what i am popping, but the fact that i do 2 pops.

I also tried keeping a single push/pop per action .. i though maybe there is a limit somewhere.. but it didn't to the trick.

Anyway, Klaus, i thought maybe a bug tracker would be a great ideea to add especially now that you are developing 1.0.8 and are in the beta phase.

13

Donnerstag, 29. Januar 2009, 19:49

Hi,

you're right! the pop() is buggy!
I found and fixed the bug now, it will be okay in the next beta release (should be ready soon),
thanks for helping and thanks for idea for a bug tracker!

best regards,
Klaus

14

Donnerstag, 29. Januar 2009, 22:45

This is really good news... I can hardly wait for the next beta.

For a bug tracker, i can recommend http://www.mantisbt.org/
I'm using it for my personal projects and I find it pretty good.

LaterEdit: Oh, and it's free :)

15

Montag, 2. Februar 2009, 10:40

Thanks!
I'll check it!

Graydon

Profi

Beiträge: 614

Wohnort: Texas

Beruf: Industrial gas turbine services.

  • Nachricht senden

16

Montag, 9. Februar 2009, 02:30

needing help following push / pop example here

I was trying to follow the push/pop example and am having some trouble understanding some aspects of it...

where is plugin[ms_entrance1] located and how does it look?

I think I understand the data flow to / from the stack...
- push the x value of ms_entrance1 to stack
- pop the value from stack back into spotx.x
- push the y value from ms_entrance1 to stack
- pop the value from stack back into spotx.y

I'm assuming that this is being used in the case where you are loading a map as a plugin image... and thus are placing spots on the map like this example... http://www.krpano.com/examples/tour/tour.xml

... but could something be done like this using the google maps plugin... when the map points are subnodes?

Hopefully the questions are clear... if not, I'll try to refine them. *confused*

17

Montag, 9. Februar 2009, 10:51

ms_entrance1 plugin looks like this:

Quellcode

1
2
3
4
5
6
	<plugin name="ms_entrance1" 
			x="130" y="195" 
			onhover="showtext(Entrance);" 
			onclick="action(load_generic, entrance1, 0);" 
        	keep="true" 
			url="mappoint.png" zorder="2" align="righttop" edge="center"/>

As you can see it looks like the one defined in the tour example. It simply puts the image mappoint.png somewhere over my map.
The map is also a plugin (png image) loaded like in the tour example. It looks like this:

Quellcode

1
2
3
4
5
6
7
8
9
	<plugin name="map"   url="ea_map.png" zorder="1" align="righttop" edge="righttop" 
        	x="16"  y="16" alpha="0.7" 
        	handcursor="true"
        	keep="true" 
        	width="739" 
        	height="258"
        	onhover="showtext(Close Map,smalltext);" 
        	onclick="action(closemap);"
        	/>


I am using the push/pop functions because this the only way i found to transfer the X and Y from ms_entrance1 to the radar and spotx plugins.

The googlemaps plugin is not free. Besides, it works better for me to have an image as a map background.
For example, for indoor virtual tours it's best to have a schematic that i have made instead of some google satellite images.

Graydon

Profi

Beiträge: 614

Wohnort: Texas

Beruf: Industrial gas turbine services.

  • Nachricht senden

18

Montag, 9. Februar 2009, 18:18

OK, I understand now what you are doing... seeing that and re-reading your initial post...

you are wanting to avoid having to do this...

Quellcode

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
<action name="load1">

		set(plugin[spotx].x,293);
		set(plugin[spotx].y,87);
		set(plugin[radar].x,293);
		set(plugin[radar].y,87);
		loadpano(1.xml,null,KEEPALL,BLEND(2));
		set(plugin[radar].heading,10);
	
</action>
−
<action name="load2">

		set(plugin[spotx].x,165);
		set(plugin[spotx].y,71);
		set(plugin[radar].x,165);
		set(plugin[radar].y,71);
		loadpano(2.xml,null,KEEPALL,BLEND(2));
		set(plugin[radar].heading,2);
	
</action>
−
<action name="load3">

		set(plugin[spotx].x,135);
		set(plugin[spotx].y,73);
		set(plugin[radar].x,135);
		set(plugin[radar].y,73);
		loadpano(3.xml,null,KEEPALL,BLEND(2));
		set(plugin[radar].heading,180);
	
</action>
−
<action name="load4">

		set(plugin[spotx].x,96);
		set(plugin[spotx].y,101);
		set(plugin[radar].x,96);
		set(plugin[radar].y,101);
		set(radar.heading,270);
		loadpano(4.xml,null,KEEPALL,BLEND(2));
		set(plugin[radar].heading,98);
	
</action>


too bad there's not a way to setup a map plugin that uses an image instead of googlemap... and lets you use the same type of spots subnode structure along with the "pantospot" and "activatespot" syntax.

Only other possible solution that I see right now would be to pass your x and y values through as additional variables in your onclick function...

Quellcode

1
onclick="action(load_generic, entrance1, 0, 130, 195);"


You would still be listing the values twice... but at least they'd be in the same plugin.

19

Montag, 9. Februar 2009, 23:07

Hey... you just read my mind :)

I plan on writing my own map plugin that would essentially incorporate everything that i do manually (radar, active spot, many map spots, etc).
Unfortunately i'm still in the phase of figuring out how to use flash... but i'm getting there.
As soon as I have a first version i will post it somewhere around here.