|
![](/i/fill.gif) |
Hi,
I have a script where it imports an object and render it to get an image.
The fact is that all works fine but the question is that the script can
import any kind of object and it should adapt the camera to focus the object
almost the 80% of view. I mean, if the object is too small, the camera should
zoom + to get the object size almost the 80% and in case the object is too big,
it should zoom - to get the same situation.
How can I accomplish this?
The code I use is:
#include "{{INCLUDE_FILE}}"
#include "{{BASE_PATH}}/axes_macro.inc"
#include "math.inc"
#include "finish.inc"
#include "transforms.inc"
#include "{{BASE_PATH}}/base_render.inc"
#include "{{BASE_PATH}}/center_volumen.inc"
#include "colors.inc"
#include "textures.inc"
#declare maxcorner = 0;
#declare mincorner = 0;
#declare max_x = 0;
#declare min_x = 0;
#declare max_y = 0;
#declare min_y = 0;
#declare max_z = 0;
#declare min_z = 0;
background {color rgb 0.1}
global_settings {
assumed_gamma 2
ambient_light rgb<1, 0, 0>
}
sky_sphere
{
pigment
{
gradient y
color_map
{
[0.0 rgb <1.0,1.0,1.0>] //153, 178.5, 255 //150, 240, 192
[0.7 rgb <0.9,0.9,0.9>] // 0, 25.5, 204 //155, 240, 96
}
scale 2
translate 1
}
}
object {
{{MODELNAME}}
Center_Trans({{MODELNAME}}, x+y+z)
texture {
pigment { Red }
finish { ambient 0.1
diffuse 0.9
phong 1 }
}
#declare maxcorner = max_extent({{MODELNAME}});
#declare mincorner = min_extent({{MODELNAME}});
#declare max_x = max(maxcorner.x,mincorner.x);
#declare min_x = min(maxcorner.x,mincorner.x);
#declare max_y = max(maxcorner.y,mincorner.y);
#declare min_y = min(maxcorner.y,mincorner.y);
#declare max_z = max(maxcorner.z,mincorner.z);
#declare min_z = min(maxcorner.z,mincorner.z);
FindObjectCenter( {{MODELNAME}} )
}
camera {
location <0,200,0>
up <0,1,0>
look_at <0,0,0>
}
object {
light_source {
<max_x+100, 0, 0>
rgb 0.5
shadowless
}
}
light_source {
<0, max_y+100, 0>
rgb 0.5
shadowless
}
light_source {
<0, 0, 100>
rgb 0.5
shadowless
}
Thanks.
Post a reply to this message
|
![](/i/fill.gif) |