POV-Ray : Newsgroups : povray.general : Fitting object to orthographic screen Server Time
31 Jul 2024 02:29:12 EDT (-0400)
  Fitting object to orthographic screen (Message 1 to 4 of 4)  
From: Nekar Xenos
Subject: Fitting object to orthographic screen
Date: 19 Jan 2008 01:46:32
Message: <47919cc8@news.povray.org>
I think this has been mentioned before, but I can't find the post. I'm 
trying to fit objects' bounding box exactly to screensize. Can anyone please 
tell me what I'm missing?


-- 
-Nekar Xenos-


// ----------------------------------------



sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.7 rgb <0.0,0.1,0.8>]
    }
  }
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

// ----------------------------------------

plane {
  y, -1
  pigment { color rgb <0.7,0.5,0.3> }
}

// +h400 +w400
#include"shapes.inc"
#include "shapes"

#declare hObject =
sphere {
  <0,0,0>, 1   translate <1,2,3>
  pigment { rgb <1,0,0> }
}

#declare Min = min_extent ( hObject );
#declare Max = max_extent ( hObject );

object { hObject }
box {Min, Max pigment {rgbt .5} }

#declare CamPos=<(Min+Max).x/2,(Min+Max).y/2,(Min-Max).z>;
#declare CamLook= (Min+Max)/2;

camera { orthographic
  location  CamPos
  right (Max-Min).x
  up (Max-Min).y
  look_at  CamLook
}


Post a reply to this message

From: Chris B
Subject: Re: Fitting object to orthographic screen
Date: 19 Jan 2008 05:45:16
Message: <4791d4bc@news.povray.org>
"Nekar Xenos" <nek### [at] gmailcom> wrote in message 
news:47919cc8@news.povray.org...
>I think this has been mentioned before, but I can't find the post. I'm 
>trying to fit objects' bounding box exactly to screensize. Can anyone 
>please tell me what I'm missing?
>
> camera { orthographic
>  location  CamPos
>  right (Max-Min).x
>  up (Max-Min).y
>  look_at  CamLook
> }
>

That should be
  right x*(Max-Min).x
  up y*(Max-Min).y

It took me quite some looking and head scratching to spot that one. :-)

'up' and 'right' are vectors and you're using a float (i.e. just the x 
dimension of the difference between the Max and Min extents of the object). 
This gets automatically expanded to a vector with equal values for x, y, and 
z, so you need to multiply by the appropriate vector (e.g. 'x') to get a 3D 
vector with just the 'x' component being '1' and the rest being '0'.

Regards,
Chris B.


Post a reply to this message

From: Nekar Xenos
Subject: Re: Fitting object to orthographic screen
Date: 19 Jan 2008 07:27:31
Message: <4791ecb3$1@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote in message 
news:4791d4bc@news.povray.org...
>
> "Nekar Xenos" <nek### [at] gmailcom> wrote in message 
> news:47919cc8@news.povray.org...
>>I think this has been mentioned before, but I can't find the post. I'm 
>>trying to fit objects' bounding box exactly to screensize. Can anyone 
>>please tell me what I'm missing?
>>
>> camera { orthographic
>>  location  CamPos
>>  right (Max-Min).x
>>  up (Max-Min).y
>>  look_at  CamLook
>> }
>>
>
> That should be
>  right x*(Max-Min).x
>  up y*(Max-Min).y
>
> It took me quite some looking and head scratching to spot that one. :-)
>
> 'up' and 'right' are vectors and you're using a float (i.e. just the x 
> dimension of the difference between the Max and Min extents of the 
> object). This gets automatically expanded to a vector with equal values 
> for x, y, and z, so you need to multiply by the appropriate vector (e.g. 
> 'x') to get a 3D vector with just the 'x' component being '1' and the rest 
> being '0'.
>
> Regards,
> Chris B.

Thanks !


-- 
-Nekar Xenos-


Post a reply to this message

From: John VanSickle
Subject: Re: Fitting object to orthographic screen
Date: 19 Jan 2008 08:31:40
Message: <4791fbbc$1@news.povray.org>
Nekar Xenos wrote:
> "Chris B" <nom### [at] nomailcom> wrote in message 
> news:4791d4bc@news.povray.org...
>> "Nekar Xenos" <nek### [at] gmailcom> wrote in message 
>> news:47919cc8@news.povray.org...
>>> I think this has been mentioned before, but I can't find the post. I'm 
>>> trying to fit objects' bounding box exactly to screensize. Can anyone 
>>> please tell me what I'm missing?
>>>
>>> camera { orthographic
>>>  location  CamPos
>>>  right (Max-Min).x
>>>  up (Max-Min).y
>>>  look_at  CamLook
>>> }
>>>
>> That should be
>>  right x*(Max-Min).x
>>  up y*(Max-Min).y
>>
>> It took me quite some looking and head scratching to spot that one. :-)
>>
>> 'up' and 'right' are vectors and you're using a float (i.e. just the x 
>> dimension of the difference between the Max and Min extents of the 
>> object). This gets automatically expanded to a vector with equal values 
>> for x, y, and z, so you need to multiply by the appropriate vector (e.g. 
>> 'x') to get a 3D vector with just the 'x' component being '1' and the rest 
>> being '0'.

Although,

camera { orthographic
   right (Max-Min)*x
   up (Max-Min)*y
   direction z
   location <0,0,Min-1>
}

Is shorter code.

Regards,
John


Post a reply to this message

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