You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, November 3rd 2014, 5:59pm

Getting scene name knowing scene.index

Is there a way to get scene name if you know the scene index parameter?

I have come to solution with looping through all scenes:

Source code

1
2
3
4
5
6
add(newsceneindex, scene[get(xml.scene)].index, %1);
for(set(i,0), i LT scene.count, inc(i), 
   if(scene[get(i)].index == newsceneindex, 
      set(newscenename, get(scene[get(i)].name)); 
   );
); 


But as it is supposed to run on every scene load when pressing next/previous buttons, i think it is pretty heavy algorithm.

Is there any easier way how to achieve this?

2

Monday, November 3rd 2014, 6:05pm

Yes, if for example 'your_variable' contains the index number (or the name of the scene) get it directly from here:

Source code

1
scene[get(your_variable)].name

3

Monday, November 3rd 2014, 6:57pm

Well, i guess i should explain more about the rest of the code.

  • In the tour i have some buttons which are meant as Categories.
  • Each scene has a parameter "group".
  • Scenes are scattered, like: scene[0].group = 'CAT1'; scene[1].group = 'CAT2'; scene[2].group = 'CAT1' ...
  • When pressing on a Category button, code filters all corresponding scenes and sets their scene.index consecutively starting from 0 to count of these scenes. The rest (other category) scene indexes are set to a number higher than total scene count not to interfere with anything.
  • Basically scene.index != scene[index] anymore.

So, knowing this,
i can not really set the variable let's say 'sequence' as correct scene[index] number and work with it because scenes are not in sequence.
Let's say, in category 'CAT1' there are scenes [0],[2],[14],[15],[17]. So, if the current scene is [0] and i press "NEXT", i need to move to the scene[2].

I was wondering maybe sorting scenes by groups could bring up to something,
but i'm having also an idea in the future that one scene could be in 2 groups (like variables 'group1' and 'group2'). In that case this solution wouldn't work..

I hope i did explain it understandable.

4

Monday, November 3rd 2014, 7:02pm

Isn't there something like GET scene.name WHERE scene.index = 1 ?

Umalo

Professional

Posts: 1,047

Location: Osijek, Croatia, EU

  • Send private message

5

Tuesday, November 4th 2014, 4:22pm

Don't have time to type you the code but generaly this is feasable:
- at start you need action that will make groups for you based on scene categories stored in some data structure
- than you need to iterate through indexes of grouped data

Cat 1
1 scene_real_index="3"
2 -||- 5
3 -||- 7

Cat 2
1 scene_real_index="1"
2 -||- 2
3 -||- 4
4 -||- 6
5 -||- 8

Try to make this on your own and come back with results. Should be not complicated.
Something similar you can find here. Not exactly but part of the code can be reused. Don't forget to use .count ;)
Link

6

Wednesday, November 5th 2014, 1:47pm

Thanks Umalo, but i can't really figure it out.

Let's say: Scene[ID] - ID should be unique, right?
In your example:

Cat 1
1 scene_real_index="3"
2 -||- 5
3 -||- 7

Cat 2
1 scene_real_index="1"
2 -||- 2
3 -||- 4
4 -||- 6
5 -||- 8"

i understand these IDs are not unique.

My next_scene action now looks like this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<action name="skin_nextscene">
   add(newsceneindex, scene[get(xml.scene)].index, %1);
   for(set(i,0), i LT scene.count, inc(i),
      if(scene[get(i)].index == newsceneindex,
         set(newscenename, get(scene[get(i)].name));
      );
   );
   if(newsceneindex GE 0,
      if(newsceneindex LT scenecount,
         txtadd(layer[skin_thumbborder].parent, 'skin_thumb_', get(newsceneindex));
         layer[skin_thumbs].scrolltocenter(get(scene[get(newscenename)].thumbx), get(scene[get(newscenename)].thumby));
         loadscene(get(newscenename),null,get(skin_settings.loadscene_flags),get(skin_settings.loadscene_blend));
      );
   );
</action>

Umalo

Professional

Posts: 1,047

Location: Osijek, Croatia, EU

  • Send private message

7

Wednesday, November 5th 2014, 1:58pm

ah, now going in next dimension listing category based thumbs is completely different story but can relate to my proposal.
You would than need to recreate thumbs on scroll area whenever active category is changed.
Best would be you send me your code on mail and I will give you my proposal directly in the code but can't promise instant response due to other projects. How urgent this is for you?