POV-Ray : Newsgroups : povray.general : stare_at? : Re: stare_at? Server Time
12 Aug 2024 19:37:40 EDT (-0400)
  Re: stare_at?  
From: Karsten Senz
Date: 20 Jan 1999 05:24:09
Message: <36A5AEE2.C729BC05@wi-bw.tfh-wildau.de>
Phil Clute wrote:
> 
> First of all ignore my last message! Entitled ty. It was just a dumb
> mistake!
> One of many I assure you. My appologies for wasting news-group space.
> And now for the real stuff...
> As a learning project I've started making an Eye.inc, it's basically an
> eye object
> where you can change the iris texture and pupil size at this point. But
> I would
> also like to be able to point the eye in a direction as though it's
> looking at another
> object. I know, I know rotate is the obvious answer, but it would be
> cool if I could
> use a vector like look_at in camera{}so that I could just specify a
> point. This
> would be handy when animating and a bit simpler to follow, or at least
> that's the
> idea.

You could convert that stare_at point into rotations ?

I suppose you use y for the up direction but that doesn't matter at all.
So you have the position of "your" eye: <eye_x,eye_y, eye_z>
(by the way you should create "your" eye at the origin and translate it
later to that position)

and you have that stare_at point <stare_at_x,stare_at_y,stare_at_z>

what we need first is the length from stare_at_x to eye_x and from
stare_at_z to eye_z :

length_x = stare_at_x - eye_x;
length_z = stare_at_z - eye_z;

now we can easily get the rotation of y by :

rotation_y = atan2(length_z,length_x);


now the eye should look in the right direction but not at the point. We
have to make another adjustment.
we need the heigth of the stare_at point

length_y = stare_at_y - eye_y;

and do another rotation :

rotation_z = atan2(length_y,length_x);


in the eye definition you may have :

object eye
{
  union
  {
  ...
  // the parts of "your" eye created at origin
  }
  rotate<0.0,rotation_y,rotation_z> // first rotate
  translate<eye_x,eye_y,eye_z>
}

If the steps are not clear write me and I will make a sketch because I'm
no native English and often miss the right terms.



I hope that helps and if it does not work you expected, I hope you even
got an idea how to get it work


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.