Pov-ray Simple Tutorial--first image and basic graphics

Source: Internet
Author: User
Tags set background

First image and Base graphic in this article, we will use Pov-ray to render our first image, as well as some other simple graphical objects (spheres, planes, cubes).
1. Coordinates of the left-hand system. The z-axis points to the inside of the screen (understanding the Pov-ray coordinate system helps us to render images, such as some location information). 2. Add an include file to create a. POV type of file, open it with Pov-ray, and edit it (you can, of course, edit it with a different text editor). First, we need to include some basic files to build our scene (which is very similar to programming in some languages).

  #include "colors.inc"    //The Include files contain  #include "stones.inc"    //pre-defined scene elements

The first file is the color, and the second is the texture header file that joins the stone (they all end With. Inc). In addition, we can also add some other files, will continue to use later. Here, just to get a simple picture, these two header files are enough.
3. Add a camera
Camera {location    <0, 2, -3>    look_at  <0, 1,  2>  }
Location is where the camera is located, and the look_at is the camera pointing direction. The back <x,y,z> is his position information in the coordinate system. 4. Describe the object
Sphere {    <0, 1, 2>, 2    texture {      Pigment {color Yellow}    }  }
Here is the creation of a sphere (sphere) <0,1,2> is the position of the ball sphere; 2 is the radius. texture{} to set the texture. Pigment is a key word. Color yellow is set to yellow (note that the first letter of the color is capitalized) There are several ways to use it:
Color Red 1.0 Green 0.8 Blue 0.8 color RGB <1.0, 0.8, 0.8>rgb <1.0, 0.8, 0.8>
5. Define the light source
Light_source {<2, 4, -3> color white}  
light_source{} is a keyword, others do not do too much explanation, it is straightforward to understand
And finally the whole code:
  #include "colors.inc"  background {color Cyan}  camera {location    <0, 2, -3>    look_at  <0, 1,  2>  }  Sphere {    <0, 1, 2>, 2    texture {      Pigment {color Yellow}    }  }< C20/>light_source {<2, 4, -3> color white}
Added background is set background, here set background color: Cyan Rendering effect


Other basic graphics 1.box
box{   <-1,0,-1>,   <1,0.5,3>   texture   {      t_stone25  //Set Texture effect scale      4    // Set scale   }   
(The camera position is not adjusted, but we can see a marble box) 2.cone (cone)
cone{   <0,1,0>, 0.3    <1,2,3>, 1.0    //two round coordinates and RADIUS   open    //Set whether openings   texture   {      T_stone25 scale      4   }}
3.cylinder
cylinder{   <0,2,0>,   <-2,2,3>,   0.5   Open   



4.plane
plane{   <0,1,0>,-1   pigment   {       checker color red, color blue  //Red and Blue   }   

5.Torus (ring) Base graphics:
#include "Colors.inc" camera {location   <0,1,-25>   look_at 0   Angle}          background {color GRAY50} Light_source{<300,300,-1000> White}    torus{   4,1   rotate-90*x      pigment {Green}     }



Advanced variants (1):
#include "Colors.inc" camera {location <0,1,-25> look_at 0 Angle} background {color gray50}light_ Source{<300,300,-1000> White} #declare half_torus=difference//difference:a and b two objects. The effect is: Remove the part ab intersect in a {torus{4,1 rotate-90*x}box{<-5,-5,-1>,<5,0,1>}pigment {Green}} #declare F          Lip_it_over=180*x; Declare declaration, facilitates subsequent calls to #declare torus_translate=8;union{Object{half_torus} object {Half_torus rotate F  Lip_it_over Translate Torus_translate*x} object {Half_torus translate Torus_translate*x*2} object {Half_torus rotate flip_it_over Translate Torus _translate*x*3} object {Half_torus rotate Flip_it_over translate-x*torus_tr       Anslate} object {Half_torus translate-x*torus_translate*2} object {          Half_torusRotate Flip_it_over Translate-x*torus_translate*3} object {Half_torus translate-x*torus_t     RANSLATE*4} rotate y*45 translate z*90}
Snake Pattern Advanced Variant (2):
 #include "Colors.inc" camera {location <0,1,-25> look_at 0 Angle} background {color gray50}light _source{<300,300,-1000> White} #declare half_torus=difference{torus{4,1 rotate-90*x}BOX{&LT;-5,-5,-1&GT;,&L    T;5,0,1>}} #declare flip_it_over=180*x; #declare torus_translate=8; #declare chain_segment=cylinder{<0,4,0>,<0,-4,0>,1} #declare chain_gold=texture{Pigment{brigh Tgold} finish {ambient. 1 diffuse. 4 reflection. Specular 1 Metallic}} #declare link= union{Object {Half_torus Translate Y*torus_translate/2} object {Half_torus Rotat E flip_it_over Translate-y*torus_translate/2} object {Chain_segment translate X*torus_translat E/2} object {chain_segment TRANSLATE-X*TORUS_TRANSLATE/2} Texture{chain_gold}} #de     Clare Link_translate=torus_translate*2-2*y; #declare Link_pair=union{Object{link} object {Link translate y*link_translate rotate y*90} } #declare chain=union{Object {Link_pair} object {Link_pair translate y*link_translate*2} obj ECT {Link_pair Translate y*link_translate*4} object {Link_pair translate Y*link_translat E*6} object {Link_pair translate-y*link_translate*2} object {Link_pair translate -y*link_translate*4} object {Link_pair translate-y*link_translate*6}} object {Chain scale. 1 ro Tate <0,45,-45>}

Chain:

(OK, about torus this part, I lazy, some of these things do not explain, but you should be able to understand, if there is a problem, you can leave a message, or read the official documents)
End of this article!!!







Pov-ray Simple Tutorial--first image and basic graphics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.