POV-Ray : Newsgroups : povray.animations : Add object to camera Server Time
23 Nov 2024 11:53:12 EST (-0500)
  Add object to camera (Message 1 to 3 of 3)  
From: philguy
Subject: Add object to camera
Date: 5 Jul 2008 15:25:00
Message: <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

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


Yes, this is not all about animation, but animation was still the subcategory I
thought would fit best, so I nevertheless hope that some of you can help me
here.


Post a reply to this message

From: Chris B
Subject: Re: Add object to camera
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

From: Mike Williams
Subject: Re: Add object to camera
Date: 6 Jul 2008 00:10:08
Message: <lXuinDBMWEcIFw+T@econym.demon.co.uk>
Wasn't it philguy who wrote:
>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

>with the up vector, but I'd like to have that automated (if the loops are
>generated automatically).
>
>
>Yes, this is not all about animation, but animation was still the subcategory I
>thought would fit best, so I nevertheless hope that some of you can help me
>here.

The demo scene that's included in the distribution does all that
/scenes/animations/splinefollow/splinefollow.pov

The first Aircraft is attached to the camera.

The camera itself is offset from the first Aircraft by
        translate <0,0.4,0.4>
otherwise it would be inside the body of the Aircraft and wouldn't see
anything interesting.

splinefollow.pov doesn't move the light source, but the same technique
that's used for moving the camera works. Try removing the existing light
sources from a copy of splinefollow.pov and adding this one at the end.

light_source {< 0,0.4,0.4>,
      color 1.0
      spotlight point_at <0,0.4,1> radius 10
      Spline_Trans (MySpline, clock*11, y, 0.5, 0.5)
}

Using the non-first-person view shows the lighting effect better.
Using the first-person view shows the camera tilt.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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