POV-Ray : Newsgroups : povray.text.scene-files : hf grids Server Time
1 Nov 2024 11:14:45 EDT (-0400)
  hf grids (Message 1 to 1 of 1)  
From: Paul Jones
Subject: hf grids
Date: 2 Nov 2000 13:48:33
Message: <3A01B619.876B1578@psu.edu>
// begin code

/*This will take any height field and make a grid which follows
the contours of the height field. */

#version Unofficial Megapov 0.6;

#include "colors.inc"

global_settings
{
  assumed_gamma 1.0
}

// ----------------------------------------
camera
{
  location  <0.0, 4, -5.0>
  direction 1.5*z
  right     4/3*x
  look_at   <0.0, 0.0,  0.0>
}

sky_sphere
{
  pigment
  {
    color Black
  }
}

light_source
{
  0*x // light's position (translated below)
  color red 1.0  green 1.0  blue 1.0  // light's color
  translate <-30, 30, -30>
}

//this determines the final size of the height field. It is used
// used to scale and translate tthe HF so it is centered at the origin
(<0,0,0>).


#declare square_size  = 5

//This reads in the height field data
#debug "start height field parsing\n"
#declare hf = 
height_field
{
  tga               
  
  "d:\glass group users\paul\pov\hf1.tga"     // the path and file to be
read
texture {pigment {color Red transmit 0.6}}  

smooth
scale <square_size,1,square_size> translate
<-square_size/2,0,-square_size/2>
}
#debug "finish height field parsing\n"
 




  

  

//create Mesh
#declare interval = square_size/80; // the higher the number, the finer
the grid patter


#declare CX =  -square_size/2+interval/2;   // do not alter
#declare CZ = -square_size/2+interval/2;    //do not alter  
#declare cyl_width = 0.005;                 //width of the cylinder
components of the grid
#declare cyl_tex = texture{pigment {color Green } } // texture of the
grid itself


        #debug "Starting grid formation\n"
 
 #declare grid =
        union{
        #while (CX < square_size/2-interval/2) 
        #debug concat ( "CX = ", str (CX,3,3)," of ", str(square_size/2
,3,3), "\n")
                  #while (CZ < square_size/2-interval/2)
                        #declare YValue = trace (hf, <CX,20,CZ>, -y);
                        #declare YValueX1 = trace (hf,
<CX+interval,20,CZ>, -y);
                        #declare YValueZ1 = trace (hf,
<CX,20,CZ+interval>, -y);   
                        
                        #if (YValue.x = 0 & YValue.y = 0 & YValue.z = 0)
                        #else
                        
                                cylinder {<CX,YValue.y,CZ>
<CX+interval,YValueX1.y,CZ> cyl_width texture {cyl_tex}}
                                cylinder {<CX,YValue.y,CZ>
<CX,YValueZ1.y,CZ+interval> cyl_width texture {cyl_tex}}                
                        #end
                        #declare CZ = CZ + interval;
                        #end
        #declare CZ = -square_size/2+interval/2   ;
        #declare CX = CX + interval;
           
        #end 

// cap off +X axis 
#declare CX1 =  square_size/2-interval/2;
#declare CZ1 = -square_size/2+interval/2; 
    
    #while (CZ1 <= square_size/2-interval/2)
          #declare YValue = trace (hf, <CX1,20,CZ1>, -y);
          #declare YValueX1 = trace (hf, <CX1+interval,20,CZ1>, -y);
          #declare YValueZ1 = trace (hf, <CX1,20,CZ1+interval>,
-y);         
        
        
        cylinder {<CX1,YValue.y,CZ1> <CX1,YValueZ1.y,CZ1+interval>
cyl_width texture {cyl_tex}}               
        
        
        #declare CZ1 = CZ1 + interval;
           
    #end 
    
    // cap off +z axis 
#declare CX2 =  -square_size/2+interval/2;
#declare CZ2 = square_size/2-interval/2; 

    #while (CX2 <= square_size/2-interval/2)
          #declare YValue = trace (hf, <CX2,20,CZ2>, -y);
          #declare YValueX1 = trace (hf, <CX2+interval,20,CZ2>, -y);
          #declare YValueZ1 = trace (hf, <CX2,20,CZ2+interval>,
-y);         
        
        
        cylinder {<CX2,YValue.y,CZ2> <CX2+interval,YValueX1.y,CZ2>
cyl_width texture {cyl_tex}}               
        
        
        #declare CX2 = CX2 + interval;
           
    #end 

     }//end union
       
                                             

// objects

object {grid translate <0,1,0>}
object {hf}

//end code
-- 



--------------------------------------------------}
Paul Daniel Jones
The Pennslyvania State University

pdj### [at] psuedu
http://research.chem.psu.edu/glassgrp/paul

       C            The way is near, but men
     // \           seek it afar. It is in the
    N    N          easy things, but men seek it
    |    ||         in the difficult things.
    C    C          -Menicius
     \\  /
       C
--------------------------------------------------}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.