How to change an attribute of depthmap-elements?

  • Hi
    I try to modify the attribute of depthmap-elements.
    To get all style-elements I can loop through them by doing something like this:

    Code
    for(set(i,0), i LT style.count, inc(i),
    style[get(i)].atribute = value;	
    );

    But for depthmap-elements this does not work.

    How can I manipulate attributes of depthmap-elements?

    Kind regards
    Alain

  • I found the solution.

    Code
    /*copy the center-attribute-value to every scene.image.depthmap*/
     for(set(i,0), i LT scene.count, inc(i),
     copy(sc, scene[get(i)]);
     txtsplit(get(camera_coordinates[get(i)].value),',', coordinates_per_camera);
     set(centerdata, calc(coordinates_per_camera[2].value*-1 + ',' + coordinates_per_camera[1].value + ',' + coordinates_per_camera[0].value));
     copy(sc.image.depthmap.center, centerdata);
     trace('depthmap center:', sc.image.depthmap.center);
     trace('scene 0:', scene[1].image.depthmap.center);
    );

    A scene-element looks like this:

    The value of the center-attribut in the depthmap-element looks correct when I trace it.
    But when I click to the next scene the depthmap-position is not correct (but also here, tracing the caller.linkedscene-object after the click, outputs the correct value).
    Only when I hardcode the center-attribute-value then the depthmap-position is correct.

    Any idea what I do wrong?

    Edited once, last by Alain (November 19, 2020 at 6:01 PM).

  • this is a misunderstanding of how krpano works
    you can NOT access or set other scenes content like this

    e.g. if you are in scene 0 ...
    you can access attributes of other <scene> elements like :
    trace(scene[1].name);
    but you can NOT access xml elements inside other <scene> elements :
    trace(scene[1].image.depthmap.center); <--- NOPE

    processing all scenes in advance in the way you're trying is not possible
    it would be possible by altering the scenes content attribute, but then you have do your own xml parsing.
    maybe something like this might be an easier solution :

    Code
    <events name="set_depthmap_center" onnewscene="set_depthmap_center" keep="true" />
    <action name="set_depthmap_center">
        calc(i, scene[get(xml.scene)].index);
        trace('scene index = ', i);
        txtsplit(get(camera_coordinates[get(i)].value), ',', coordinates_per_camera);
        calc(image.depthmap.center, coordinates_per_camera[2].value*-1 + ',' + coordinates_per_camera[1].value + ',' + coordinates_per_camera[0].value);
        trace('depthmap center = ', image.depthmap.center);
    </action>

Participate now!

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