Rotating Dial

Date:    Mon, 20 Feb 1995 23:25:41 +0000
From:    Peter Small <peter@GENPS.DEMON.CO.UK>
Subject: A rotating dial for Roy

On Sun, 19 Feb 1995 23:10:45
Roy Pardi <rpardi@INTERACCESS.COM> wrote :
 
>My task: I am trying to create a relationship (map) between the width of
>a sprite and the duration of a QT movie such that when the mouse enters >the
>sprite rect, the movietime is set to that point.
 
> -------Stuff deleted
>
 
>the problem here is again the relationship between
>the bounding rect and the QT duration, with the added complexity of >looping
>either way through the movie so that the sim feels like true >rotation, not
>just running the linear movie.
Hi Roy

Your requirement to be able to rotate a Quick Time 3D object with the mouse reminded me of a dial control I once made in Hypercard.

I've just tried it out in Lingo and it works quite well.

In essence, you rotate a dial with the mouse and get a read out of the position of the dial in degrees (which you can easily translate into a suitable movieTime number). It should be quite effective for rotating your 3D object.

The demo is only 12k if you want me to Email it to you, but, it will be quite simple for you to set up for yourself.

  1. Put a circle (your dial) about 100 pixels in diameter into sprite (channel) 1.
  2. Put a small colored circle (your knob) about 10 pixels in diameter into sprite (channel) 2.
  3. Put a display field into sprite (channel) 3. Name this field "Degrees"
  4. Put the following two handlers into the frame script, then turn the knob with your mouse and see what happens.
     
    on exitFrame
      pause
    end exitFrame
     
    on mouseDown
      put the locH of sprite 1 into orH
      put the locV of sprite 1 into orV
      repeat while stillDown()
        put float((mouseH() -orH)/2) into mH
        put float((mouseV() -orV)/2) into mV
        if mv > 0 then
          if mh >0 then
            put Atan(mH /mv) into angle
            put float(the width of sprite 1 /2) into Radius
            set the loch of sprite 2 to orH + sin(angle) *radius
            set the locV of sprite 2 to orV + cos(angle) *radius
            put integer(180 -angle *180/pi()) into field "Degrees"
          else
            put Atan(mH /mv) into angle
            put the width of sprite 1 /2 into Radius
            set the loch of sprite 2 to orH + sin(angle) *radius
            set the locV of sprite 2 to orV + cos(angle) *radius
            put integer(180 -angle *180/pi()) into field "Degrees"
          end if
        end if
        if mv < 0 then
          if mh >0 then
            put Atan(mH /mv) into angle
            put the width of sprite 1 /2 into Radius
            set the loch of sprite 2 to orH - sin(angle) *radius
            set the locV of sprite 2 to orV - cos(angle) *radius
            put integer(-angle *180/pi()) into field "Degrees"
          else
            put Atan(mH /mv) into angle
            put the width of sprite 1 /2 into Radius
            set the loch of sprite 2 to orH - sin(angle) *radius
            set the locV of sprite 2 to orV - cos(angle) *radius
            put integer( 360 -angle *180/pi()) into field "Degrees"
          end if
        end if
        updateStage
      end repeat
    end
    
In my HyperCard version I used a picture font in a field, using the angular read outs to select pictures from a font of a dial face in different positions to simulate a turning dial.

A similar turning dial can be arranged in Director by using casts (a set pictures of a dial face in different positions).