// tool to find exact positions for an object on your ground or whatever - not very mature // during render you see the position and inclination in the message window (Alt+M), after finishing you have to scroll // definitions __________________________________________________________________ #declare x_pos = 30; // between 0 for left and 100 for right image edge #declare y_pos = 60; // between 0 for sky and 100 for lower image egde #declare cam_loc = <-1,1.5,3>; #declare lookat = <-0.25,0.5,0>; #declare cam_ang = 30; #declare areal = height_field { function 100,100 { pattern {bozo scale 0.2} } smooth translate <-0.5,0,-0.5> scale <4,0.5,4> texture { pigment {color rgb <0.5,1,0.3>} normal {bozo scale 0.02} finish {ambient 0 diffuse 0.6} } double_illuminate hollow } // macro stuff __________________________________________________________________ #macro pos_finder (areal, cam_loc, lookat, cam_ang, x_pos, y_pos, sign_scale) #include"transforms.inc" #declare cam_mirror = 1; // 1 for normal / -1 for mirror image #declare cam_z = 0.5*image_width/image_height/tan(radians(cam_ang*0.5)); // amount of camera zoom #declare cam_a = cam_mirror*image_width/image_height; // camera aspect ratio #declare cam_s = y; // camera sky vector #declare cam_d = vnormalize (lookat-cam_loc); // camera direction vector #declare cam_r = vnormalize (vcross(cam_s,cam_d)); // camera right vector #declare cam_up = vnormalize (vcross(cam_d,cam_r)); // camera up vector #declare cam_dir = cam_d*cam_z; // direction vector scaled #declare cam_right = cam_r*cam_a; // right vector scaled #declare dir_y = vaxis_rotate (lookat-cam_loc,vcross (lookat-cam_loc,cam_up),(0.5-y_pos*0.01)*cam_ang/image_width*image_height); #declare dir_xy = vaxis_rotate (dir_y,cam_up,(0.5-x_pos*0.01)*cam_mirror*cam_ang); #declare Norm = <0,0,0>; #declare Inter = trace (areal,cam_loc,dir_xy,Norm); #if (vlength (Norm) != 0) #declare rx = degrees (atan2 (Norm.z,Norm.y)); #declare rz = -degrees (atan2 (Norm.x,Norm.y)); #declare precise = 3; // number of digits shown in message window union { cylinder {0.2*y,1*y,0.05} cone {0,0,0.2*y,0.08} text { ttf "cyrvetic.ttf" concat ("rotate <",str (rx,0,precise-1),",0,",str (rz,0,precise-1),">") 0.1,0 scale 0.1 rotate <-rx,0,-rz> translate <0.1,0.6,0> } text { ttf "cyrvetic.ttf" concat ("translate <",str (Inter.x,0,precise),",",str (Inter.y,0,precise),",",str (Inter.z,0,precise),">") 0.05,0 scale 0.1 rotate <-rx,0,-rz> translate <0.1,0.48,0> } texture { pigment {color rgb x} finish {ambient 0 diffuse 1 specular 0.3 roughness 0.1 reflection 0.15} } scale sign_scale rotate translate Inter } #debug concat (" \n") #debug concat ("rotate <",str (rx,0,precise-1),",0,",str (rz,0,precise-1),">\n") #debug concat ("translate <",str (Inter.x,0,precise),",",str (Inter.y,0,precise),",",str (Inter.z,0,precise),">\n") #debug concat (" \n") #else #debug concat (" \n") #debug concat ("position not on areal, please try other x_pos or y_pos values\n") #debug concat (" \n") #end #end // scene __________________________________________________________________ pos_finder (areal, cam_loc, lookat, cam_ang, x_pos, y_pos, 0.5) camera { location cam_loc look_at lookat right cam_right angle cam_ang } light_source {0 color rgb 1 translate <-200,400,150>} light_source {0 color rgb 0.25 shadowless translate cam_loc} background {color rgb 1} object {areal}