• 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?

  • 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.:

    Code
    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

  • Hi,

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

    Code
    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:

    Code
    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

  • Hi,

    your first attempt looks very good:

    Code
    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

  • The problem with this code

    Code
    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:

    Code
    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.

  • Quote

    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

  • 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.

  • 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


    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:

    Code
    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.

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

    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

  • 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

  • Code
    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.

  • 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:


    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.

  • 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*

  • ms_entrance1 plugin looks like this:

    Code
    <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:

    Code
    <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.

  • 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...

    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...

    Code
    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.

  • 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.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!