Sie sind nicht angemeldet.

1

Mittwoch, 16. Oktober 2013, 13:58

Draggable polygonal hotspots

Hello. Can anybody give me advise on how to make polygonal hotspots draggable? I tried this code for regular hotspots and it's works fine, but it's not useful for polygonal hotspots.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
<style name="dragablehotspot" 
dragging="if(pressed,
sub(dx,mouse.stagex,drag_adjustx); sub(dy,mouse.stagey,drag_adjusty); 
screentosphere(dx,dy,ath,atv); if(onDrag!==null, onDrag() ); 
delayedcall(0,dragging()); , if(onDragEnd!==null, onDragEnd() ); );" 
ondown="spheretoscreen(ath,atv,hotspotcenterx,hotspotcentery);
sub(drag_adjustx,mouse.stagex,hotspotcenterx); 
sub(drag_adjusty,mouse.stagey,hotspotcentery); if(onDragStart!==null, 
onDragStart() ); dragging();">
</style>

<hotspot name="hs1" style="dragablehotspot" distorted="true" url="hotspot.jpg" atv="0.0" ath="0.0"></hotspot>


I need similar solution, but for polygonal hotspots and WITHOUT usage of editor plugin.

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

2

Mittwoch, 16. Oktober 2013, 16:03

Hi!

I've played a bit, see here:

http://vt-vr.most-inform.com/poly_move/

The hotspot consists of five points, the modified "draghotspot" action is this:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<action name="draghotspot">
		if(%1 != dragging,
			spheretoscreen(hotspot[get(name)].point[0].ath, hotspot[get(name)].point[0].atv, hotspotcenterx, hotspotcentery);
			sub(drag_adjustx, mouse.stagex, hotspotcenterx); 
			sub(drag_adjusty, mouse.stagey, hotspotcentery); 
			draghotspot(dragging);
		  ,
			if(pressed,
				sub(dx, mouse.stagex, drag_adjustx);
				sub(dy, mouse.stagey, drag_adjusty);
				screentosphere(dx, dy, new_ath, new_atv);
				sub(ath_diff,hotspot[get(name)].point[0].ath,new_ath);sub(atv_diff,hotspot[get(name)].point[0].atv,new_atv);
				sub(hotspot[get(name)].point[0].ath,ath_diff);sub(hotspot[get(name)].point[0].atv,atv_diff);
				sub(hotspot[get(name)].point[1].ath,ath_diff);sub(hotspot[get(name)].point[1].atv,atv_diff);
				sub(hotspot[get(name)].point[2].ath,ath_diff);sub(hotspot[get(name)].point[2].atv,atv_diff);
				sub(hotspot[get(name)].point[3].ath,ath_diff);sub(hotspot[get(name)].point[3].atv,atv_diff);
				sub(hotspot[get(name)].point[4].ath,ath_diff);sub(hotspot[get(name)].point[4].atv,atv_diff);
				delayedcall(0, draghotspot(dragging) );
			  );
		  );
	</action>


As you see, the code is static, "ath_diff" and "atv_diff" are differences between the original and new ath and atv values of the "zero" spot (the first spot of the polygon, in fact). Then this difference is applied to all points. What is left to do is write some dynamic code which will count number of spots via "hotspot[...].point.count" value and apply the difference to all spots automatically. *tongue*
Regards,

Alexey

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

3

Mittwoch, 16. Oktober 2013, 16:20

Here we go. The updated version of "draghotspot" for polygons. As far as I've tested, it counts all the points and applies the ath and atv changes properly.

Here it is:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<action name="draghotspot">
		if(%1 != dragging,
			spheretoscreen(hotspot[get(name)].point[0].ath, hotspot[get(name)].point[0].atv, hotspotcenterx, hotspotcentery);
			sub(drag_adjustx, mouse.stagex, hotspotcenterx); 
			sub(drag_adjusty, mouse.stagey, hotspotcentery); 
			draghotspot(dragging);
		  ,
			if(pressed,
				sub(dx, mouse.stagex, drag_adjustx);
				sub(dy, mouse.stagey, drag_adjusty);
				screentosphere(dx, dy, new_ath, new_atv);
				sub(ath_diff,hotspot[get(name)].point[0].ath,new_ath);sub(atv_diff,hotspot[get(name)].point[0].atv,new_atv);
				for(set(i,0), i LT hotspot[get(name)].point.count, inc(i), 
                sub(hotspot[get(name)].point[get(i)].ath,ath_diff);sub(hotspot[get(name)].point[get(i)].atv,atv_diff);   );				
				delayedcall(0, draghotspot(dragging) );
			  );
		  );
	</action>
 




Hope this helps *tongue*
Regards,

Alexey

4

Donnerstag, 17. Oktober 2013, 10:17

*thumbsup* Thanks a lot Alex. I got the idea. You save my day.

5

Donnerstag, 17. Oktober 2013, 11:35

May I ask what is dragable poly hotspot for? I can not imagine where I would use it.
Can I see your link?

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

6

Donnerstag, 17. Oktober 2013, 17:17

You could make a polygon builder in krpano to set/delete points and adjust its position. And then some clever javascript and php to save it.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour