|
|
Mark Wright wrote:
> If anyone has a moment for this newbie...
>
> Could you explain the declare statement to me?
> The help docs are great, but the declare examples they give
> don't seem to work for me. A simple sample of some source code
> would help alot.
The most common problem people seem to have with the #declare statement
is that they expect it to put the object in the scene. All #declare
does is *define* a word. You have to *use* the word later in the scene
file if you want to see any results.
Here is how it goes:
#define Ball = sphere { <0, 0, 0>, 1 texture { pigment { color rgb <1,
0, 0> } } }
POV now knows you plan to talk about something called a "Ball" and how
to make one when you do. If you stop here, you will not see a "Ball".
Later in your file ...
...
object { Ball scale <1, 2, .5> rotate <0, 0, -13> translate <3, 2, 4> }
object { Ball texture { finish { reflection .8 } } translate <3, 0, -4>
}
...
*Now* you have actually created some "Balls" and they will appear in
your scene.
Here is a full scene that uses some #declares:
//Start POV code
#include "colors.inc"
#include "textures.inc"
#version 3.0
global_settings { assumed_gamma 1.0 }
#declare Cam = camera { location <0, 0, -35> look_at <0, 0, 0> }
// This defines a camera, but does not use it yet.
#declare Lyt = light_source { <20, 50, -100> color rgb <1.25, .5, .25> }
// Ditto a light_source
#declare Skin = texture { pigment { color rgb <1, .5, .25> } }
// This sets up a texture I will use later
#declare Grid =
union
{
#declare P1 = -10 // this creates a variable
#while (P1 <= 10)
#declare P2 = -10
#while (P2 <= 10)
cylinder { <-10, P1, P2>, < 10, P1, P2>, .05 texture { Skin } }
// using those variables and the texture to define my grid
cylinder { <P2, P1, -10>, <P2, P1, 10>, .05 texture { Skin } }
cylinder { <P2, -10, P1>, <P2, 10, P1>, .05 texture { Skin } }
#declare P2 = P2 + 5 // changing the value of my variable
#end
#declare P1 = P1 + 5
#end
}
// Now, POV knows what a "Grid" is, but I have not told it to make one.
camera { Cam } // Use the camera I defined
light_source { Lyt } // Light the scene my predefined way
// These two things let me set up several lighting schemes and
viewpoints and
// switch between them easily if I want to.
object { Grid } // Now I am telling POV to actually make a grid.
// End POV code
I hope that makes it clear. The #declares for the objects and texture,
by the way, could just as well be in an include file as long as you
included it before you used any of them. Good luck.
Jerry Anning
cle### [at] dholcom
Post a reply to this message
|
|