POV-Ray简单案例
POV-Ray,全名是Persistence of Vision Raytracer,是一个使用光线跟踪绘制三维图像的开放源代码免费软件。
按照3.7版本给的参考,写的代码,以下为部分源码
#version 3.7;
global_settings { assumed_gamma 0.8 } //设置全局亮度
#include "colors.inc"
#include "textures.inc"
#include "shapes.inc"
#include "metals.inc"
#include "glass.inc"
#include "woods.inc"
#include "stones.inc"
//相机坐标
camera {
location <-3, 5, -6>
angle 45 // direction <0, 0, 1.7>
right x*image_width/image_height
look_at <0,0,0>
}
// Uncomment the area lights only if you've got lots of time.
#declare Dist=80.0;
light_source {< -50, 25, -50> color White
fade_distance Dist fade_power 2
// area_light <-40, 0, -40>, <40, 0, 40>, 3, 3
// adaptive 1
// jitter
}
light_source {< 50, 10, -4> color Gray30
fade_distance Dist fade_power 2
// area_light <-20, 0, -20>, <20, 0, 20>, 3, 3
// adaptive 1
// jitter
}
light_source {< 0, 100, 0> color Gray30
fade_distance Dist fade_power 2
// area_light <-30, 0, -30>, <30, 0, 30>, 3, 3
// adaptive 1
// jitter
}
//设置背景颜色
sky_sphere {
pigment {
gradient y
color_map {
[0, 1 color White color White]
}
}
}
//声明r的大小,类似于int float等
#declare r=0.02;
union {
// cell 14
// cell 7
sphere{<0.975637,-1,-1>,r}
sphere{<0.77992,-0.855811,-0.946429>,r}
sphere{<0.48367,-0.943088,-0.546919>,r}
cylinder{<0.48367,-0.943088,-0.546919>,<0.77992,-0.855811,-0.946429>,r}
sphere{<0.721746,-0.792901,-1>,r}
cylinder{<0.721746,-0.792901,-1>,<0.77992,-0.855811,-0.946429>,r}
sphere{<-0.422036,-0.629073,-0.478126>,r}
sphere{<0.929994,-0.954386,-1>,r}
cylinder{<0.929994,-0.954386,-1>,<0.975637,-1,-1>,r}
cylinder{<0.929994,-0.954386,-1>,<0.721746,-0.792901,-1>,r}
cylinder{<0.929994,-0.954386,-1>,<0.77992,-0.855811,-0.946429>,r}
sphere{<-0.0948664,-0.365769,-1>,r}
cylinder{<-0.0948664,-0.365769,-1>,<0.721746,-0.792901,-1>,r}
sphere{<-0.852311,-0.717163,-1>,r}
cylinder{<-0.852311,-0.717163,-1>,<-0.422036,-0.629073,-0.478126>,r}
cylinder{<-0.852311,-0.717163,-1>,<-0.0948664,-0.365769,-1>,r}
sphere{<-0.297797,-0.568924,-0.489879>,r}
cylinder{<-0.297797,-0.568924,-0.489879>,<-0.0948664,-0.365769,-1>,r}
cylinder{<-0.297797,-0.568924,-0.489879>,<-0.422036,-0.629073,-0.478126>,r}
sphere{<-0.834134,-1,-1>,r}
cylinder{<-0.834134,-1,-1>,<-0.852311,-0.717163,-1>,r}
cylinder{<-0.834134,-1,-1>,<0.975637,-1,-1>,r}
sphere{<-0.377755,-1,-0.453654>,r}
cylinder{<-0.377755,-1,-0.453654>,<-0.834134,-1,-1>,r}
cylinder{<-0.377755,-1,-0.453654>,<-0.422036,-0.629073,-0.478126>,r}
sphere{<0.401431,-0.925331,-0.505262>,r}
cylinder{<0.401431,-0.925331,-0.505262>,<0.48367,-0.943088,-0.546919>,r}
cylinder{<0.401431,-0.925331,-0.505262>,<-0.297797,-0.568924,-0.489879>,r}
sphere{<0.386068,-1,-0.498897>,r}
cylinder{<0.386068,-1,-0.498897>,<0.401431,-0.925331,-0.505262>,r}
cylinder{<0.386068,-1,-0.498897>,<-0.377755,-1,-0.453654>,r}
sphere{<0.595652,-1,-0.604238>,r}
cylinder{<0.595652,-1,-0.604238>,<0.386068,-1,-0.498897>,r}
cylinder{<0.595652,-1,-0.604238>,<0.975637,-1,-1>,r}
cylinder{<0.595652,-1,-0.604238>,<0.48367,-0.943088,-0.546919>,r}
//设置纹理,这一块可以去网上搜索,放在最后面
texture {
pigment {
wood
color_map {
[0.0 color DarkTan]
[0.9 color DarkBrown]
[1.0 color VeryDarkBrown]
}
turbulence 0.05
scale <0.2, 0.3, 1>
}
finish { phong 1 }
}
}