POV-Ray : Newsgroups : povray.newusers : Tips on code : Re: Tips on code Server Time
30 Jul 2024 22:14:27 EDT (-0400)
  Re: Tips on code  
From: Friedrich A  Lohmueller
Date: 6 Aug 2003 17:13:48
Message: <3F316F5C.15B06196@t-online.de>
Loek Peters wrote:
> 
> Hello all
> 
> Is there a way to optimize the code I have writen, or is this the shortes
> way to this shape?
> 

Just a more serious answer:
Try this
// begin --------------------------------------------------------------
#include "colors.inc"
background { color Black }

camera  {
        location <0, 0, 10>
        look_at  <0, 0,  -1>
        }

light_source { <1, 3, 6> color White}

declare MyTexture =
        texture {
                pigment { color rgb <0.56,0.35,0.30> }
                normal { bumps 0.7 scale 0.02 }
                finish {ambient 0.27 diffuse 0.8 phong 0.2}
                }
        }
// Hint: use capitals for the first letters of objects defined by your
own!
//       Otherwise sooner or later you'll hit a reserved word!
declare Rod = union {
        sphere {
                <0, 3,  0>, 0.5
                }
        sphere {
                <0, -3, 0>, 0.5
                }
        cylinder {
                <0,  3, 0>,
                <0, -3, 0>,
                0.5
                }
//        texture { myTexture }
// Hint: use textures like wood at the end of caved out objects 
//       otherwise the grain may not be consequent on objects objects
with csg  
// Hint: declare symmetric objects right at zero! 
// Much easier to immagine what's going on there!!!
        }

difference {
                object { Rod }
                box    {  // a box to the other side!
                         <-0.6, -3.6,  0>,
                         < 0.6,  3.6,  1>
                       }
//              object {rod scale <-0.7, 0.954, 0>}
//                                      //scale 0 is "nonsense"!!!
                object {Rod scale <-0.7, 0.954, 1> }
                object {Rod scale <-0.1, 0.875, 1> translate <0,0,-0.5>}

                texture { MyTexture }
                translate<0,0,2>
  }
//end  -------------------------------------------------------------

// -----------------------------------------------------------------
//      intersection { A with B }
//    = difference   { A with NotB }

//      difference   { intersection { A with B)  minus C  minus  D } 
//    = difference   { A  minus NotB  minus C  minus  D }
// -----------------------------------------------------------------

Greetings


Friedrich  

------------------------------------------------------
email: Fri### [at] t-onlinede

homepage of Andrea and Friedrich Lohmueller:
http://www.f-lohmueller.de/index.htm
my students workshop raytracing gallery and the
homepage of the computer graphics course at KHS-school:
http://khs-kappeln.lernnetz.de/cg/cindex_e.htm
----------------------------------------------------end


Post a reply to this message

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