// Last edited on 2008-08-13 13:52:29 by stolfi // Room room macro #include "chair_dimensions.inc" #include "desk_dimensions.inc" #declare debug_lighting = false; #declare wall_texture = texture { pigment { color rgb < 0.800, 0.830, 0.850 > } finish { ambient 0.25 diffuse 0.70 specular 0.05 roughness 0.05 } } #declare floor_texture = texture { pigment { color rgb < 0.900, 0.900, 0.900 > } finish { ambient 0.25 diffuse 0.70 specular 0.05 roughness 0.05 } } #declare ceiling_texture = texture { pigment { color rgb < 0.800, 0.800, 0.800 > } finish { ambient 0.25 diffuse 0.75 } } #declare door_texture = texture { pigment { color rgb 0.90*< 0.800, 0.830, 0.850 > } finish { ambient 0.25 diffuse 0.70 specular 0.05 roughness 0.05 } } #declare air_conditioner_texture = texture { pigment { color rgb < 0.900, 0.850, 0.750 > } finish { ambient 0.15 diffuse 0.75 specular 0.15 roughness 0.05 } } #declare hub_texture = texture { pigment { color rgb < 0.400, 0.500, 0.600 > } finish { ambient 0.25 diffuse 0.60 specular 0.15 roughness 0.005 } } #declare door_transp_texture = texture { pigment { color rgb 0.90*< 0.800, 0.830, 0.850 > transmit 0.800 } finish { ambient 0.25 diffuse 0.70 specular 0.05 roughness 0.05 } } #declare teacher_texture = texture { pigment { color rgb < 1.000, 0.800, 0.600 > } finish { ambient 0.25 diffuse 0.75 } } #declare chalk_texture = texture { pigment { color rgb < 1.000, 1.000, 1.000 > } finish { ambient 0.25 diffuse 0.75 } } #declare shocking_texture = texture { pigment { color rgb < 1.000, 0.850, 0.750 > } finish { ambient 0.75 diffuse 0.25 } } #include "chair.inc" #include "desk.inc" #include "human.inc" #macro room_5(wx,wz,wy, scrk,chrk, twall,swall,bwall) // A model of a standard office in IC-1/2. // The words "left", "right", "front"and "back" are relative to the // person LEAVING the office. // The "front wall" is where the door is. // // {wx,wy,wz} = room dimensions, wall-to-wall (excl. walls). // If {dskk>0}, also puts desks of type {dskk}. // If {chrk>0}, also puts chairs of type {chrk}. // If {twall=true}, includes ceiling. // If {swall=true}, side walls have full height. // If {bwall=true}, includes the room's back wall. // // The origin <0,0,0> is at the lower left corner of the front wall. // The X axis points from left to right. // The Y axis points *forward*, so the whole room has negative Y values. #local wall_thk = 0.150; // Thickness of walls. union { // Exterior bounding box (including walls): #local elo_x = -wall_thk; #local ehi_x = wx + wall_thk; #local elo_y = -wy - wall_thk; #local ehi_y = wall_thk; #local elo_z = -wall_thk; #local ehi_z = wz + wall_thk; // Floor: wall_slab(z,elo_z,0, x,elo_x,ehi_x, y,elo_y,ehi_y, floor_texture) // Front wall: wall_slab(y,0,ehi_y, x,elo_x,ehi_x, z,0,wz, wall_texture) #if (twall) // Ceiling: wall_slab(z,wz,ehi_z y,elo_y,ehi_y, x,elo_x,ehi_x, ceiling_texture) #end #if (swall) // Full-height left wall, with windows and blinds: #local win_wy = 3.000; // ??? Y extent (width) of window hole. #local win_wz = 0.500; // ??? Z extent (height) of window hole. #local win_1_dy = -1.000; // ??? Y displ. of window 1 from front wall. #local win_2_dy = -5.000; // ??? Y displ. of window 2 from front wall. #local win_dz = wz - win_wz - 0.050; // ??? Z displ. of windows from floor. #local win_hole = object { wall_hole(x,-wall_thk,0, y,0,win_wy, z,0,win_wz, wall_texture ) } #local win_obj = object { empty_object() } union { difference { wall_slab(x,elo_x,0, y,0,-wy, z,0,wz, wall_texture) object { win_hole translate win_1_dy*y + win_dz*z } object { win_hole translate win_2_dy*y + win_dz*z } } object { win_obj translate win_1_dy*y + win_dz*z } object { win_obj translate win_2_dy*y + win_dz*z } } // Full-height right wall: wall_slab(x,wx,ehi_x, y,0,-wy, z,0,wz, wall_texture) #else // Half-height side walls: wall_slab(x,elo_x,0, y,0,-wy, z,0,wz/2, wall_texture) wall_slab(x,wx,ehi_x, y,0,-wy, z,0,wz/2, wall_texture) #end #local door_wdt = 0.820; // ??? Width of door. #local door_hgt = 2.080; // ??? Height of door. #local door_thk = 0.030; // Thickness of door. #local door_of_x = 0.150; // ??? Distance from door to right wall. #local door_of_y = 0.060; // ??? Door inset. #local door_hi_x = +wx - door_of_x; // Hi X of door. #local door_lo_x = door_hi_x - door_wdt; // Lo X of door. #local door_hi_y = -wy - door_of_y; // Hi Y of door. #local door_lo_y = door_hi_y - door_thk; // Lo Y of door. #local door_rev = true; // Higes on the hi X side. #if (bwall) // Back wall: difference { wall_slab(y,elo_y,-wy x,elo_x,ehi_x, z,0,wz, wall_texture) wall_hole(y,elo_y,-wy, x,door_lo_x,door_hi_x, z,0,door_hgt, wall_texture) } door(y,door_lo_y,door_hi_y, x,door_lo_x,door_hi_x, z,0,door_hgt, door_rev,+85, door_texture) #end // Air-conditioning units #if (swall) #local ac_wx = 0.500; // X extent of air conditioner. #local ac_wy = 1.200; // Y extent of air conditioner. #local ac_wz = 0.300; // Z extent of air conditioner. #local ac_of_x = 0.050; // X gap between air contitioner and right wall. #local ac_of_z = 2.880; // Z of bottom of conditioner. #local ac_A_ctr_y = -0.25*wy; // Y of center of conditioner A #local ac_B_ctr_y = -0.75*wy; // Y of center of conditioner B object { air_conditioner(ac_wy,ac_wx,ac_wz, air_conditioner_texture) rotate 90*z translate (wx - ac_of_x)*x translate ac_A_ctr_y*y translate ac_of_z*z } object { air_conditioner(ac_wy,ac_wx,ac_wz, air_conditioner_texture) rotate 90*z translate (wx - ac_of_x)*x translate ac_B_ctr_y*y translate (ac_wz/2 + ac_of_z)*z } #end // !!! Here should come the chairs #if (dskk > 0) // Desk: #if (dskk = 1) // L-shaped desk. #end // Plop the desk: object { desk( desk_dx, desk_dy, desk_dz, desk_wx, desk_wy, desk_rad, show_dims ) } #local teacher_z = 0; #local teacher_y = 1500; #else #local teacher_z = 0; #local teacher_y = 1500; #end // !!! Whiteboard #if (swall) #end // Teacher #local teacher_wz = 1.720; object { human(teacher_wz,1.00,false) texture { teacher_texture } translate (wx - chair_gap_x - 1.5*chair_wx)*x translate teacher_y*y + teacher_z*z } #if (debug_lighting) // Lighting gauge on top of desk: sphere { < 0, 0, 0 >, 0.200 translate (wx - bb_of_x - bb_wx/2)*x translate -wall_thk*y translate (bb_of_z + bb_wz/2)*z texture { chalk_texture } } #end #if (scrk > 0) #if (scrk = 1) // Old style #local screen_wx = 1.740; #local screen_wz = 1.160; #local screen_of_x = wx - screen_wx; #local screen_of_z = 1.500; #local screen_ang = -20; #end #if (scrk = 2) // New style #local screen_wx = 1.740; #local screen_wz = 1.160; #local screen_of_x = door_of_x + door_wdt + door_of_x; #local screen_of_z = 1.550; #local screen_ang = 0; #end #if (scrk = 3) // Centered high up #local screen_wx = 1.740; #local screen_wz = 1.160; #local screen_of_x = (wx - screen_wx)/2; // X dist btw left wall and screen. #local screen_of_y = 0.050; // Y dist btw screen and front wall. #local screen_of_z = wz - 0.050 - screen_wz; // Z dist btw floor and bot of screen. #local screen_tilt = 0; #local screen_ang = 0; #end object { screen ( -y, x,screen_wx, z,screen_wz ) rotate screen_tilt*x rotate screen_ang*z translate screen_of_x*x + screen_of_z*z translate -wall_thk/2*y } #end } #end #macro wall_slab(dir1,lo1,hi1, dir2,lo2,hi2, dir3,lo3,hi3, txure) // A box-like block of material, e.g. wall, floor slab, roof slab, etc. // {thk} is the wall thickness. // {dir1} is normal axis ({x},{y}, or {z}), {dir2,dir3} are the other two axes. // {lo1,hi1,lo2,hi2,lo3,hi3} are the coordinate intervals along {dir1,dir2,dir3}. #local eps = 0.0001; box { dir1*(lo1+eps) + dir2*(lo2+eps) + dir3*(lo3+eps), dir1*(hi1-eps) + dir2*(hi2-eps) + dir3*(hi3-eps) texture { txure } } #end #macro wall_hole(dir1,lo1,hi1, dir2,lo2,hi2, dir3,lo3,hi3, txure) // A box to make the hole on a wall, e.g. for a door or window. // {dir1} is normal axis ({x},{y}, or {z}), {dir2,dir3} are the other two axes. // {lo1,hi1,lo2,hi2,lo3,hi3} are the coordinate intervals along {dir1,dir2,dir3}. #local eps = 0.0001; #local del = 0.005; box { dir1*(lo1-del) + dir2*(lo2+eps) + dir3*(lo3+eps), dir1*(hi1+del) + dir2*(hi2-eps) + dir3*(hi3-eps) texture { txure } } #end #macro door(dir1,lo1,hi1, dir2,lo2,hi2, dir3,lo3,hi3, rev, ang, txure ) // A door, closed or open. // {dir1} is normal axis ({x},{y}, or {z}), {dir2,dir3} are the other two axes. // {lo1,hi1,lo2,hi2,lo3,hi3} are the coordinate intervals along {dir1,dir2,dir3}. // {rev=false} puts hinges at {dir1*lo1}, {rev=true} puts hinges at {dir1*hi1}. // {ang} is how much the door is open (degrees). // The door hinges are at the {lo2} position of {dir2}. #local eps = 0.0002; box { dir1*eps + dir2*eps + dir3*(lo3+eps), dir1*(hi1-lo1-eps) + dir2*(hi2-lo2-eps) + dir3*(hi3-eps) rotate ang*dir3 texture { txure } #if (rev) scale + 1*dir1 - 1*dir2 + 1*dir3 translate dir1*hi1 + dir2*lo2 #else translate dir1*lo1 + dir2*lo2 #end } #end #macro door_anim(dir1,lo1,hi1, dir2,lo2,hi2, dir3,lo3,hi3, rev, ang, txure, txint) // An "animated" door. // Same as {door}, but also shows intermediate positions with texture {txint}. #local eps = 0.0002; #local pane = box { dir1*eps + dir2*eps + dir3*(lo3+eps), dir1*(hi1-lo1-eps) + dir2*(hi2-lo2-eps) + dir3*(hi3-eps) } union{ object { pane rotate 0.000*ang*dir3 texture { txint } } object { pane rotate 0.333*ang*dir3 texture { txint } } object { pane rotate 0.667*ang*dir3 texture { txint } } object { pane rotate 1.000*ang*dir3 texture { txure } } translate dir1*lo1 + dir2*lo2 } #end #macro air_conditioner(wx,wy,wz, txure) // An air conditioning unit. // {wx,wy,wz} dimensions of air conditioning unit. // {txure} Body texture. // The bottom face is at Z = 0, the back face is at Y = 0. // The air openings are at the +Y face. // The origin will be at the midpoint of the back bottom edge. #local eps = 0.0223; box { < -wx/2+eps, 0+eps, 0+eps >, < +wx/2-eps, wy-eps, wz-eps > texture { txure } } #end #macro net_hub(pos_x,sz_x, pos_y,sz_y, pos_z,sz_z, txure) // A networking cabinet. // {pos_x,pos_y,pos_z} are the starting positions along those axes. // {sz_x,sz_y,sz_z} are the extents along those axes. box { < pos_x, pos_y, pos_z > < pos_x, pos_y, pos_z > + < sz_x, sz_y, sz_z > texture { txure } } #end