POV-Ray : Newsgroups : povray.binaries.images : New Macro Test : New Macro Test Server Time
31 Jul 2024 00:27:42 EDT (-0400)
  New Macro Test  
From: John VanSickle
Date: 25 Sep 2010 19:28:33
Message: <4c9e85a1@news.povray.org>
There is in film something called the rule of thirds, which says that 
for many shots, the main item of interest should be positioned one-third 
of the way across the screen, either from the right or from the left.

I decided to write a macro to make it easier to point the camera so that 
an item of interest falls along one of these two lines.  For a test I 
simply re-used the scene from my last post (titled "Old School") with a 
couple of light sources taken away (one was positioned at the camera 
location, and the other was far off in the +x direction).

Here are the macros.  There is one for positioning to the left, and 
another for positioning to the right.

#macro PlaceLeftThird(pCamLoc,pCamEye,vCamSky,sCamZoom)
   #local vD=vnormalize(pCamEye-pCamLoc);
   #local vR=vnormalize(vcross(vCamSky,vD));
   #local sD=vlength(pCamEye-pCamLoc)/sCamZoom * image_width/image_height/6;
   (pCamEye+vR*sD)
#end

#macro PlaceRightThird(pCamLoc,pCamEye,vCamSky,sCamZoom)
   #local vD=vnormalize(pCamEye-pCamLoc);
   #local vR=vnormalize(vcross(vCamSky,vD));
   #local sD=vlength(pCamEye-pCamLoc)/sCamZoom * image_width/image_height/6;
   (pCamEye-vR*sD)
#end

In these macros, pCamLoc is the location of the camera, pCamEye is the 
location of the item that is to appear towards the left or towards the 
right, vCamSky is the direction of the sky vector used in the scene (y 
for the scenes I do), and sCamZoom is the length of the direction vector 
used in the camera.

The macro returns a value which should be used as the look_at value in 
the camera definition.

An example of macro use:

camera {
   location <100,20,-300>
   direction z*2.5
   look_at PlaceLeftThird(<100,20,-300>,<100,15,-100>,y,2.5)
}

If you use this in a right-handed scene (+x is right, +y is forward, +z 
is up) and this causes problems, let me know.

A sample pic is attached.

Regards,
John


Post a reply to this message


Attachments:
Download '70lights.png' (162 KB)

Preview of image '70lights.png'
70lights.png


 

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