1
#include "POVRenderer.h"
2
#include "../../../SyntopiaCore/Math/Vector3.h"
4
using namespace SyntopiaCore::Math;
6
#include "../../../SyntopiaCore/Logging/Logging.h"
8
using namespace SyntopiaCore::Logging;
10
namespace StructureSynth {
14
void POVRenderer::writeline(QString text) const {
15
output += text + "\r\n";
18
void POVRenderer::write(QString text) const {
22
void POVRenderer::drawBox(SyntopiaCore::Math::Vector3f base,
23
SyntopiaCore::Math::Vector3f dir1 ,
24
SyntopiaCore::Math::Vector3f dir2,
25
SyntopiaCore::Math::Vector3f dir3, const QString &)
27
writeline("object { ");
28
writeline(" box { <0, 0.0, 0>, <1, 1, 1> }");
29
writeline(QString("matrix < %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12 > ")
30
.arg(dir1.x()).arg(dir1.y()).arg(dir1.z())
31
.arg(dir2.x()).arg(dir2.y()).arg(dir2.z())
32
.arg(dir3.x()).arg(dir3.y()).arg(dir3.z())
33
.arg(base.x()).arg(base.y()).arg(base.z()));
35
QString(" texture { pigment { color rgbt <%1,%2,%3,%4> } finish { DEFFIN } normal { DEFNOR } }")
36
.arg(rgb.x()).arg(rgb.y()).arg(rgb.z()).arg(1-alpha));
41
void POVRenderer::drawGrid(SyntopiaCore::Math::Vector3f /*base*/,
42
SyntopiaCore::Math::Vector3f /*dir1*/ ,
43
SyntopiaCore::Math::Vector3f /*dir2*/,
44
SyntopiaCore::Math::Vector3f /*dir3*/, const QString &) {
48
void POVRenderer::drawLine(SyntopiaCore::Math::Vector3f /*from*/, SyntopiaCore::Math::Vector3f /* to*/, const QString &) {
52
void POVRenderer::drawDot(SyntopiaCore::Math::Vector3f /*v*/, const QString &) {
56
void POVRenderer::drawSphere(SyntopiaCore::Math::Vector3f center, float radius, const QString &) {
57
writeline("object { ");
58
writeline(QString(" sphere { <%1, %2, %3>, %4 }")
59
.arg(center.x()).arg(center.y()).arg(center.z()).arg(radius));
61
QString(" texture { pigment { color rgbt <%1,%2,%3,%4> } finish { DEFFIN } normal { DEFNOR } }")
62
.arg(rgb.x()).arg(rgb.y()).arg(rgb.z()).arg(1-alpha));
66
void POVRenderer::begin() {
67
writeline("// Global settings");
68
writeline("global_settings {");
69
writeline(" max_trace_level 5");
70
writeline(" ambient_light rgb <1,1,1>");
73
writeline("// Finish and normal");
74
writeline("#declare DEFFIN = finish { ambient 0.1 diffuse 0.5 specular 0.5 };");
75
writeline("#declare DEFNOR = normal { dents 0 scale 0.01 };");
77
writeline("// Background");
79
writeline(" z, 100.0");
80
writeline(" texture {");
81
writeline(" pigment { color rgb <0.0,0.0,0.0> }");
82
writeline(" finish { ambient 1 }");
87
writeline("// Camera");
88
writeline("camera {");
89
writeline(" location <-0.0,0.0,-15.0>");
90
writeline(" look_at <-0.0,-0.0,-0.0>");
91
writeline(" right -x");
93
writeline(" angle 60");
96
writeline("// Lights");
97
writeline("light_source { <500,500,-1000> rgb <1,1,1> shadowless } ");
98
writeline("light_source { <-500,-500,-1000> rgb <1,1,1> shadowless } ");
99
writeline("light_source { <-500,500,1000> rgb <1,1,1> shadowless } ");
103
void POVRenderer::end() {
107
void POVRenderer::setBackgroundColor(SyntopiaCore::Math::Vector3f /*rgb*/) {