You are not logged in.

1

Saturday, November 6th 2021, 8:38pm

Problem with loading new pano from xml

Hello everyone!

I'm building a virtual tour that loads different panos with a button.
I have a few different xml files with different scenes in them.
I'm using the loadpano(); and loadpanoscene(); actions and I load the xml files just fine, except the thumbnails don't update correctly.
If I load 01.xml there are 2 thumbnails (as there are 2 scenes in it), and 02.xml has 4 thumb (4 scenes in it).
If I then go back to 01.xml, there are 4 thumbs now (2 of them work, and 2 don't- they are the third and forth from 02.xml)

I tried to search the forums with little success.

I tried using : loadpano(%1,null,REMOVESCENES); and skin_startup();

Is there any action I should try or should I edit anything in the vtourskin.xml ?

Any help is appreciated!
Thanks in advance!

2

Saturday, November 6th 2021, 8:59pm

i guess you're using the vtourskin.xml, the thumbs are initialized there.
but vtourskin.xml is not expecting you to tamper with xml loading and changing the amount of scenes ;) ...
you need to check and combine your work with the code in vtourskin.xml

3

Saturday, November 6th 2021, 9:00pm

... the easiest solution is probably to create separate tours and load them by loading a different url
or.. try to delete the unused scenes before loading the new xml....

https://krpano.com/docu/actions/#array.removearrayitem

4

Saturday, November 6th 2021, 10:13pm

Hey indexofrefraction,
thank you for your replay!

I realize that I need to alter the vtourskin.xml, but I can't really follow the actions and what they do.

I guess loading different urls could work, but I think it should be possible without it. I have a lot of floors to do, and it would take too much time creating the new urls. Plus it would load much slower, I think.

I will try to delete the old scenes as you suggested, but just need to figure out how before that.

Most of all I would like to figure out how to fix the vtourskin.xml.

I will post my results later.

5

Saturday, November 6th 2021, 10:29pm

scene.removearrayitem(your_scene_name);

or.. for all scenes something like this should work ...

for(,scene.count,,scene.removearrayitem(0));

then load your xml with the scene definitions...
vtourskin.xml skin_startup() reinitializes things, but that should work automatically i think

This post has been edited 1 times, last edit by "indexofrefraction" (Nov 6th 2021, 10:43pm)


6

Saturday, November 6th 2021, 10:40pm

yes, I tried that one (scene.removearrayitem(scene_03);), but its not working. I think the removescenes flag should be doing exactly that.
That leads me to think that the problem is with the scene.count variable. I'm not sure how to debug it and test its value in runtime. Will investigate that next.

ps. if I set it to 2 in the for loop, it creates only two panos, as expected.

Source code

1
for(set(i,0), i LT scene.count, inc(i),calc(thumbname, 'skin_thumb_' + i);	addlayer(get(thumbname));


I guess something in the action skin_addthumbs needs to change to implement the dynamic change of the number of thumbnails.

7

Saturday, November 6th 2021, 10:45pm

REMOVESCENES flag --> ok, right...
maybe you simply need to clear/empty thumbarray ..
see skin_addthumbs()

8

Saturday, November 6th 2021, 10:47pm

I had an idea. Not sure how to implement it yet and will research it further, but I think my problem is not with the scenes, but with the thumbs. I don't need to delete the scenes, because there actually aren't more scenes than I need, just more thumbs (the additional thumbs don't work. They give a null).

PS. Just saw your replay. Will check it, yes.

9

Saturday, November 6th 2021, 11:22pm

Okey I tried removelayer(skin_thumbs, removechildren); in an action within my main xml. I tried adding it to the beginning of skin_addthumbs action as well. Not working.
Tried removearray(thumbnails); and set(thumbnails.count,0); in both places.( I found those in an old thread from 2011)
Still not working. I'm kind of stuck on how to delete the current thumbs, and still be able to add new ones when I change the xml.

10

Saturday, November 6th 2021, 11:50pm

a) to my knowing there is no removearray() action
b) there is no array "thumbnails" ...

try delete(thumbarray);
and also remove all thumb layers (named "skin_thumb_" + number)

i would add all of that at the beginning of skin_addthumbs()
so that it clears out everything before it creates the thumbs

but there are maybe also other things to consider
vtourskin does not support changes in the scene amount

11

Sunday, November 7th 2021, 10:09am

Hey indexofrefraction
Well I got those from here: https://krpano.com/forum/wbb/index.php?p…31620#post31620
but as I said its a post from 2011, so it quite old.

I will try the methods you suggested and let you know if there is any success.
The other thing I will try is to add a custom identifier to the layers on creation and delete all layers having that identifier later.
Just need to find the forum thread that I read yesterday :)

Many thanks,
Martin

12

Sunday, November 7th 2021, 12:21pm

that post is from 2011 and removearray is not in the documentation...
you have to test if that action exists but delete(some_array); does work.
thumbnails is just an example from a post in this thread, it has nothing to do with the vtourskin.

try this :

Source code

1
2
3
4
5
6
7
8
9
<action name="skin_addthumbs" scope="local">
	delete(global.thumbarray);
	for(set(i,0), i LT layer.count, inc(i),
		if(calc(indexof(layer[get(i)].name, 'skin_thumb_') == 0),
			removelayer(get(layer[get(i)].name));
			dec(i);
		);
	);
	...

This post has been edited 5 times, last edit by "indexofrefraction" (Nov 7th 2021, 12:38pm)


13

Sunday, November 7th 2021, 2:33pm

Hey indexofrefraction,
thanks again for your help.

The commands from the 2011 thread don't work, I did some tests.
I managed to find a post on the forums that gave me the idea to add a custom attribute to the automatically generated layers of the thumbnails, and then test for it and delete if true.
I figured out how to test it with the console. I made it trace the values of layer.count and scene.count before and after I load a new xml.
After that I made it even trace all the names of the layers on the screen.

I think I managed to delete the layers that are generated with skin_addthumbs using my custom attribute.

Source code

1
2
3
4
		for(set(i,0), i LT layer.count, inc(i),
			if(layer[get(i)].category==thumbs,
			removelayer(layer[get(i)].name,removechildren);				)
		);



This lowers the count of layer.count, but the thumbnails are still there. I tried to delete them from the last index layer, because in the documentation it says:
Not sure if this is relevant to me. Nevertheless it didn't work.
Now I will try and inspect all layers on screen and see what I'm not deleting.

I will keep you updated.

Many thanks,
Martin

14

Sunday, November 7th 2021, 2:51pm

sorry, your code has errors... remove() needs a get() for the name, after removing you need a dec(i)
see above .. no custom tag needed... *whistling*

This post has been edited 1 times, last edit by "indexofrefraction" (Nov 7th 2021, 3:06pm)


15

Sunday, November 7th 2021, 5:41pm

Hey indexofrefraction,

I didn't have the time to test your code earlier and just told you what I had done.
In fact your code works just perfect. I'm trying to wrap my head around what it actually does.
Can't figure out what delete(global.thumbarray); does. I kind of figured out the rest.

Either way it works and again thank you so much for the help.

Ps. I need to delete the layers with the text of the thumbnails, but I think I can manage to use your code as a guide and do that myself.

16

Sunday, November 7th 2021, 5:55pm

the global thumbarray is initialized in skin_addthumbs() and used in other places as well i think
delete(global.thumbarray); just deletes / clears the variable to have a clean slate

17

Sunday, November 7th 2021, 7:39pm

Well I didn't find it anywhere in the vtourskin.xml code.
It works without it, but I will leave it just in case. It sounds good to clear this variable, if it exists.

I added another check for the the skin_thumbtext and it's all working like a charm. I think. *g*


Many thanks,
Martin

18

Sunday, November 7th 2021, 7:53pm

krpano 1.20.9 vtourskin.xml uses thumbarray in many places
...
anyway glad we made it work *squint*

This post has been edited 1 times, last edit by "indexofrefraction" (Nov 7th 2021, 8:51pm)


19

Monday, November 8th 2021, 7:54am

Ah cool. I'm using 1.20.2 for some reason. Might update soon.