Difference between revisions of "HowTo:Use the plane object"
m (HowTo:Use the plane object/Example Code moved to HowTo:Use the plane object over redirect) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==The Plane== | ==The Plane== | ||
− | In POV a plane is considered to have a volume, any point that is "under" the plane is inside, and any point that is "above" the plane is outside. This becomes important when you use a plane in CSG. A plane is defined in POV by a | + | In POV, a plane is one of the five Infinite Solid Primitives. It is a flat surface that extends infinitely in all directions (unless clipped by an object). Planes are considered to have a volume, any point that is "under" the plane is inside, and any point that is "above" the plane is outside. This becomes important when you use a plane in CSG. A plane is defined in POV by a normal vector, and a float distance. The normal vector indicates the surface normal of the plane, and the distance is how far in that direction from the origin the surface begins. |
+ | |||
+ | ===A Simple Plane=== | ||
<source lang="pov"> | <source lang="pov"> | ||
#include "colors.inc" | #include "colors.inc" | ||
− | plane {y,-1 | + | plane |
− | + | { | |
+ | y, -1 | ||
+ | pigment {checker White Tan} | ||
} | } | ||
</source> | </source> | ||
+ | |||
+ | The resultant plane (a red arrow has been added to illustrate the normal vector). | ||
+ | |||
+ | [[Image:Plane-example-1.jpg|center|thumb|320px|Example #1: A simple plane.]] | ||
+ | |||
This uses the default y vector for "up", it's easy enough to rotate a plane to the desired angles after creating it, but vrotate can be used to rotate the vector before defining the plane. | This uses the default y vector for "up", it's easy enough to rotate a plane to the desired angles after creating it, but vrotate can be used to rotate the vector before defining the plane. | ||
+ | |||
+ | ===Modifying a Plane=== | ||
+ | We can use the clipped_by object modifier to render only the portion of the plane within the clipping shape. Note, though, that even though the plane is by default a solid shape, the rest of the plane does not "fill" the clipping shape: only the surface (or underside) of the plane is visible. | ||
+ | |||
+ | To have a plane "fill out" the clipping shape, we must place the plane and clipping shape inside of an intersection statement. | ||
+ | |||
+ | [[Image:Plane-example-2.jpg|center|thumb|320px|Example #2: Clipped plane vs. Intersected plane]] | ||
+ | |||
+ | In the above image, the plane section on the left is clipped by a sphere. The green and blue object on the right is an identical plane and sphere, intersected. | ||
+ | |||
+ | |||
+ | ====Full Source for Example #2==== | ||
+ | |||
+ | <source lang="pov"> | ||
+ | #include "colors.inc" | ||
+ | |||
+ | |||
+ | #declare Myfinish = | ||
+ | finish | ||
+ | { | ||
+ | specular 0.00 | ||
+ | roughness 1.00 | ||
+ | ambient 0.25 | ||
+ | } | ||
+ | |||
+ | |||
+ | // our ground plane: | ||
+ | plane | ||
+ | { | ||
+ | y, -1 | ||
+ | // this is identical to <0,1,0>, -1 | ||
+ | |||
+ | pigment | ||
+ | { | ||
+ | checker White Tan | ||
+ | } | ||
+ | |||
+ | finish | ||
+ | { | ||
+ | Myfinish | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | // plane section on the left, using clipped_by: | ||
+ | plane | ||
+ | { | ||
+ | y, 2 | ||
+ | |||
+ | clipped_by | ||
+ | { | ||
+ | sphere{ <-3,2,0>, 2 } | ||
+ | } | ||
+ | |||
+ | pigment | ||
+ | { | ||
+ | checker Black Red | ||
+ | } | ||
+ | |||
+ | finish | ||
+ | { | ||
+ | Myfinish | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | // plane section on the right, using intersection: | ||
+ | intersection | ||
+ | { | ||
+ | |||
+ | plane | ||
+ | { | ||
+ | y, 2 | ||
+ | } | ||
+ | |||
+ | sphere | ||
+ | { | ||
+ | <3,2,0>, 2 | ||
+ | } | ||
+ | |||
+ | pigment | ||
+ | { | ||
+ | checker Blue Green | ||
+ | } | ||
+ | |||
+ | finish | ||
+ | { | ||
+ | Myfinish | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | light_source | ||
+ | { | ||
+ | <0,0,0> | ||
+ | color rgb <1,1,1> | ||
+ | |||
+ | translate <10,100,-100> * 10 | ||
+ | } | ||
+ | |||
+ | |||
+ | camera | ||
+ | { | ||
+ | location <0,5,-12> | ||
+ | look_at <0,2,0> | ||
+ | } | ||
+ | </source> |
Latest revision as of 00:18, 28 December 2007
The Plane
In POV, a plane is one of the five Infinite Solid Primitives. It is a flat surface that extends infinitely in all directions (unless clipped by an object). Planes are considered to have a volume, any point that is "under" the plane is inside, and any point that is "above" the plane is outside. This becomes important when you use a plane in CSG. A plane is defined in POV by a normal vector, and a float distance. The normal vector indicates the surface normal of the plane, and the distance is how far in that direction from the origin the surface begins.
A Simple Plane
#include "colors.inc"
plane
{
y, -1
pigment {checker White Tan}
}
The resultant plane (a red arrow has been added to illustrate the normal vector).
This uses the default y vector for "up", it's easy enough to rotate a plane to the desired angles after creating it, but vrotate can be used to rotate the vector before defining the plane.
Modifying a Plane
We can use the clipped_by object modifier to render only the portion of the plane within the clipping shape. Note, though, that even though the plane is by default a solid shape, the rest of the plane does not "fill" the clipping shape: only the surface (or underside) of the plane is visible.
To have a plane "fill out" the clipping shape, we must place the plane and clipping shape inside of an intersection statement.
In the above image, the plane section on the left is clipped by a sphere. The green and blue object on the right is an identical plane and sphere, intersected.
Full Source for Example #2
#include "colors.inc"
#declare Myfinish =
finish
{
specular 0.00
roughness 1.00
ambient 0.25
}
// our ground plane:
plane
{
y, -1
// this is identical to <0,1,0>, -1
pigment
{
checker White Tan
}
finish
{
Myfinish
}
}
// plane section on the left, using clipped_by:
plane
{
y, 2
clipped_by
{
sphere{ <-3,2,0>, 2 }
}
pigment
{
checker Black Red
}
finish
{
Myfinish
}
}
// plane section on the right, using intersection:
intersection
{
plane
{
y, 2
}
sphere
{
<3,2,0>, 2
}
pigment
{
checker Blue Green
}
finish
{
Myfinish
}
}
light_source
{
<0,0,0>
color rgb <1,1,1>
translate <10,100,-100> * 10
}
camera
{
location <0,5,-12>
look_at <0,2,0>
}