mheavers
mheavers

Reputation: 30158

scaling object to match field of view

I am overlaying some clickable hotspots on top of a proprietary panorama viewer application in flash (as3), and I need to make sure that the hotspots scale according to the changing field of view as the user zooms in / zooms out, but I'm not sure what formula to use.

I set a maximum and minimum field of view of 90 and 25, respectively. I've been given some suggestions of how to calculate the scale of the icons:

from the maker of the panorama software:

Scale => 1/tan(FoV)

This doesn't seem to work for me. And:

scalar += (ZOOM_SCALE_UPPER - ZOOM_SCALE_LOWER) * ( ZOOM_LIMIT_OUT - tempFOV   )/( ZOOM_LIMIT_OUT-ZOOM_LIMIT_IN) ;

hotspot.scaleX = hotspot.scaleY = scalar;

Gets me close, but at some point the hotspot stops scaling even though the panorama continues to scale. I thought I could just do something like:

diffFOV = previousFOV - currentFOV.
hotspot.scale = currentScale*(1-diffFov)

But that's not quite right either. Everything gets way too big or too small.

Any ideas?

Upvotes: 1

Views: 318

Answers (1)

Reshape Media
Reshape Media

Reputation: 341

You may be over thinking it.

//assume we change the scale
var NEW_SCALE:Number = currentScale*(1-(previousFOV-currentFOV));

//1. change the scale of the parent containing both the view and the hotspots
viewSprite.scale = NEW_SCALE;
//this way the hotspot and the panorama will scale together

//2. if they are not in the same parent... then set them both to the same view
hotspot.scale = panorama.scale;

Only thing you may have to do after is reposition if they are not registered on their center point.

Upvotes: 1

Related Questions