|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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.
Thanks much
Mark Wright
mwr### [at] netonecomnet
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ok .. thanks a bunch Jerry, I will study the code and your explanations.
I have been doing alot of cutting, pasting and typing the code, trying to
get used
to all this stuff. I'll probably post one in the binaries.images tonight or
tomorrow.
Keep On Tracing !!
Mark Wright
Jerry Anning wrote in message <34DA123F.DCF8EF31@dhol.com>...
>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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mark Wright (ren### [at] myhousenet) wrote:
: 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.
Someone explained something already, but I will try to help too...
Unlike #define in C, #declare in povray doesn't just define text replacing
strings. You can define thinks like float values, vectors, textures,
objects, etc. For example:
#declare MyValue=10
says that the string 'MyValue' has the value 10. So, if you have for
example "rotate <MyValue,1,2>", this is the same thing as "rotate <10,1,2>".
#declare MyVector=<10,1,2>
defines a vector. Now you can type for example "rotate MyVector" and it
will be the same as "rotate <10,1,2>".
These work just like the text replacing #define in C, but textures,
objects, etc work a bit different.
Suppose you want to define a texture. You type for example:
#declare MyTexture=texture { pigment { rgb <1,0,0> } normal { bumps .2 } }
When you want to use this texture in an object, you type:
texture { MyTexture }
You can also define pigments, normals, etc, like:
#declare MyPigment=
pigment
{ color rgbf <1,.5,0,.5>
}
#declare MyNormal=
normal
{ bumps .1 scale 2
}
and then you can use them like this:
sphere
{ 0,1
pigment { MyPigment }
normal { MyNormal }
}
You can also define an object or CSG:
#define MyObject=sphere{ 0,1 scale <.5,.4,1> }
#define MyCSG=
union
{ sphere { 0,2 }
box { -1,1 }
}
When you want to use these object, you use the 'object' directive like this:
object
{ MyObject
scale 5
}
object
{ MyCSG
translate x*5
}
or for example:
difference
{ object { MyObject }
object { MyCSG }
texture { MyTexture }
}
--
- Warp. -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ok ... Am I on the right track with this? The problem I seem to be
having now is when I rotate this cross, it's not as one object
and doesn't rotate as one. Man .. I was up way too late trying to
figure all this out.
// DECLARE REDCROSS
#declare redcross =
box { < -0.5, -0.5, -0.5>, < 0.5, 0.5, 0.5>
texture { pigment { color Red } }
scale < 5, 14, -3 >
translate < 0, -4, 1 > }
box { < -0.5, -0.5, -0.5>, < 0.5, 0.5, 0.5>
texture { pigment { color Red } }
scale < 14, 5, -3 >
translate < 0, -4, 1 > }
// UNION
union { object { redcross } rotate y*(360*clock)}
Thanks again to All that have helped me and others !!
Mark Wright
mwr### [at] netonecomnet
Nieminen Mika wrote in message <34de05a4.0@news.povray.org>...
>Mark Wright (ren### [at] myhousenet) wrote:
>: 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.
>
> Someone explained something already, but I will try to help too...
>
> Unlike #define in C, #declare in povray doesn't just define text
replacing
>strings. You can define thinks like float values, vectors, textures,
>objects, etc. For example:
>#declare MyValue=10
>says that the string 'MyValue' has the value 10. So, if you have for
>example "rotate <MyValue,1,2>", this is the same thing as "rotate
<10,1,2>".
>#declare MyVector=<10,1,2>
>defines a vector. Now you can type for example "rotate MyVector" and it
>will be the same as "rotate <10,1,2>".
> These work just like the text replacing #define in C, but textures,
>objects, etc work a bit different.
> Suppose you want to define a texture. You type for example:
>#declare MyTexture=texture { pigment { rgb <1,0,0> } normal { bumps .2 } }
> When you want to use this texture in an object, you type:
> texture { MyTexture }
> You can also define pigments, normals, etc, like:
>#declare MyPigment=
>pigment
>{ color rgbf <1,.5,0,.5>
>}
>#declare MyNormal=
>normal
>{ bumps .1 scale 2
>}
> and then you can use them like this:
>
>sphere
>{ 0,1
> pigment { MyPigment }
> normal { MyNormal }
>}
>
> You can also define an object or CSG:
>#define MyObject=sphere{ 0,1 scale <.5,.4,1> }
>#define MyCSG=
>union
>{ sphere { 0,2 }
> box { -1,1 }
>}
>
> When you want to use these object, you use the 'object' directive like
this:
>
>object
>{ MyObject
> scale 5
>}
>object
>{ MyCSG
> translate x*5
>}
>
> or for example:
>
>difference
>{ object { MyObject }
> object { MyCSG }
> texture { MyTexture }
>}
>
>--
> - Warp. -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mark Wright wrote:
> Ok ... Am I on the right track with this? The problem I seem to be
> having now is when I rotate this cross, it's not as one object
> and doesn't rotate as one. Man .. I was up way too late trying to
> figure all this out.
The problem is that POV thought that "redcross" referred only to the
first box, and that you were simply telling it to render the second
box. This is tricky, but watch: for *objects*, POV reads the material
after the equal sign until the parser has finished a complete object
definition. This also applies to lights, cameras and most other things,
including colors. When POV finished reading the first box, that
completed an object definition, so the second box was not added to
"redcross". FOR *textures*, POV keeps reading until it finds something
that is NOT a texture. If it finds several successive textures, it
assumes you are creating a layered texture, and the #declare'd name
applies to the whole set of textures. If you want to combine several
objects under a #declare'd name, you need to put the objects into a
union *in the definition*. If some or all of the objects are
transparent, use "merge" instead of "union". Your code should read as
follows:
//begin POV code
#declare redcross =
union
{
box { < -0.5, -0.5, -0.5>, < 0.5, 0.5, 0.5>
texture { pigment { color Red } }
scale < 5, 14, -3 >
translate < 0, -4, 1 > }
box { < -0.5, -0.5, -0.5>, < 0.5, 0.5, 0.5>
texture { pigment { color Red } }
scale < 14, 5, -3 >
translate < 0, -4, 1 > }
}
object { redcross rotate y*(360*clock)}
// End POV code
Good luck.
Jerry Anning
cle### [at] dholcom
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ok thanks Jerry ...
Jerry Anning wrote in message <34DF6D81.F1C93DD3@dhol.com>...
>Mark Wright wrote:
>
>> Ok ... Am I on the right track with this? The problem I seem to be
>> having now is when I rotate this cross, it's not as one object
>> and doesn't rotate as one. Man .. I was up way too late trying to
>> figure all this out.
>
>The problem is that POV thought that "redcross" referred only to the
>first box, and that you were simply telling it to render the second
>box. This is tricky, but watch: for *objects*, POV reads the material
>after the equal sign until the parser has finished a complete object
>definition. This also applies to lights, cameras and most other things,
>including colors. When POV finished reading the first box, that
>completed an object definition, so the second box was not added to
>"redcross". FOR *textures*, POV keeps reading until it finds something
>that is NOT a texture. If it finds several successive textures, it
>assumes you are creating a layered texture, and the #declare'd name
>applies to the whole set of textures. If you want to combine several
>objects under a #declare'd name, you need to put the objects into a
>union *in the definition*. If some or all of the objects are
>transparent, use "merge" instead of "union". Your code should read as
>follows:
>
>//begin POV code
>
>#declare redcross =
>union
> {
> box { < -0.5, -0.5, -0.5>, < 0.5, 0.5, 0.5>
> texture { pigment { color Red } }
> scale < 5, 14, -3 >
> translate < 0, -4, 1 > }
>
> box { < -0.5, -0.5, -0.5>, < 0.5, 0.5, 0.5>
> texture { pigment { color Red } }
> scale < 14, 5, -3 >
> translate < 0, -4, 1 > }
> }
>
> object { redcross rotate y*(360*clock)}
>
>// End POV code
>
>Good luck.
>
>Jerry Anning
>cle### [at] dholcom
>
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|