Advertisement
FoxyCorndog

Castle

Mar 30th, 2012
1,324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Lego.pov"
  2.  
  3. #declare brickWidth      = 10;
  4. #declare brickHeight     = 3.5;
  5. #declare brickLength     = 5;
  6.  
  7. #declare random          = seed(1000);
  8.  
  9. #declare leftRight       = 0;
  10. #declare forwardBackward = 1;
  11. #declare aFloor          = 2;
  12.  
  13. #declare zoom = 100;
  14.  
  15. camera
  16. {
  17.     location <500, 200, -500>
  18.     look_at <0, 0, 0>
  19. }
  20.  
  21. light_source
  22. {
  23.     <500, 1000, 0>
  24.     //<0, 50 * 3, -10 * 7 * 3>
  25.     color rgb <1, 1, 1>
  26. }
  27.  
  28. light_source
  29. {
  30.     <-500, 1000, 0>
  31.     //<0, 50 * 3, -10 * 7 * 3>
  32.     color rgb <1, 1, 1>
  33. }
  34.  
  35. light_source
  36. {
  37.     <0, 1000, 500>
  38.     //<0, 50 * 3, -10 * 7 * 3>
  39.     color rgb <1, 1, 1>
  40. }
  41.  
  42. light_source
  43. {
  44.     <0, 1000, -500>
  45.     //<0, 50 * 3, -10 * 7 * 3>
  46.     color rgb <1, 1, 1>
  47. }
  48.  
  49. light_source
  50. {
  51.     <0, 1000, 0>
  52.     //<0, 50 * 3, -10 * 7 * 3>
  53.     color rgb <1, 1, 1>
  54. }
  55.  
  56. sky_sphere
  57. {
  58.   pigment
  59.   {
  60.     color rgb <0, .5, 0>
  61.   }
  62. }
  63.  
  64. // uses image color index as height, extends along X-Z axes
  65. // from <0 0 0> to <1 1 1>
  66. height_field {
  67.   png
  68.         "heightMapRiver.png"    
  69.         smooth    
  70.         water_level 0.055
  71.         texture
  72.         {
  73.                
  74.                 pigment
  75.                 {
  76.                         color rgb <0, 0, .5>
  77.                 }
  78.            
  79.         }
  80.         //rotate <0, 90, 0>
  81.        
  82.         #declare scaleFactor = 8.7;
  83.        
  84.         scale <640 * scaleFactor, 5 ,400 * scaleFactor>
  85.         translate <-315 * scaleFactor, -1 , -175 * scaleFactor>  
  86. }
  87.  
  88. #declare showCenter = false;
  89.  
  90. #if (showCenter)
  91.     box
  92.     {
  93.         <-3 * brickWidth, 0, 10>
  94.         <3 * brickWidth, 10, 0>
  95.        
  96.         pigment
  97.         {
  98.             color rgb <1, 1, 0>
  99.         }
  100.     }
  101.    
  102.     box
  103.     {
  104.         <-1, 0, 10.5>
  105.         <1, 10.5, -0.5>
  106.        
  107.         pigment
  108.         {
  109.             color rgb <1, 0, 0>
  110.         }
  111.     }
  112. #end
  113.  
  114. #macro buildObject(varWidth, varHeight, varLength, varX, varY, varZ, varType, varCrenulate varMirrorX, varMirrorZ)
  115.     #declare vx = 0;
  116.     #declare vy = 0;
  117.    
  118.     #declare varX = varX * brickWidth;
  119.     #declare varY = varY * brickHeight;
  120.     #declare varZ = varZ * brickLength;
  121.    
  122.     #if (varType = leftRight)
  123.         #declare vw = varWidth;
  124.         #declare vh = varHeight;
  125.     #end
  126.     #if (varType = forwardBackward)
  127.         #declare vw = varLength;
  128.         #declare vh = varHeight;
  129.     #end
  130.     #if (varType = aFloor)
  131.         #declare vw = varWidth;
  132.         #declare vh = varLength;
  133.        
  134.         #declare varCrenulate = false;
  135.     #end
  136.    
  137.     #declare f = 1;
  138.     #declare draw = true;
  139.    
  140.     #while (vx < vw)
  141.         #while (vy < vh)
  142.             #declare r = 0.5 - rand(random) / 5;
  143.             #declare g = 1 - rand(random); // / 5;
  144.             #declare b = 1 - rand(random); // / 5;
  145.            
  146.             //#declare g = r;
  147.             //#declare b = r;
  148.            
  149.             #if (varCrenulate)
  150.                 #if (vy = vh - 1)
  151.                     #if (f = 1)
  152.                         #declare draw = false;
  153.                         #declare f = 0;
  154.                     #else
  155.                         #declare f = 1;
  156.                     #end
  157.                 #else
  158.                 #end
  159.             #else
  160.             #end
  161.            
  162.             #if (draw)
  163.                 box
  164.                 {
  165.                     #if (varType = leftRight)
  166.                         <vx * brickWidth + varX, vy * brickHeight + varY, varZ>
  167.                         <vx * brickWidth + brickWidth + varX, vy * brickHeight + brickHeight + varY, brickLength + varZ>
  168.                        
  169.                         createLego(vx * brickWidth + varX, vy * brickHeight + varY, varZ,
  170.                                     4, 2, 2,
  171.                                     <180, 0, 0>,
  172.                                     <1, 0, 0>)
  173.                     #end
  174.                    
  175.                     #if (varType = forwardBackward)
  176.                         <varX, vy * brickHeight + varY, vx * brickWidth + varZ>
  177.                         <brickLength + varX, vy * brickHeight + brickHeight + varY, vx * brickWidth + brickWidth + varZ>
  178.                     #end
  179.                    
  180.                     #if (varType = aFloor)
  181.                         <vx * brickWidth + varX, varY, vy * brickLength + varZ>
  182.                         <vx * brickWidth + brickWidth + varX, brickHeight + varY, vy * brickLength + brickLength + varZ>
  183.                     #end
  184.  
  185.                     pigment
  186.                     {
  187.                         color rgb <r, g, b>
  188.                     }
  189.                 }
  190.             #end
  191.            
  192.             #declare draw = true;
  193.            
  194.             #declare vy = vy + 1;
  195.         #end
  196.        
  197.         #declare vx = vx + 1;
  198.         #declare vy = 0;
  199.     #end
  200.    
  201.     #if (varMirrorZ)
  202.         #if (varType = forwardBackward)
  203.             #declare w = -(varLength - 1) * 2;
  204.         #end
  205.        
  206.         #if (varType = aFloor)
  207.             #declare w = -(varLength - 2);
  208.         #end
  209.        
  210.         #if (varType = leftRight)
  211.             #declare w = varLength;
  212.         #end
  213.    
  214.         #declare varX = ( varX / brickWidth);
  215.         #declare varY = ( varY / brickHeight);
  216.         #declare varZ = (-varZ / brickLength) + w;
  217.    
  218.         buildObject(varWidth, varHeight, varLength, varX, varY, varZ, varType, varCrenulate, false, false)
  219.     #end
  220.    
  221.     #if (varMirrorX)
  222.         #if (varType = forwardBackward)
  223.             #declare w = varWidth / 2;
  224.         #else
  225.             #declare w = varWidth;
  226.         #end
  227.    
  228.         #declare varX = (-varX / brickWidth) - (w);
  229.         #declare varY = ( varY / brickHeight);
  230.         #declare varZ = ( varZ / brickLength);
  231.    
  232.         buildObject(varWidth, varHeight, varLength, varX, varY, varZ, varType, varCrenulate, false, varMirrorZ)
  233.     #end
  234. #end
  235.  
  236.  
  237. #macro createLego(varX, varY, varZ, varWidth, varHeight, varLength, varRot, varColor)
  238.     #declare cylinderHeight = .3;
  239.    
  240.     object
  241.     {
  242.         merge
  243.         {
  244.             box
  245.             {
  246.                 <-varWidth / 2, -varHeight / 2, -varLength / 2>
  247.                 < varWidth / 2,  varHeight / 2,  varLength / 2>
  248.                
  249.                 pigment
  250.                 {
  251.                     color rgb varColor
  252.                 }
  253.             }
  254.            
  255.             #declare vx = 1;
  256.             #declare vy = 1;
  257.             #declare vz = 1;
  258.        
  259.             #while (vz < varLength * 2)
  260.                 #while (vx < varWidth * 2)
  261.                     cylinder
  262.                     {
  263.                         <(-varWidth / 2) + (varWidth * (vx / 8)), (varHeight / 2)     , (-varLength / 2) + (varLength * (vz / 4))>
  264.                         <(-varWidth / 2) + (varWidth * (vx / 8)), (varHeight / 2) + .3, (-varLength / 2) + (varLength * (vz / 4))>
  265.                        
  266.                         .375
  267.                        
  268.                         pigment
  269.                         {
  270.                             color rgb varColor
  271.                         }
  272.                     }
  273.                    
  274.                     #declare vx = vx + 2;
  275.                 #end
  276.                
  277.                 #declare vx = 1;
  278.                 #declare vz = vz + 2;
  279.             #end
  280.         }
  281.        
  282.         rotate varRot
  283.        
  284.         translate <varX + (varWidth / 2), varY + (varHeight / 2), varZ + (varLength / 2)>
  285.     }
  286. #end
  287.  
  288. //#macro buildWalls()
  289. //  buildObject(8 , 10, 1 , 3    , 0 , -25 , leftRight      , true , true , false)
  290. //  buildObject(10, 10, 1 , 1    , 0 , -20 , leftRight      , true , true , false)
  291. // 
  292. //  buildObject(22, 10, 1 , -11  , 0 ,  26 , leftRight      , true , false, false)
  293. //  buildObject(1 , 10, 17, 14.5 , 0 , -16 , forwardBackward, true , true , false)
  294. // 
  295. //  buildObject(22, 10, 1 , -11  , 0 ,  22 , leftRight      , true , false, false)
  296. //#end
  297. //
  298. //#macro buildCornerTowers()
  299. //  buildObject(6 , 20, 1 , 11   , 0 , -29 , leftRight      , true , true , true )
  300. //  buildObject(1 , 20, 2 , 11   , 0 , -28 , forwardBackward, true , true , true )
  301. //  buildObject(1 , 20, 6 , 16.5 , 0 , -28 , forwardBackward, true , true , true )
  302. //  buildObject(2 , 20, 1 , 14.5 , 0 , -17 , leftRight      , true , true , true )
  303. //#end
  304. //
  305. //#macro buildPlatforms()
  306. //  buildObject(5 , 1 , 11, 11.5 , 16, -28 , aFloor         , false, true , true )
  307. //  buildObject(22, 1 , 4 , -11  , 6 , -24 , aFloor         , false, false, true )
  308. //#end
  309. //
  310. //#macro buildCenterTower()
  311. //  buildObject(6 , 20, 1 , -3   , 0 , -6 , leftRight      , true , false , true )
  312. //#end
  313. //
  314. //#macro buildHouse(varX, varY, varZ)
  315. //
  316. //#end
  317.  
  318. #macro buildWalls()
  319.     buildObject(20, 10, 1 ,    3    , 0 , -25 ,    leftRight      , true , true , false)
  320.     buildObject(22, 10, 1 ,    1    , 0 , -20 ,    leftRight      , true , true , false)
  321.    
  322.     buildObject(34, 10, 1 ,    -19  , 0 ,  26 ,    leftRight      , true , false, false)
  323.     buildObject(1, 10, 33,    23 , 0 , -24 ,    forwardBackward, true , true , false)
  324.    
  325.     buildObject(34, 10, 1 ,    -19  , 0 ,  22 ,    leftRight      , true , false, false)
  326. #end
  327.  
  328. #macro buildCornerTowers()
  329.     buildObject(12, 30, 1 ,    21.5   , 0 , -57 ,    leftRight      , true , true , true )
  330.     buildObject(1 , 30, 4 ,    22   , 0 , -56.5 ,    forwardBackward, true , true , true )
  331.     buildObject(1 , 30, 12 ,    33 , 0 , -56 ,    forwardBackward, true , true , true )
  332.     buildObject(4 , 30, 1 ,    29 , 0 , -33 ,    leftRight      , true , true , true )
  333. #end
  334.  
  335. #macro buildPlatforms()
  336.     buildObject(5 , 1 , 11,    11.5 , 16, -28 ,    aFloor         , false, true , true )
  337.     buildObject(22, 1 , 4 ,    -11  , 6 , -24 ,    aFloor         , false, false, true )
  338. #end
  339.  
  340. #macro buildCenterTower()
  341.     buildObject(6 , 60, 1 ,    -3   , 0 , -6 ,    leftRight      , true , false , true )
  342. #end
  343.  
  344. #macro buildHouse(varX, varY, varZ)
  345.  
  346. #end
  347.  
  348. buildCornerTowers()
  349. //buildWalls()
  350. buildCenterTower()
  351. //buildPlatforms()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement