|
![](/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?
>
You have another possibility: Adjust the dimention of the object to a
given dimention.
You can get the extent of the bounding box of an object using
min_extent(Object_Name) and max_extent(Object_Name).
Using the returned values, you can compute a scaling factor to adjust
the dimention of the object to your liking.
This will resize an object to 10 units in the vertical direction:
// This assume that you have previously declared
// an object with the name "MyObject"
// Get the extent of MyObject
#declare Min = min_extent(MyObject);
#declare Max = max_extent(MyObject);
// Calculate it's vertical dimention
#declare V_Dim = Max.y - Min.y;
// Instanciate and scale MyObject
object{MyObject scale 10/V_Dim}
Also, you can relocate your object to the origin if needed, like when
the object was not created at the origin.
Alain
Post a reply to this message
|
![](/i/fill.gif) |