|
![](/i/fill.gif) |
"Jug" <nomail@nomail> wrote in message
news:web.489bf2df611ced9672762ce30@news.povray.org...
> Hi,
> I am new to POV-Ray and have no previous programming experience, so
> please
> forgive me if this is a simple question. I a trying to write an .inc file
> of
> an etched tile. I want the tile and the lettering to be two different
> colors
> and to be able to easily edit the colors of the tile from the scene file I
> add
> it into. I know that if I do not include a color/texture in the .inc file
> I
> can define the it in the scene, but it makes the tile and writing the same
> color/texture. Is there a way I can determine or change the color/texture
> of
> the individual components of the tile from the scene file? I would also
> like
> to be able to easily change the pigment, texture, and finish of the tile
> in
> the .inc file from the scene file. Do I need to include the standard .inc
> files, such as colors, textures, or stones1 into my .inc file, or will it
> work
> if I include them in the scene? I have included my tile below and added
> in the
> color and texture as an example of what I am trying to do. Thanks a lot
> for any
> help you can give me.
>
> Jug
Hi and Welcome.
There are actually lots of approaches you could take.
I very much prefer the approach that I've illustrated below using #ifdef and
#ifndef to define default texture values. As you can see from the
'WritingTexture' declaration, you can nest these to provide the sort of
flexibility you mentioned in your question: If 'WritingTexture' is already
defined by the time your include file is parsed, it'll use that. Otherwise
if 'WritingPigment' or 'WritingNormal' are defined it'll use them to
construct 'WritingTexture'. If none are defined it'll just define defaults
and plough on regardless.
You can use a similar technique to define any #include files that you're
dependent upon if they weren't already included.
By testing for everything you need you can make a very robust little
#include file. By providing defaults for everything, anyone can start using
the file without having to initially worry about setting variables,
parameters etc.
If you're planning to generate multiple element blocks (e.g. a whole
periodic table), you're probably better off wrapping the contents of your
#include file in a macro statement e.g. #macro Element() .... #end. Then you
can #include it once and call it many times.
p.s. To revert to default settings between macro calls you can use #undef on
textures, pigments or normals that were previously declared.
Regards,
Chris B.
#ifndef (Green) #include "colors.inc" #end
#ifndef (T_Stone1) #include "stones.inc" #end
#ifndef(BlockTexture)
#declare BlockTexture = texture {T_Stone1}
#end
#ifndef(WritingTexture)
#declare WritingTexture = texture {
#ifdef (WritingPigment) pigment {WritingPigment}
#else pigment {Green}
#end
#ifdef (WritingNormal) pigment {WritingNormal}
#else normal {agate scale 0.5}
#end
}
#end
#declare Silver = union{ // Element Tile
difference{ // Front Plate and Lettering
box{<0, 0, 0>, // Box, Near lower left corner
< 1.6, 2.2, 0.2> // Far upper right corner
texture {BlockTexture} // color
translate <0, 0, 0> // location
}
text {ttf "Arial.ttf" "Ag" 5, 0 // text and symbol
texture {WritingTexture} // color
scale 1 // scale
translate <.2, .5, -1> // location
}
text {ttf "Arial.ttf" "47" 5, 0 // text and number
texture {WritingTexture} // color
scale 0.6 // scale
translate <.1, 1.6, -1> // location
}
translate <0.25, 0.25, > // location
}
difference{ // Border and Back Plate
box{<0, 0, 0>, // Border, Near lower left corner
< 2.1, 2.7, 0.3> // Far upper right corner
texture {T_Stone1} // color
}
box{<0.15, 0.15, -0.1>, // Negative Space, Near lower left corner
< 1.95, 2.55, 0.2> // Far upper right corner
texture {WritingTexture} // color
}
}
}
Post a reply to this message
|
![](/i/fill.gif) |