POV-Ray : Newsgroups : povray.general : perspective user defined camera? : perspective user defined camera? Server Time
26 Apr 2024 05:05:53 EDT (-0400)
  perspective user defined camera?  
From: ingo
Date: 26 Jan 2019 10:07:05
Message: <XnsA9E3A3F647A49seed7@news.povray.org>
How do I get the proper functions for defining a perspective camera as a 
user_defined one? There's all kind of stuff I can calculate, but can't 
get it into functions. Been at it for a few days, must say that young 
blokes playing games a meter away doesn't help either.

I'd like to define location look at and angle, possibly roll. Below one 
of many approaches,

ingo

---%<------%<------%<---

#version 3.8;
global_settings {assumed_gamma 1}
// perspective camera as user_defined

#declare Loc   = <0,0.5,0>;
#declare Look  = <0,0,1>;
#declare Angle = 90;
#declare Up    = <0,1,0>;
//#declare Roll = <0,0,0>;

#declare AR = image_width/image_height;
#declare Right = <AR,0,0>;

#declare Distance = 0.5*vlength(Right)/tan((radians(Angle))/2);

#declare Direction = vnormalize(Look-Loc);  //W
#declare U = vnormalize(vcross(Up,Direction));  
#declare V = vcross(Direction,U);
// Roll, rotate cam around Direction 
// transforms.inc : Axis_Rotate_Trans(Axis, Angle)


camera {
  user_defined
  location {
    function{u*AR}
    function{v}
    function{Distance}
  }                             
  direction{
    function{u*AR}
    function{v}
    function{Distance}
  }
} 
//camera{location Loc look_at Look angle Angle}

background{rgb 1}
light_source {<100,100,-100> rgb 1}
light_source {<0,0,0> rgb .1}
sphere{< 0,0  , 2>,0.5 texture{pigment{checker rgb 1 rgb 0}}} //+Z
sphere{< 0,0.5, 2>,0.2 pigment{rgb 1}}
sphere{< 0,0  ,-2>,0.5 texture{pigment{checker rgb 1 rgb x}}} //-Z
sphere{< 0,0.5,-2>,0.2 pigment{rgb x}}
sphere{< 2,0  , 0>,0.5 texture{pigment{checker rgb 1 rgb y}}} //+X
sphere{< 2,0.5, 0>,0.2 pigment{rgb y}}
sphere{<-2,0  , 0>,0.5 texture{pigment{checker rgb 1 rgb z}}} //-X
sphere{<-2,0.5, 0>,0.2 pigment{rgb z}}


Post a reply to this message

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