Fish eyeball vector

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • while_1

    #1

    Fish eyeball vector

    I made a simple animated gif of a fish whose eyeball wiggles
    a few loops upon any mouseover:

    < img id="ppic" src="http://xxx.yyy.com/Nice_Fish.gif"
    onMouseOver="do cument.images.p pic.src=documen t.images.ppic.s rc" >

    But what I'd really like to do is to turn the eyeball into a
    floating sprite that follows the mouse....so the fish looks at
    the mouse cursor, at whatever position the mouse happens to be,
    upon mouseover.

    You'd need to calculate a relative vector somehow, from the center
    of the eyeball position to the current mouse position.
    I think I remember how to do that from previous exmperiments
    with OpenGL. In fact I think I know how to do the whole
    thing with OpenGL, but I haven't got a clue how to do it with
    javascript, in browser land.

    Is this possible, with javascript?
    How would I do it?
  • Tony

    #2
    Re: Fish eyeball vector

    while_1@montana-riverboats.com (while_1) wrote in message news:<9be1f7f8. 0408090703.3850 fa6a@posting.go ogle.com>...[color=blue]
    > I made a simple animated gif of a fish whose eyeball wiggles
    > a few loops upon any mouseover:
    >
    > &lt; img id="ppic" src="http://xxx.yyy.com/Nice_Fish.gif"
    > onMouseOver="do cument.images.p pic.src=documen t.images.ppic.s rc" &gt;
    >
    > But what I'd really like to do is to turn the eyeball into a
    > floating sprite that follows the mouse....so the fish looks at
    > the mouse cursor, at whatever position the mouse happens to be,
    > upon mouseover.
    >
    > You'd need to calculate a relative vector somehow, from the center
    > of the eyeball position to the current mouse position.
    > I think I remember how to do that from previous exmperiments
    > with OpenGL. In fact I think I know how to do the whole
    > thing with OpenGL, but I haven't got a clue how to do it with
    > javascript, in browser land.
    >
    > Is this possible, with javascript?
    > How would I do it?[/color]

    You can use the basic trig from these:







    Tone.

    Comment

    • Sandy Pittendrigh

      #3
      Re: Fish eyeball vector

      ....thank you!

      Comment

      • Kien

        #4
        Re: Fish eyeball vector

        Hi,
        I would suggest having the eye in 8 positions, Up,Down,L,R,UpL ,UpR,DownL,Down R
        Then replace the image with each position according to the mouse position
        You can sense the mouse position using onmousemove capture
        like here http://www.caoxuan.com/cxk/webart/goodies/shyobj.html

        Kien



        while_1@montana-riverboats.com (while_1) wrote in message news:<9be1f7f8. 0408090703.3850 fa6a@posting.go ogle.com>...[color=blue]
        > I made a simple animated gif of a fish whose eyeball wiggles
        > a few loops upon any mouseover:
        >
        > &lt; img id="ppic" src="http://xxx.yyy.com/Nice_Fish.gif"
        > onMouseOver="do cument.images.p pic.src=documen t.images.ppic.s rc" &gt;
        >
        > But what I'd really like to do is to turn the eyeball into a
        > floating sprite that follows the mouse....so the fish looks at
        > the mouse cursor, at whatever position the mouse happens to be,
        > upon mouseover.
        >[/color]
        ....[color=blue]
        > Is this possible, with javascript?
        > How would I do it?[/color]

        Comment

        Working...