POV-Ray : Newsgroups : povray.general : stuck with user_defined camera : Re: stuck with user_defined camera Server Time
25 Apr 2024 23:59:52 EDT (-0400)
  Re: stuck with user_defined camera  
From: ingo
Date: 21 Jan 2019 14:33:29
Message: <XnsA9DED1218BE46seed7@news.povray.org>
in news:5c45feaf$1@news.povray.org clipka wrote:

> all you need to do is scale and offset u 
> and v,

It seems to work very well, a bit rough and unchecked macro, have to have 
a closer look at the "zoom factors" etc.
Thanks again!

ingo

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

#version 3.8;
global_settings {assumed_gamma 1}

#macro TileCam(Loc,Face,Zoom,Col,Row) //Face not implemented yet
  /*
  Renders a single square tile for the given tile position
  Set image resolution with aspect ratio 1:1, most tile renders
  use 256x256
  //+w256 +h256 +a0.001 +am3
  
  Number of tiles = 4^zoomlevel
  Tiles:Side = sqrt(4^zoomlevel)
  
  Zoomlevel 0
  one square 256x256
       Z C R
  0   (0,0,0)
  
  Zoomlevel 1
  4 squares
       Z C R
  1   (1,0,0) (1,1,0)
      (1,0,1) (1,1,1)
  
  Zoomlevel 2
  16 squares
       Z C R
  2   (2,0,0) (2,1,0) (2,2,0) (2,3,0)
      (2,0,1) (2,1,1) (2,2,1) (2,3,1)
      (2,0,2) (2,1,2) (2,2,2) (2,3,2)
      (2,0,3) (2,1,3) (2,2,3) (2,3,3)
  
  Loc  (vec): Camera location
  Zoom (int): Zoomlevel
              resulting amount of tiles per zoomlevel = pow(4,zoom)
              max zoom level = ...?
  Face (str): Letter describing the direction to look into
              "F": front look_at +z
              "B": back  look_at -z
              "U": up    look_at +y
              "D": down  look_at -y
              "R": right look_at +x
              "L": left  look_at -x
  Col  (int): Column coordinate to render, top,left = 0
  Row  (int): Row coordinate to render, top,left = 0
  */
  #local Map05 = function(x,y,z){((x-y)/(z-y))-0.5};
  #local TileTotal  = pow(4,Zoom);
  #local TileSide   = sqrt(TileTotal);
  #local TileLength = 1/TileSide;
  //TODO:
  //check col and row index fit inside zoomlevel else error
  #local TileUStart = Map05(Col*TileLength,0,1);
  #local TileUC   = TileUStart+(TileLength/2);
  #local TileVStart = Map05(Row*TileLength,1,0);
  #local TileVC   = TileVStart-(TileLength/2);
  
  #debug concat("Tiles Total  : ",str(TileTotal , 0,0 ),"\n")
  #debug concat("Tiles Side   : ",str(TileSide  , 0,0 ),"\n")
  #debug concat("Tiles Length : ",str(TileLength, 0,0 ),"\n\n")
  #debug concat("TileUStart   : ",str(TileUStart,10,10),"\n")
  #debug concat("TileVStart   : ",str(TileVStart,10,10),"\n\n")
  #debug concat("TileUC       : ",str(TileUC,    10,10),"\n")
  #debug concat("TileVC       : ",str(TileVC,    10,10),"\n\v")

  camera {
    user_defined
    location Loc
    direction{
      function{((1/TileSide*u)+TileUC)*tan(radians(90)/2)}
      function{((1/TileSide*v)+TileVC)*tan(radians(90)/2)}
      function{.5}
    }
  }
  
#end 

TileCam(<0,0,0>,"F",1,0,0)

background{rgb 1}
light_source {<100,100,-100> rgb 1}
sphere{<0,0  , 2>,0.5 texture{pigment{checker}}}
sphere{<0,0.5, 2>,0.2 pigment{rgb z}}


Post a reply to this message

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