Sie sind nicht angemeldet.

Tuur

Erleuchteter

  • »Tuur« ist der Autor dieses Themas

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

1

Montag, 9. Mai 2022, 16:38

Hotspot visible in screen

Hi,

I was wondering if there is an 'easy' way to 'know' if a hotspot is in the range of the screen and so visible.
Imagine when ath = 0 and we look to 170 the hotspot is invisible.
Is there a way to know or check if a hotspot is in the 'viewing range' ? Taking in mind the view.fov etc..
Obviously I could make an uneducated guess in degrees.. but I am out for a better way.
yes.. I am aware of the getlooktodistance thing.. but I like to have a better 'guess' on the angle/degrees
I might be confused .. as usual.


EDIT:
never mind.
Found a nice way *cool*



Tuur *thumbsup*

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Tuur« (10. Mai 2022, 13:59)


2

Mittwoch, 11. Mai 2022, 19:40

Hi,Tuur,
if so ?

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
<events name="test" keep="true" 
        onviewchange="test()"
/>
<action name="test"> 
	copy(hs, hotspot[link]);
	spheretoscreen(hs.ath, hs.atv, x,y );
	if(x GT 0 AND x LT stagewidth AND y GT 0 AND y LT stageheight,
		trace(YES);
		,
		trace(NO);
	);
</action>	

Tuur

Erleuchteter

  • »Tuur« ist der Autor dieses Themas

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

3

Mittwoch, 11. Mai 2022, 22:08

Hi San,

Yes! Same idea indeed.
I have more functionality connected and made in js action, but yes basicly like that.

Tuur *thumbsup*

4

Mittwoch, 11. Mai 2022, 23:25

on top you can define a pixel with for the border and start fading out hotspots when they get closer to the screen edge.
this is used in zflare.js

Tuur

Erleuchteter

  • »Tuur« ist der Autor dieses Themas

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

5

Mittwoch, 11. Mai 2022, 23:56

yeahh.. also nice idea, but I think not useful for what I am doing atm.
I'll have a sleep on it anyway.

Tuur *thumbsup*

6

Donnerstag, 12. Mai 2022, 00:52

this method is not perfect tough...
it can only detect if a hotspot origin is in the visible stage
but a large hotspot may be partially visible, even if its origin is outside the visible stage

Fernando

Fortgeschrittener

Beiträge: 330

Wohnort: Habana, Cuba

Beruf: Architect, Photographer.

  • Nachricht senden

7

Donnerstag, 12. Mai 2022, 18:01

Any suggestions?

this method is not perfect tough...
it can only detect if a hotspot origin is in the visible stage
but a large hotspot may be partially visible, even if its origin is outside the visible stage
Perhaps by establishing a circumference with a radius equal to the distance between the center and the farthest point of the hotspot and then calculate if that point is inside the screen... Not perfect either, but it would be closer to the solution.


Edit: To many false positive *sad*

»Fernando« hat folgende Bilder angehängt:
  • 20220512_120024.jpg
  • 20220512_121049.jpg

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Fernando« (12. Mai 2022, 18:13)


8

Donnerstag, 12. Mai 2022, 18:11

A smooth change in the transparency of the hotspot is already on the forum, I can’t remember the link, but here is the code.
at a deviation of 45 degrees, the transparency is smoothly equal to zero

Quellcode

1
2
3
4
5
6
7
8
9
10
  <settings transparent_angle="45"/>
  
  <events name="transparent_active" keep="true" onviewchanged="transparent_active"/>
  
 <action name="transparent_active" scope="local">
        getlooktodistance(current_angle, hotspot[logo].ath, hotspot[logo].atv); 
	calc(alpha_hs, 1 -  current_angle /settings.transparent_angle );
	clamp(alpha_hs, 0, get(settings.transparent_angle));
	copy(hotspot[logo].alpha, alpha_hs);    
  </action>

9

Donnerstag, 12. Mai 2022, 18:44

Perhaps by establishing a circumference with a radius equal to the distance between the center and the farthest point of the hotspot and then calculate if that point is inside the screen... Not perfect either, but it would be closer to the solution.



Depends on the problem statement, I think it is enough to make adjustments in width and height, for example

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<action name="test2"> 
	copy(hs, hotspot[link]);
	spheretoscreen(hs.ath, hs.atv, x,y );
	calc(xw,  hs.pixelwidth / 2 );  
	calc(stw, stagewidth - xw ); 
	calc(yh, hs.pixelheight / 2); 
	calc(sth, stageheight - yh ); 
 
	if(x GT xw AND x LT stw AND y GT yh AND y LT sth,
		trace(YES);
		,
		trace(NO);
	);
</action>

In this case, the signal as soon as the picture reaches the edge

Fernando

Fortgeschrittener

Beiträge: 330

Wohnort: Habana, Cuba

Beruf: Architect, Photographer.

  • Nachricht senden

10

Donnerstag, 12. Mai 2022, 22:23

Hi, San7, I'am very interesting in your example,
In this case, the signal as soon as the picture reaches the edge
Ok, but how do you make it work if you see a part of the hotspot? (view attachment 2)
Thanks for your help!
»Fernando« hat folgende Bilder angehängt:
  • 1.jpg
  • 2.jpg

11

Freitag, 13. Mai 2022, 06:28

Hi, San7, I'am very interesting in your example,
In this case, the signal as soon as the picture reaches the edge
Ok, but how do you make it work if you see a part of the hotspot? (view attachment 2)
Thanks for your help!
If super accuracy is not needed, then you can enter a coefficient with a rough correction for fov. This is if the hotspot is distorted. Just pick the right number that satisfies.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<action name="test2"> 
	calc(coeff, 100 / view.fov );
	copy(hs, hotspot[link]);
	spheretoscreen(hs.ath, hs.atv, x,y );
	calc(xw,  (hs.pixelwidth / 2) * coeff );  
	calc(stw, stagewidth - xw ); 
	calc(yh, (hs.pixelheight / 2) * coeff ); 
	calc(sth, stageheight - yh ); 
	if(x GT xw AND x LT stw AND y GT yh AND y LT sth,
		set( hs.alpha,1);  
		,
		set( hs.alpha,0);  
	);
</action>

Fernando

Fortgeschrittener

Beiträge: 330

Wohnort: Habana, Cuba

Beruf: Architect, Photographer.

  • Nachricht senden

12

Freitag, 13. Mai 2022, 10:51

Hi, San7. Testing with many coeff values (from 0.9 to 5), the result is "NO" -or hide- despite that hotspot is 50% inside screen. Is not useful for my specific case, but it is very interesting code for when the hotspot should look complete up to a certain range.
Thanks for sharing *thumbup*
»Fernando« hat folgendes Bild angehängt:
  • 3.jpg

13

Freitag, 13. Mai 2022, 11:32

Hi, San7. Testing with many coeff values (from 0.9 to 5), t

Hello, you need to change the number 100 in my code.
calc(coeff, 100 / view.fov );
hotspot - distorted="true"
Works for me.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »San7« (13. Mai 2022, 12:47)


Fernando

Fortgeschrittener

Beiträge: 330

Wohnort: Habana, Cuba

Beruf: Architect, Photographer.

  • Nachricht senden

14

Samstag, 14. Mai 2022, 15:12

Hi, San7 I testing with coeff, 100 and others values, but not work in my project:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
<hotspotname="mezaninepcchino"
url="%VIEWER%/meza/central_chino+.png"
alpha="0"
keep="true"
zoom="true"
scale="0.000715"
rotate="-70"
ondown="draghotspot();"
ath="-0.013641" atv="0.123258"
enabled="false"
visible="false"
distorted="true"
/>

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<events name="test" keep="true" 
    	onviewchange="test2()"
/>

<action name="test2"> 
	calc(coeff, 100 / view.fov );
	copy(hs, hotspot[mezaninepcchino]);
	spheretoscreen(hs.ath, hs.atv, x,y );
	calc(xw,  (hs.pixelwidth / 2) * coeff );  
	calc(stw, stagewidth - xw ); 
	calc(yh, (hs.pixelheight / 2) * coeff ); 
	calc(sth, stageheight - yh ); 
	if(x GT xw AND x LT stw AND y GT yh AND y LT sth,
		set( hs.alpha,1); trace(YES);  
		,
		set( hs.alpha,0.5); trace(NO); 
	);
</action>
»Fernando« hat folgendes Bild angehängt:
  • 4.jpg

15

Samstag, 14. Mai 2022, 19:49

This is an exampleof how this code works:
calc(coeff, 150 / view.fov );


scale="0.000715" - this is your problem, you change the correction for this size. use setting width and height