I'm creating an arrow (hotspot[arrow]) that points to a hotspot (hotspot[cross]). Right now, using the code below, it looks like this:
The arrow should always be pointing to the center of the cross, but it doesn't. I guess I'm over complicating things in my code. So, do you have any suggestions how to approach this?
Thanks!
Code
<hotspot name="cross" ath="102.017" atv="13.112" url="cross.png" distorted="true" scale="0.3" />
<hotspot name="arrow" edge="left" ath="0" atv="0" url="arrow.png>" distorted="true" scale="0.1" alpha="0.7" />
<events onviewchange="arrow()" />
<action name="arrow">
if(view.hlookat != last_view_hlookat OR view.vlookat != last_view_vlookat,
copy(last_view_hlookat, view.hlookat);
copy(last_view_vlookat, view.vlookat);
mod(cross_ath,hotspot[cross].ath,360);
add(cross_ath,360);
mod(cross_ath,360);
mod(hlookat,view.hlookat,360);
add(hlookat,360);
mod(hlookat,360);
sub(residue,hlookat,cross_ath);
copy(cross_atv,hotspot[cross].atv);
copy(vlookat,view.vlookat);
sub(vdiff,cross_atv,vlookat);
div(vdiff,90);
if((hlookat GT cross_ath) AND residue LT 180,
set(rot,0);
Math.abs(residue);
sub(residue,180,residue);
div(residue,2);
mul(vdiff,residue);
sub(rot,vdiff);
,
if(residue GT 180,
sub(residue,360);
);
set(rot,180);
Math.abs(residue);
sub(residue,180,residue);
div(residue,2);
mul(vdiff,residue);
add(rot,vdiff);
);
set(hotspot[arrow].rotate,get(rot));
set(hotspot[arrow].ath,get(hlookat));
set(hotspot[arrow].atv,get(vlookat));
);
</action>
Display More