Skip to content

Instantly share code, notes, and snippets.

@dreamspy
Created September 13, 2018 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreamspy/9dbe53178b35205357d92dfc8d62bdf8 to your computer and use it in GitHub Desktop.
Save dreamspy/9dbe53178b35205357d92dfc8d62bdf8 to your computer and use it in GitHub Desktop.
{% if displaycomments %}
<!-- Plugin: OpenDoors V1.1
Author: Michael Brüning <M.Bruening@compunics.com.ni>
Tested with: PTP V2.5.3, V2.5.7
-->
{% endif %}
<events name="OpenDoorsEvents" keep="true"
onTourStart="if(debug, showlog(); );"
onxmlcomplete="preload{{p.id}}();"
/>
<action name="display_image">
calc_pos(get(MyHFOV), get(MyYAW), get(MyPITCH), get(MyROLL));
tween(hotspot[get(MySPOT)].alpha,1);
</action>
<action name="calc_pos">
div(hfov,%1,57.295779);
div(yaw,%2,-57.295779);
div(pitch,%3,57.295779);
div(roll,%4,-57.295779);
mul(hfov,0.5);Math.tan(hfov);mul(width,hfov,1000);set(height,'prop');
Math.cos(ch,yaw);Math.sin(sh,yaw);
Math.cos(ca,pitch);Math.sin(sa,pitch);
Math.cos(cb,roll);Math.sin(sb,roll);
mul(m0,ca,ch);
mul(tmp,cb,sa);mul(tmp,ch);mul(tmp2,sb,sh);add(m3,tmp,tmp2);
mul(m4,cb,ca);
mul(tmp,cb,sa);mul(tmp,sh);mul(tmp2,sb,ch);sub(m5n,tmp,tmp2);mul(m5n,-1);
mul(tmp,sb,sa);mul(tmp,ch);mul(tmp2,cb,sh);sub(m6n,tmp,tmp2);mul(m6n,-1);
Math.atan2(yaw,m6n,m0);
Math.atan2(roll,m5n,m4);
Math.asin(pitch,m3);
mul(ath,yaw,57.295779);
mul(atv,pitch,57.295779);
mul(rotate,roll,57.295779);
</action>
<action name="preload{{p.id}}">
{% for picture in p.pictures.elements %}
{% if picture.file %}
preloadimage(Preload_{{picture.file.fileName}}, {{dataDirectory}}/{{pluginDirectory}}/{{picture.file.fileName}} );
{% endif %}
{% endfor %}
</action>
<action name="preloadimage">
<!-- 1. parameter = internal ID, 2. parameter = url -->
indexoftxt(idx, %1, '.', 0);
subtxt(pname, %1, 0, get(idx) );
addplugin(pname);
set(plugin[pname].visible, false);
set(plugin[pname].url, %2);
</action>
<action name="show{{p.id}}">
getmessage(imgid, %1);
{% for picture in p.pictures.elements %}
{% if picture.file %}
if( imgid == {{forloop.counter0}},
set(MyIMG,"{{dataDirectory}}/{{pluginDirectory}}/{{picture.file.fileName}}");
txtadd(tmpMyHFOV, {{p.id}}MyHFOV, get(imgid) );
getmessage(MyHFOV, get(tmpMyHFOV));
txtadd(tmpMyYAW, {{p.id}}MyYAW, get(imgid) );
getmessage(MyYAW,get(tmpMyYAW));
txtadd(tmpMyPITCH, {{p.id}}MyPITCH, get(imgid) );
getmessage(MyPITCH,get(tmpMyPITCH));
txtadd(tmpMyROLL, {{p.id}}MyROLL, get(imgid) );
getmessage(MyROLL,get(tmpMyROLL));
txtadd(MySPOT,'spot',get(imgid) );
addhotspot(get(MySPOT));
set(hotspot[get(MySPOT)].url,get(MyIMG));
set(hotspot[get(MySPOT)].keep, false);
set(hotspot[get(MySPOT)].preload, true);
set(hotspot[get(MySPOT)].distorted, true);
set(hotspot[get(MySPOT)].enabled, false);
set(hotspot[get(MySPOT)].zorder, 1);
set(hotspot[get(MySPOT)].alpha, 0);
<!-- set(hotspot[get(MySPOT)].onloaded, "calc_pos(get(MyHFOV), get(MyYAW), get(MyPITCH), get(MyROLL));" ); -->
<!-- tween(hotspot[get(MySPOT)].alpha,1); -->
set(hotspot[get(MySPOT)].onloaded, "display_image();" )
);
{% endif %}
{% endfor %}
</action>
<action name="hide{{p.id}}">
getmessage(imgid, %1);
{% for picture in p.pictures.elements %}
{% if picture.file %}
if( imgid == {{forloop.counter0}},
txtadd(MySPOT,'spot',get(imgid) );
set(hotspot[get(MySPOT)].visible, false);
tween(hotspot[get(MySPOT)].alpha,0);
removehotspot(get(MySPOT));
);
{% endif %}
{% endfor %}
</action>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment