File: POVRenderer.cpp

package info (click to toggle)
structure-synth 1.0.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,072 kB
  • ctags: 1,176
  • sloc: cpp: 7,070; python: 167; makefile: 66; lisp: 25
file content (114 lines) | stat: -rw-r--r-- 3,799 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "POVRenderer.h"
#include "../../../SyntopiaCore/Math/Vector3.h"

using namespace SyntopiaCore::Math;

#include "../../../SyntopiaCore/Logging/Logging.h"

using namespace SyntopiaCore::Logging;

namespace StructureSynth {
	namespace Model {	
		namespace Rendering {

			void POVRenderer::writeline(QString text) const {
				output += text + "\r\n";
			};

			void POVRenderer::write(QString text) const {
				output += text;
			};

			void POVRenderer::drawBox(SyntopiaCore::Math::Vector3f base, 
				SyntopiaCore::Math::Vector3f dir1 , 
				SyntopiaCore::Math::Vector3f dir2, 
				SyntopiaCore::Math::Vector3f dir3,  const QString &) 
			{
				writeline("object {   ");                               
				writeline("  box { <0,  0.0, 0>, <1,  1,  1> }");
				writeline(QString("matrix < %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12 > ")
					.arg(dir1.x()).arg(dir1.y()).arg(dir1.z())
					.arg(dir2.x()).arg(dir2.y()).arg(dir2.z())
					.arg(dir3.x()).arg(dir3.y()).arg(dir3.z())
					.arg(base.x()).arg(base.y()).arg(base.z()));
				writeline(
					QString("  texture { pigment { color rgbt <%1,%2,%3,%4> } finish { DEFFIN } normal { DEFNOR } }")
					.arg(rgb.x()).arg(rgb.y()).arg(rgb.z()).arg(1-alpha));
				writeline("}");

			};

			void POVRenderer::drawGrid(SyntopiaCore::Math::Vector3f /*base*/, 
				SyntopiaCore::Math::Vector3f /*dir1*/ , 
				SyntopiaCore::Math::Vector3f /*dir2*/, 
				SyntopiaCore::Math::Vector3f /*dir3*/,  const QString &) {
					// TODO
			};

			void POVRenderer::drawLine(SyntopiaCore::Math::Vector3f /*from*/, SyntopiaCore::Math::Vector3f /* to*/,  const QString &) {
				// TODO
			};

			void POVRenderer::drawDot(SyntopiaCore::Math::Vector3f /*v*/,  const QString &) {
				// TODO	
			};

			void POVRenderer::drawSphere(SyntopiaCore::Math::Vector3f center, float radius,  const QString &) {
				writeline("object {   ");                               
				writeline(QString("  sphere { <%1, %2, %3>, %4 }")
					.arg(center.x()).arg(center.y()).arg(center.z()).arg(radius));
				writeline(
					QString("  texture { pigment { color rgbt <%1,%2,%3,%4> } finish { DEFFIN } normal { DEFNOR } }")
					.arg(rgb.x()).arg(rgb.y()).arg(rgb.z()).arg(1-alpha));
				writeline("}");
			};

			void POVRenderer::begin() {
				writeline("// Global settings");
				writeline("global_settings {");
				writeline("  max_trace_level 5");
				writeline("  ambient_light rgb <1,1,1>");
				writeline("}");
				writeline("");
				writeline("// Finish and normal");
				writeline("#declare DEFFIN = finish { ambient 0.1 diffuse 0.5 specular 0.5 };");
				writeline("#declare DEFNOR = normal { dents 0 scale 0.01 };");
					writeline("");
				writeline("// Background");
				writeline("plane {");
				writeline("  z, 100.0");
				writeline("  texture {");
				writeline("    pigment { color rgb <0.0,0.0,0.0> }");
				writeline("    finish { ambient 1 }");
				writeline("  }");
				writeline("  hollow");
				writeline("}");
				writeline("");
				writeline("// Camera");
				writeline("camera {");
				writeline("  location <-0.0,0.0,-15.0>");
				writeline("  look_at <-0.0,-0.0,-0.0>");
				writeline("  right -x");
				writeline("  up y");
				writeline("  angle 60");
				writeline("}");
				writeline("");
				writeline("// Lights");
				writeline("light_source { <500,500,-1000> rgb <1,1,1> shadowless } ");
				writeline("light_source { <-500,-500,-1000> rgb <1,1,1> shadowless } ");
				writeline("light_source { <-500,500,1000> rgb <1,1,1> shadowless } ");
				writeline("");
			};

			void POVRenderer::end() {
				// TODO
			};

			void POVRenderer::setBackgroundColor(SyntopiaCore::Math::Vector3f /*rgb*/) {
				// TODO
			}

		}
	}
}