// Persistence of Vision Ray Tracer Scene Description File // File: AM_Resize.inc // Vers: 3.8 // Desc: http://news.povray.org/povray.newusers/thread/%3C60c8e000%241%40news.povray.org%3E/ // Date: 15 June 2021 // Auth: Alain Martel, to Herbert Pflaum // Thomas de Groot made a macro out of this. //======================================================================================================= #macro Resize (Obj, Center, DimFactor) // 1) Obj is your object. // 2) Find it's bounds : #local TopRight = max_extent(Obj); #local BottomLeft = min_extent(Obj); // 3) Find the centre of the object : #local ObjCentre = (TopRight + BottomLeft )/2; // 4) Place your object at the origin. Center "on" places the the 'center' of the object at the origin; // with Center "off", the 'base' of the object is placed at the origin : #if (Center) #local Obj = object {Obj translate -ObjCentre } #else #local Obj = object {Obj translate <-ObjCentre.x, BottomLeft.y, -ObjCentre.z> } #end // 5) Optionally, you can scale it to fit and prevent clipping : #local Extent = max(TopRight.x, TopRight.y, TopRight.z); // Find the largest dimension // Standardize the dimension to your needs. DimFactor=1 effectively scales your object down to a size of 1 unit; // other values scales the object up or down : #declare Obj = object {Obj scale DimFactor/Extent} // 6) Finally, place the object in your scene : Obj #end //of macro //======================================================================================================= /* Usage example in a scene: ------------------------- 1) Include the macro: #include "AM_Resize to standard.inc" 2) Apply the macro to your object (example with "the Bunny"): #include "bunny_POV_geom.inc" #declare Bunny = object {bunny_ rotate 180*y } object { Resize (Bunny, off, 1) //resizing the object to 1 pov-unit rotate 10*y translate -0.5*z translate 1.0*x } */