//------------------------------------------------------------------------------------------------------------ // Macro to output AABB coordinates of object [and] show constant thickness wire_box bounding box for designated object. // Bill Walker 2017 (POV-Ray user Bald Eagle) // A work in progress - trying to make this work with manual parameters, or with automated calculations // Usage: Loc (Object, Radius of wire_box wires, Show bounding box [yes/no] ) // If a vector variable "Location" is defined, use automatic parameters for bounding box wire thickness // Auto bounding box is made with cones to acheive a constant visible minute-of-angle (MOA) #macro Loc (Obj, R, BB) #ifndef (Shapes_Inc_Temp) #include "shapes.inc" // (required for shapes2.inc) #end #ifndef (Shapes2_Inc_Temp) #include "shapes2.inc" // (required for Wire_Box object) #end #local Rad = R; // if user-defined camera variables exist, override manual radius // display minimum visible radius #ifdef (Location) #declare Auto = yes; #macro MinRad (Vector) #ifndef (Angle) #local Angle = 67.38; #end #local Aspect = image_width/image_height; #local Dist = vlength (Vector-Location); #local M = (0.5*Aspect)/tan(radians(Angle/2)); #local ZA = Dist/M; #local Rad = (ZA/image_width)*Aspect; Rad #end // end macro MinRad #end // end check for camera Location variable #local Min = min_extent (Obj); #local Max = max_extent (Obj); #local Center = (Min+Max)/2; #debug concat ("Object is located at <", vstr(3, Center, ", ", 3, 3), "> \n") #debug concat ("Object extends from <", vstr(3, Min, ", ", 3, 3), "> to <", vstr(3, Max, ", ", 3, 3), "> \n") #if (BB) #ifdef (Auto) #local LBF = Min; #local LBFr = MinRad (LBF); #local RBF = ; #local RBFr = MinRad (RBF); #local LTF = ; #local LTFr = MinRad (LTF); #local RTF = ; #local RTFr = MinRad (RTF); #local LBR = ; #local LBRr = MinRad (LBR); #local RBR = ; #local RBRr = MinRad (RBR); #local LTR = ; #local LTRr = MinRad (LTR); #local RTR = Max; #local RTRr = MinRad (RTR); union { sphere {LBF, LBFr} cone {LBF, LBFr, LBR, LBRr} sphere {LBR, LBRr} cone {LBR, LBRr, RBR, RBRr} sphere {RBR, RBRr} cone {RBR, RBRr, RBF, RBFr} sphere {RBF, RBFr} cone {RBF, RBFr, LBF, LBFr} cone {LBF, LBFr, LTF, LTFr} cone {LBR, LBRr, LTR, LTRr} cone {RBR, RBRr, RTR, RTRr} cone {RBF, RBFr, RTF, RTFr} sphere {LTF, LTFr} cone {LTF, LTFr, LTR, LTRr} sphere {LTR, LTRr} cone {LTR, LTRr, RTR, RTRr} sphere {RTR, RTRr} cone {RTR, RTRr, RTF, RTFr} sphere {RTF, RTFr} cone {RTF, RTFr, LTF, LTFr} texture { pigment {color rgb <0.6, 0, 0>} //finish {specular 0.6} } // end texture no_shadow } // end union #else union { object {Wire_Box (Min, Max, Rad, no) texture { pigment {color rgb <0.6, 0, 0>} finish {specular 0.6} } // end texture } // end object Wire_Box cylinder {Min, , Rad texture {pigment {Green*0.6} finish {specular 0.6} }} cylinder {, , Rad texture {pigment {Green*0.6} finish {specular 0.6} }} no_shadow } // end union #end #end // end if #end // end macro Loc //------------------------------------------------------------------------------------------------------------