POV-Ray : Newsgroups : povray.binaries.tutorials : Tutorial to make Grid-Patterns and Wireframes Server Time: 14 Dec 2018 01:45:21 GMT
  Tutorial to make Grid-Patterns and Wireframes (Message 1 to 1 of 1)  
From: Meothuru
Subject: Tutorial to make Grid-Patterns and Wireframes
Date: 12 Oct 2007 05:40:01
Message: <web.470f083961a4a39a5a73e3b40@news.povray.org>
This tutorial will show you, how to create wireframe-models and
grid-patterns in a quick and easy way.

To create wireframes and grids, POV-Ray offers the special-pattern:

 Tiles_Ptrn()

With this pattern you can create tiled patterns - and the grid-pattern
is the "mother of all tiled patterns". So in this way you can create
wireframe-models and grid-patterns by "pigmenting" the figures,
with this special pattern.

A first example:
//------------------------------------------
#include "textures.inc"

plane { <0,1,0>,0
   pigment {
      Tiles_Ptrn()
      color_map{
         [0.00 color rgb <1,1,1>]   // white stanchions
         [0.04 color rgb <0,0,0>]  // black spaces
      }
      rotate x*90  // rotates the pattern onto the "upper side" of the plane
   }
}

light_source {<5,5,-5>,1}
camera {location <5,5,-5> look_at 0}
//-------------------------------------------

This short example shows a black plane with a white grid-pattern.

So far, so good...but wireframe-models are transparent.This is no
problem...for
creating wireframes, we only have to modify the color_map a litte bit. We
make
the black spaces simply transparent - and this looks likes this:

      color_map{
         [0.00 color rgb <1,1,1>]   // white stanchions
         [0.04 color rgbt <0,0,0,1>]  // transparent spaces
      }

That's all you have to do, to alternate a grid-pattern into a
wireframe-pattern.

In the same easy way you can modify  the thickness of the stanchions.
You simply change the value of the second entry. i.e.

      color_map{
         [0.00 color rgb <1,1,1>]   // white stanchions
         [0.08 color rgbt <0,0,0,1>]  // transparent spaces
      }

Here the value was changed from 0.04 to 0.08 to make the stanchions thicker.
For thinner stanchions the value must be set to a lower value.But of course
this
method have limits.

In the next step, I demonstrate how to change the size and the ratio of the
pattern. To do this, you have to insert a "scale" in this way:

   pigment {
      Tiles_Ptrn()
      color_map{
         [0.00 color rgb <1,1,1>]   // white stanchions
         [0.04 color rgbt <0,0,0,1>]  // transparent spaces
      }
      scale <0.5, 1, 0.5>    // Here yo can set the size and ratio of the
grid
   }


For some figures it is necessary/sensefull to render the grid-pattern
with "uv_mapping" to get usable results.For example, we want
to render a sphere-figure, that shows a grid-pattern just like the
longitudes/latitudes on a globe. The next example will show such a
sphere-figure as a wireframe-model, with a "longitude/latitude"-pattern.

//---------------------------------
#include "colors.inc"
#include "textures.inc"

background {Gray75}

sphere{ <0,0,0>,3
   pigment {
      uv_mapping                         // render pattern with
"uv_mapping".
      Tiles_Ptrn()
      color_map{
         [0.00 color rgb <0,0,0>]      // black stanchions
         [0.06 color rgbt <0,0,0,1>]  // transparent spaces
      }
      scale <0.066, 0.066, 1>            // set size/ratio
   }
}

light_source {<5,5,-5>,1}
camera {location <5,5,-5> look_at 0}
//------------------------------------------------


And now let us create a litte more complexe wireframe-model.

//--------------------------------------------------
#include "textures.inc"

sky_sphere {
   pigment { gradient <0, 1, 0>
      color_map {
         [ 0 color rgb <0.054902, 0.219608, 0.4> ]
         [ 0.5 color rgb <0.960784, 0.960784, 0.960784> ]
         [ 1 color rgb <0.054902, 0.219608, 0.4> ]
      }
   }
}

union {
   sphere {  <0, 0, 0>, 1  translate -2*x  }

   cylinder { <1.1, 0, 0>, <-1.1, 0, 0>, 0.4
      open
      pigment {
         Tiles_Ptrn()
         color_map {
            [ 0 color rgb <0, 0, 0> ]
            [ 0.05 color rgbt <0, 0, 0, 1> ]
         }
         scale 0.2       // The cylinder must have his own, other scaled
wireframe-pattern.
      }                     // Because the cylinder have a smaller radius,
than the spheres.
      rotate x*45
   }

   sphere {  <0, 0, 0>, 1  translate 2*x }

   pigment {
      uv_mapping  //the wireframe-pattern for both spheres - but not for the
cylinder.
      Tiles_Ptrn()
      color_map {
         [ 0 color rgb <0, 0, 0> ]
         [ 0.05 color rgbt <0, 0, 0, 1>]
      }
      scale 0.05
   }
}

light_source { <4, 5, -5>, rgb <1, 1, 1>}
camera { location <5, 5, -5>   look_at 0 }
//------------------------------------------

OK...this is the end of this tutorial. I hope it helps you a litte bit, to
have more fun
with POV-Ray.


Post a reply to this message

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