You are not logged in.

1

Thursday, November 19th 2020, 3:28pm

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:

Source code

1
2
3
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

2

Thursday, November 19th 2020, 5:49pm

I found the solution.

Source code

1
2
3
4
5
6
7
8
9
/*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:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<scene name="scene_01_MoebliertCamera_003_Panorama_1" autoload="false" title="01_MoebliertCamera.003_Panorama_1" onstart="" thumburl="panos/01_MoebliertCamera_003_Panorama_1.tiles/thumb.jpg">

 <view hlookat="0.0" vlookat="0.0" fovtype="MFOV" fov="120" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />

 <preview url="panos/01_MoebliertCamera_003_Panorama_1.tiles/preview.jpg" />

 <image style="hotspot_style_01_MoebliertCamera_003_Panorama_1">

 <cube url="panos/01_MoebliertCamera_003_Panorama_1.tiles/%s/l%l/%v/l%l_%s_%v_%h.jpg" multires="512,640,1152,2304" />
 <depthmap style="depthmapsettings" />
 </image>

 </scene>


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?

This post has been edited 1 times, last edit by "Alain" (Nov 19th 2020, 6:01pm)


3

Thursday, November 19th 2020, 7:00pm

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 :

Source code

1
2
3
4
5
6
7
8
<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>

This post has been edited 10 times, last edit by "indexofrefraction" (Nov 19th 2020, 7:20pm)


4

Friday, November 20th 2020, 8:48am

Thanks alot for your quick reply!
It works! You are my hero of the day! *thumbsup*

Kind regards
Alain