Home
- POV-Ray Tutorials
POV-Ray Introduction
Content - INDEX
0. Working with POV-Ray:
"Insert Menu Add-on".
1. Basics
on writing texts.
2. 3D Coordinates,
Floats and Vectors
3. Scene Structur
#include files,
camera,
light_source.
Types of light sources
4. Basic Objects plane, sphere,
box, cylinder, cone, torus.
Other Shapes
height_field, text, etc.
5. Transformations
Streching, Turning,
Moving and others.
CSG: union,
difference, intersection.
6. Color + Surfaces
texture, pigment, normal, finish
>7. #declare, #local,
#macro .. #end,
#include,
re-usable objects.
8. #while Loops
9. Efficiency,
speed, flexibility,
modulare working
adapting from 3.1 to 3.5;3.6
adapting from 3.5;3.6 to 3.7
POV-Ray + Windows Vista.
- Insert Menu Add-on
& Download
|
|
VII .#declare, #local
-- Definition of e.g. variable values (floats and vectors), textures and objects
Please keep in mind for choosing names and abbreviations:
> Don't use any specific national characters!
> Don't use build in keywords!
> Capitals and small characters are discriminated!
> Its recommended: for all objects and things defined by yourself - use capitals at the beginning!
POV-Ray keywords are starting with small characters!
#declare is used for global valid variables, while in macros or include file
there can be defined with #local only local valid variables. These localen variables
kann be change inside of a macro or include file (i.e. as a counter in a while loop),
without affecting a globale variable with the same name outside. Locale variables
are not visible (do not exist) outside of the region were they were declared!
Sample for the definition and the use of objects defined with "#declare ... = ":
#declare R1 = 0.25 ; // ball radius
#declare RR = 1.00 ; // ring radius
#declare Position_1 = <1,0,2> ;
#declare Ball_Texture =
texture{pigment{ color rgb<1,0.65,0>}
finish { diffuse 0.90 phong 1.0}
}// end of texture
#declare Ball1 =
sphere {<0,0,0>,R1
texture {Ball_Texture}
}// end of sphere
#declare BallHalfCircle =
union{
object{Ball1 translate<RR,0,0> rotate <0, 0,0>}
object{Ball1 translate<RR,0,0> rotate <0, 20,0>}
object{Ball1 translate<RR,0,0> rotate <0, 40,0>}
object{Ball1 translate<RR,0,0> rotate <0, 60,0>}
object{Ball1 translate<RR,0,0> rotate <0, 80,0>}
object{Ball1 translate<RR,0,0> rotate <0,100,0>}
object{Ball1 translate<RR,0,0> rotate <0,120,0>}
object{Ball1 translate<RR,0,0> rotate <0,140,0>}
object{Ball1 translate<RR,0,0> rotate <0,160,0>}
object{Ball1 translate<RR,0,0> rotate <0,180,0>}
} // end of BallHalfCircle
// drawing command:
object{ BallHalfCircle translate Position_1}
// -------------------------------------------- end |
|
VII .#macro ... #end
This allows a much more flexible definition of i.e. objects.
For choosing names and abbreviations see my hint at "#declare".
Here a sample for using "#macro":
#macro BallHalfCircle (R1, RR, Texture1)
#local Ball1 = sphere{ <0,0,0>,R1
texture {Texture1}
}
union{
object{Ball1 translate<RR,0,0> rotate <0, 0,0>}
object{Ball1 translate<RR,0,0> rotate <0, 20,0>}
object{Ball1 translate<RR,0,0> rotate <0, 40,0>}
object{Ball1 translate<RR,0,0> rotate <0, 60,0>}
object{Ball1 translate<RR,0,0> rotate <0, 80,0>}
object{Ball1 translate<RR,0,0> rotate <0,100,0>}
object{Ball1 translate<RR,0,0> rotate <0,120,0>}
object{Ball1 translate<RR,0,0> rotate <0,140,0>}
object{Ball1 translate<RR,0,0> rotate <0,160,0>}
object{Ball1 translate<RR,0,0> rotate <0,180,0>}
} // end of BallHalfCircle
#end
//-----------------------------------------------------
#declare Texture1 =
texture { pigment{ color rgb<1,0.65,0>}
finish { diffuse 0.90 phong 1.0}
}
#declare Texture2 =
texture { pigment{ color rgb<1,0.2,0>}
finish { diffuse 0.90 phong 1.0}
}
// drawing commands:
object{ BallHalfCircle (0.25, 1.00, Texture1 )
translate<1,0,2>}
object{ BallHalfCircle (0.15, 0.50, Texture2 )
translate<1,0,2>}
// --------------------------------------------end |
|
|
Once constructed objects can be defined as new ready made objects by using
an include file.
Sample: with the above declared object named BallHalfCircle as "BallHalfCircle.inc":
For this you must write the text part belonging to "BallHalfCircle" without "camera"
"lightsource" and without the drawing commands in a special file and save it (not only for a rainy day! :-)
as "BallHalfCircle.inc".
For the use of this new object in a normal POV scenery file just write:
#include "BallHalfCircle.inc"
object{ BallHalfCircle translate<1,0,2>}
The text, which is stored in the file "BallHalfCircle.inc", than will be inserted at the place where
the command #include "BallHalfCircle.inc" is written.
With this method such objects can be used later in each other scene without rewriting or copying
the whole definition! It is necessary that the include file is in the same directory
as the .pov scene text file, or that we have to put it in the include subdirectory of the POV-Ray directory!
With this mechanism you also can also save your own special textures and colours as a file named "My_tex.inc"!
A stock of furniture or/and a collection of airplanes and/or star ships can be saved in this way as well!!!
|
|
| top |
© Friedrich A. Lohmüller, 2009
email:
Friedrich.Lohmueller_at_t-online.de
homepage:http://www.f-lohmueller.de
|