The 2D Logo

The 2D Logo

Let's dive right into this project by showing a picture of the 2D logo I want to convert to 3D ( Figure 23-4 ). I used basic building blocks, or primitives, in my logo to be more effective at showing the conversion from 2D to 3D. As you can see, it's a fairly simple design. You should have noticed that the design is a repeating pattern. That's good, because it simplifies the task a bit. You'll see how later on. In PovRay, all measurements are in units. This makes it easy to describe in the PovRay language, but can be tricky when translating from a real-world object.

Figure 23-4. Image of 2D logo.

My first task was to draw out the logo on graph paper so I'd know exactly how many units each figure in the logo should be. This step paid off later, since it eventually helped me out with the 3D model. With the coordinates mapped out, it was a simple matter of entering a bunch of box, sphere, and triangle commands into my scene file, 2d_logo.pov.

  // Persistence-of-Vision Ray-Tracer Scene Description File  
  // File: 2d_logo.pov  
  // Auth: Steve Murphy  
   
  // ==== Standard POV-Ray Includes ====  
  #include "colors.inc" // Standard Color definitions  
   
  background { color White }  
   
  camera { location <0, 0, -30> look_at <0, 0, 0> }  
   
  light_source { <0, 0, -10> color White }  
  light_source { <0, 12, -50> color White }  
 light_source { <0, -12, -50> color White } 
 light_source { <-12, 0, -50> color White } 
 light_source { <12, 0, -50> color White } 
 
 // larger box in the center 
 box { 
 <-3, -3, 0>, <3, 3, 0> 
 pigment { color Blue } 
 } 
 
 // make a box object 
 #declare myBox = box { 
 <-2, -2, 0>, <2, 2, 0> 
 pigment { color Blue } 
 } 
 
 object { myBox translate <-4, -4, 0> } 
 object { myBox translate <-4, 4, 0> } 
 object { myBox translate <4, 4, 0> } 
 object { myBox translate <4, -4, 0> } 
 
  // make a triangle object  
  #declare myTriangle = triangle {  
  <-4, -3, 0>, <0, 3, 0>, <4, -3, 0>  
  pigment { color Green }  
  }  
   
  object { myTriangle translate <0, 9, 0> }  
  object { myTriangle rotate <180, 0, 0> translate <0, -9, 0> }  
  object { myTriangle rotate <0, 0, -90> translate <9, 0, 0> }  
  object { myTriangle rotate <0, 0, 90> translate <-9, 0, 0> }  
   
  // make a sphere object  
  #declare mySphere = sphere {  
  <0, 0, 0>, 2  
  pigment {color Red}  
  }  
   
  object { mySphere translate <0, 12, 0> }  
  object { mySphere translate <12, 0, 0> }  
  object { mySphere translate <0, -12, 0> }  
  object { mySphere translate <-12, 0, 0> }  

There's a lot of bulk here, but nothing too complex. Still, I'd recommend reading the PovRay documentation file to learn about the not-so-obvious commands. In reading the documentation myself , I discovered a real time-saver. I could create objects and then call the objects into play like a subroutine in a computer program. This meant I could define the three pieces in the logo as objects and simply reuse them whenever I needed them. With some fancy rotations and translations, I was able to shorten the scene file.

Translations? What's that? When designing a PovRay object, it's best to center the object at <0,0,0>. Then use the translate command to place the object somewhere in your scene. Translate moves the object relative to coordinate <0,0,0>. Proper object rotation is also achieved when the object is designed around <0,0,0>. The first mistake you might make is to design a scene with objects at absolute positions within the scene. This will lead to complications when you need to move things around.

The next step was to determine what it would take to transform this image into three dimensions. As you probably figured out, the end result will be a slight modification to the 2D logo scene file.

 



Multitool Linux. Practical Uses for Open Source Software
Multitool Linux: Practical Uses for Open Source Software
ISBN: 0201734206
EAN: 2147483647
Year: 2002
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net