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

Saturday, April 25th 2020, 1:56pm

Random hotspot

Is there any way that, whenever a scene is entered, a hotspot will randomly change its position? (x, or y or both)
And that it was kept in a margin of positions x, y predetermined?

Sergey74

Intermediate

Posts: 172

Location: Russia, Chelyabinsk

Occupation: professional noob

  • Send private message

2

Saturday, April 25th 2020, 5:44pm

Of course. There is an action for this random
Only it should be ath, atv
translation difficulties *huh*

San7

Intermediate

Posts: 321

Occupation: coding in krpano

  • Send private message

3

Saturday, April 25th 2020, 6:27pm

Here is an example, in onstart, define the limits for x and y

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<action name="startup" autorun="onstart">
	...
	set(Xmax,500);
	set(Xmin,200);
	set(Ymax,500);
	set(Ymin,200);
</action>

<scene name="scene_1"  onstart="delayedcall(0.1,test());" ...

<hotspot  name="spot" type="text" width="20.00" height="20.00" edge="center" 
	  bgcolor="0xFF0000" bgalpha="1" bgroundedge="10 10 10 10" /> 
					 
  <action name="test" >
	mul(valX, random, Xmax);
	if(valX LE Xmin, test(); , 
	         mul(valY, random, Ymax);
	         if(valY LE Ymin,test();  
		                 ,
		                  screentosphere(valX,valY, toh, tov);
		                  set(hotspot[spot].ath, get(toh));
		                  set(hotspot[spot].atv, get(tov));
	           );	
	   );
  </action>		
</scene>

This post has been edited 3 times, last edit by "San7" (Apr 25th 2020, 6:44pm)


San7

Intermediate

Posts: 321

Occupation: coding in krpano

  • Send private message

4

Saturday, April 25th 2020, 8:22pm

Or such an option

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<scene name="scene_1"  onstart="delayedcall(0.1,test(500,50,100,50));" ...

<hotspot  name="spot" type="text" width="20.00" height="20.00" bgcolor="0xFF0000" /> 
<!--  test(X max,X min,Y max,Y min); -->			 
<action name="test" scope="localonly" args="Xmax, Xmin, Ymax, Ymin">
	mul(valX, global.random, get(Xmax));
	mul(valY, global.random, get(Ymax));
	if(valX LE Xmin, test(get(Xmax), get(Xmin), get(Ymax), get(Ymin));
			, 
			 if(valY LE Ymin, test(get(Xmax), get(Xmin), get(Ymax), get(Ymin));
					 ,
					  screentosphere(valX,valY, global.hotspot[spot].ath, global.hotspot[spot].atv);
			 );	
		);
</action>	

This post has been edited 2 times, last edit by "San7" (Apr 26th 2020, 3:12pm)


5

Sunday, April 26th 2020, 7:20pm

It works for me in part

Thank you.
The first option does work for me, but I don't understand the maximum or minimum values, if they are around the initial position of the hotspot and in which units they are expressed in the startup.
The second option doesn't work for me. You may not have understood correctly ;-(

6

Sunday, April 26th 2020, 7:25pm

Sergey, I don't understand how to implement it

Thanks Sergey.
The problem is that I don't know how to incorporate this into a hotspot of the type: <hotspot name = "detail1038" handcursor = "true" distorted = "true" onclick = ""
url = "imag_escape / detail1038.jpg" scale = "0.1" ath = "0"
atv = "0" />

San7

Intermediate

Posts: 321

Occupation: coding in krpano

  • Send private message

7

Sunday, April 26th 2020, 8:19pm

And that it was kept in a margin of positions x, y predetermined?
These are your set conditions, which means a rectangular area of ​​screen coordinates, within which a hot spot should be located. And this rectangle is described by the maximum and minimum values ​​of x and y
The first option does work for me, but I don't understand the maximum or minimum values, if they are around the initial position of the hotspot and in which units they are expressed in the startup.
The second option doesn't work for me. You may not have understood correctly ;-(
I checked both options before posting - both workers. Hotspot changes its position each time it enters the scene within the described area in screen coordinates.