Get / Set Nested Variables

  • Hi all

    I'm trying to get and set variables that are nested.

    I can do this in this instance:

    Code
    <level_1 name="pano66">
    	<level_2a id="pano66_level_2a" h="0.1" v="-0.1394" fov="0.3984" limitview="limitrange" maxpixelzoom="1.0" transition="smooth(0.5, 0.8, 20)" />
    	<lavel_2b id="pano66_level_2b" h="0.0" v="0.0" fov="1.0" fovmax="1.0" />
    </level_2>

    thus get(level_1[pano66].level_2a.id) returns "pano66_level_2a"
    and get(level_1[pano66].level_2a.limitview) returns "limitrange"
    and get(level_1[pano66].level_2b.id) returns "pano66_level_2b"

    which is what I expect, and is OK.

    Here is an example of what I'm trying to access (generated by a well known tour generator) :

    I can access variables at the <scene> level with this
    get(scene[pano66].titleid) returns "pano66_title" which is fine.

    When I try to access variables at the <view>, or <panoview> levels, I get a "null" value - for example
    get(scene[pano66].view.limitrange returns "null" instead of "range"
    and
    get(scene[pano66].panoview.fovmax returns "null" instead of "90".

    Any ideas how to get and set these values??

    Regards

  • Hi) here's your "scene" settings (they are placed within <scene ... > )

    Code
    <scene name="pano66"
    ...
    titleid="pano66_title"
       	descriptionid="pano66_description"
       	multires="true"
       	planar="true"
       	full360="false">

    all these are get via "get(scene[pano66].YOURSETTING);"

    "panoview" is an additional set of settings and I bet it will be parsed only when the scene is loaded (the same as with "view" settings and everything else which is contained within the <scene>... > ... </scene>). To get "panoview" settings of the current scene just call, for example,

    Code
    get(panoview.fovmax);

    Regards,

    Alexey

  • To get various "panoview" settings of different (not omly the currently loaded) scenes, just move all what is inside <panoview .., /> into the <scene ... >

    E.g.

    Code
    <scene name="scene_panorama_12" title="panorama_12" onstart="" thumburl="panos/panorama_12.tiles/thumb.jpg" titleid="pano66_title"
       	descriptionid="pano66_description"	multires="true" planar="true"
       	full360="false" lat="" lng="" heading=""
    	h="0.0000" v="-0.1394" fov="0.3984" hmin="-0.5" hmax="0.5" vmin="-1.0526" vmax="1.0526" fovmax="90"
        >

    and

    Code
    showlog();trace(scene[scene_panorama_12].v);

    will return the needed value

    Regards,

    Alexey

  • Thanks Alexey

    That's exactly what is happening.

    The tours are generated with PanoTour and need tweaking as PTP 2.1.3 lacks some functionality and customisation features - especially around flat partial panos and individually timed transitions.

    What I'm trying to do is to minimise the amount of intervention on the PTP generated xml by injecting a new set of parameters for each tour after the initial xml is loaded. The idea is to create an xml file that will be included and will hold an set of arrays - one for each scene with the same scene name and the replacement values. This is used in conjunction with another xml include file that contains custom actions. So, overall the amount of modding on the PTP generated xml is kept to a minimum and can be standardised / templated. An extension of this is to inject the customised parameters from a database.

    As PTP generates nested nodes (eg <scene ....> <panoview... /> </scene>) I need to be able to access these. But, as you say, these seem to be unavailable to the get / set functions before when the scene's xml has been loaded and parsed. They are definitely writeable once the scene's xml has been loaded. They are, however, visible with a get(scene[pano66].content) before loading.

    This could be a nice route to try - rather than injecting the parameters as a one-shot after initialisation, the parameters could be changed via the onxmlcomplete event when they are exposed to the get / set functions. If combined with a database it waould also allow near realtime tweaking of scenes and transitions.

    Thanks again for rounding out the idea.

    Regards

    Jean-Paul

  • Hi,

    please see here:
    https://krpano.com/docu/xml/#scene

    The content of the <scene> elements will not be parsed/resolved until the scene itself will be loaded. The <scene> is like an inline storage for xml files. The whole content inside the <scene>...</scene> is available as string via scene[name].content. That means access to the xml structures inside the <scene> elements is not possible.

    Best regards,
    Klaus

Participate now!

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