// Persistence of Vision SDL include file // Description: A macro to simulate lens movements in architectural scenes // Helps prevent the "falling verticals syndrome" // Author: John Guthkelch (Doctor John) // Version 2.0 Released September 2005 // Changes: 1. Improved warning so that camera automatically reverts to default // type if insane values are given for CamPos and/or CamLook // 2. Corrected silly mathematical error in vertical scaling.This // is now correct so switch has been taken out. /*********************************************************************** Don't forget to switch off Vista Buffers by using -uv on the command line or Vista_Buffer=0 in your .ini file before attempting to render your image ***********************************************************************/ #macro FieldCam (CP, CL) #local CD=CL-CP; #if (CD.x!=0 | CD.z!=0) // Note: That's a Boolean OR not an uppercase i // or a lowercase L! #local HypoXZ=sqrt(pow(CD.x, 2)+pow(CD.z, 2)); #local VCorr=pow(vlength(CD), 2)/pow(HypoXZ, 2); #local CosThetaX=CD.x/HypoXZ; #local CosThetaZ=CD.z/HypoXZ; #if (CD.x=0) #local ShearX=0; #else #local ShearX=(CD.y/CD.x)*pow(CosThetaX, 2); #end #if (CD.z=0) #local ShearZ=0; #else #local ShearZ=(CD.y/CD.z)*pow(CosThetaZ, 2); #end #declare NoFall=transform { matrix <1, 0, 0, ShearX, VCorr, ShearZ, 0, 0, 1, 0, 0, 0> } #else #warning "Viewing vector is perpendicular to XZ-plane.\n" #warning "Camera changed to default type.\n" #declare NoFall=transform { matrix <1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0> } #end #end /*********************************USAGE************************************** #declare CamPos=; //Just replace with location vector #declare CamLook=; // -"- -"- with look_at vector camera { FieldCam (CamPos, CamLook) perspective location CamPos [angle Whatever] // Not essential but can be used [right If_you_want] // Also not essential but can be used transform {NoFall} look_at CamLook } ****************************************************************************/