POV-Ray : Newsgroups : povray.text.scene-files : screen.inc extension Server Time
22 Dec 2024 22:21:28 EST (-0500)
  screen.inc extension (Message 1 to 2 of 2)  
From:
Subject: screen.inc extension
Date: 12 Apr 2002 08:39:16
Message: <61ldbu8kmln7dlhdr539tohffoiobi2k4s@4ax.com>
I want share three macros to manipulate vectors on screen. I know there is
already Screen_Object in screen.inc include file but I can't use it to
manipulate selected vertices in mesh.

// screen.inc extension by ABX
// 12/04/2002

// Calculate 3D vector equivalent for specified camera parameters and
// screen coordinates. Put it in specified Distance from camera. For
// Distance_Type = yes use Distance as distance between result and
// camera location (placing on sphere around camera location).
// For Distance_Type = no use Distance as distance between camera
// location and plane contaning result and parallel to camera plane
// (placing on plane in front of camera). Input vector is 2D from
// <-.5,-.5> to <.5,.5>

#macro Screen_To_Vector( V2 )
  #local V = V2 * <Camera_Aspect_Ratio,1,0> ;
  vtransform( V , transform{ Camera_Transform translate CamD } )
#end

#macro Screen_To_Vector_At_Distance( V2 , Distance , Distance_Type )
  #local V = Screen_To_Vector( V2 ) ;
  ( CamL + Distance * ( Distance_Type ? vnormalize( V - CamL ) : ( V - CamL ) /
vlength( CamD ) ) )
#end

// Calculate coordinates on screen for specified 3D vector )
// Screen itself is from <-.5,-.5> to <.5,.5>

#macro Vector_To_Screen( V2 )
  #local Dir = vnormalize( V2 - CamL ) ;
  #local VD = vdot( vnormalize(CamD) , Dir );
  #if ( VD = 0 ) #error "Error : Vector on viewer plane" #end
  #local V = vtransform(
    - vlength(CamD) * Dir / VD ,
    transform{
      Camera_Transform
      translate CamD
      translate -CamL
      inverse
    }
  ) ;
  < V.x/Camera_Aspect_Ratio , V.y >
#end

// ABX


Post a reply to this message

From:
Subject: Re: screen.inc extension
Date: 12 Apr 2002 08:41:22
Message: <9bldbu02kv1nairhk1v6v25v1pivhssnjs@4ax.com>

wrote:
> I want share three macros to manipulate vectors on screen. I know there is
> already Screen_Object in screen.inc include file but I can't use it to
> manipulate selected vertices in mesh.

and sample file to present control over distance to camera and placing
rendered version after moment in p.b.i

#include "screen.inc"

Set_Camera_Location(<-4,4,0>)
Set_Camera_Look_At(z*15)
       
background{x}       

#local X=-.5;
#while (X<=.5)
  #local Y=-.5;
  #while (Y<=.5)
    #local V = Screen_To_Vector_At_Distance( <X,Y> , 100 , no );
    sphere{ V , 4 pigment{agate} finish{ambient 1 diffuse 0 }}
    #local V = Screen_To_Vector_At_Distance( Vector_To_Screen( V ) , 50 , no ); 
    sphere{ V , 1 pigment{bozo} finish{ambient 1 diffuse 0 }}
    #local Y=Y+.1;
  #end
  #local X=X+.1;
#end

sphere{
  Screen_To_Vector_At_Distance( <0,0> , 75 , no ) , 20
  pigment{rgbt .5} finish{ambient 1 diffuse 0 }
}


Post a reply to this message

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