POV-Ray : Newsgroups : povray.animations : Add object to camera : Re: Add object to camera Server Time
27 Apr 2024 06:07:39 EDT (-0400)
  Re: Add object to camera  
From: Chris B
Date: 5 Jul 2008 16:54:40
Message: <486fdf90@news.povray.org>
"philguy" <phi### [at] googlemailcom> wrote in message 
news:web.486fc9aab0c652322bb066f70@news.povray.org...
> I have a camera flying along a spline, and now I would like to add a pair 
> of
> "headlights" that move along with it.
>
> Is there an easy way to do it or would I be forced to solve that with an
> additional spline?
> Is there a way to set the orientation of the headlights so that they will 
> always
> be below the camera, parallel to the bottom "image border"?
>
> Also, is it possible to set the (tilt) angle of the camera in relation to 
> the
> spline? I am thinking of a loop-shaped spline. Currently, the camera will

> manually
> with the up vector, but I'd like to have that automated (if the loops are
> generated automatically).
>

There's not enough information to give a definitive answer, so I'll start by 
assuming the loop of track is flat and that you want the camera to lean into 
the corners in the way that a motorcyle would. If the track is moving up and 
down a bit you could calculate the amount to lean the camera by just 
ignoring the y component of the direction vectors for the purposes of this 
calculation.

Given the direction vector of the spline at the camera position and the 
direction vector of the spline a short, but constant distance ahead you can 
use VAngleD to work out the angle between their horizontal components. You 
can take this as being roughly proportional to the amount you should lean 
the camera off the vertical. That is to say that the sharper the turn to the 
left or right, the more the camera would lean over.

To get the 'up' vector you can project the vector 'y' onto the plane defined 
by the camera direction vector using VProject_Plane (this gives you a vector 
at right angles to the camera direction vector that will always point 
roughly upwards) then rotate the result around the camera direction vector 
by the amount you want to lean the camera over using the vaxis_rotate 
function.

You can add a directional light (a spotlight) under the camera by 
subtracting the normalised 'up' vector (multiplied by whatever distance you 
want) from the camera position. You can specify a point_at position as being 
the light position plus the camera direction vector so that the light shines 
out parallel to the camera. To get a pair you'll need to displace their 
positions at right angles to the plane defined by the camera 'up' and 
'direction' vectors (see vperp_to_plane).

Hope that helps,

Regards,
Chris B.


Post a reply to this message

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