~ubuntu-branches/ubuntu/lucid/structure-synth/lucid

« back to all changes in this revision

Viewing changes to StructureSynth/Model/Rendering/POVRenderer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Miriam Ruiz
  • Date: 2009-04-13 13:28:45 UTC
  • Revision ID: james.westby@ubuntu.com-20090413132845-d7d42t4llxjxq0ez
Tags: upstream-0.9
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "POVRenderer.h"
 
2
#include "../../../SyntopiaCore/Math/Vector3.h"
 
3
 
 
4
using namespace SyntopiaCore::Math;
 
5
 
 
6
#include "../../../SyntopiaCore/Logging/Logging.h"
 
7
 
 
8
using namespace SyntopiaCore::Logging;
 
9
 
 
10
namespace StructureSynth {
 
11
        namespace Model {       
 
12
                namespace Rendering {
 
13
 
 
14
                        void POVRenderer::writeline(QString text) const {
 
15
                                output += text + "\r\n";
 
16
                        };
 
17
 
 
18
                        void POVRenderer::write(QString text) const {
 
19
                                output += text;
 
20
                        };
 
21
 
 
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 &) 
 
26
                        {
 
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()));
 
34
                                writeline(
 
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));
 
37
                                writeline("}");
 
38
 
 
39
                        };
 
40
 
 
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 &) {
 
45
                                        // TODO
 
46
                        };
 
47
 
 
48
                        void POVRenderer::drawLine(SyntopiaCore::Math::Vector3f /*from*/, SyntopiaCore::Math::Vector3f /* to*/,  const QString &) {
 
49
                                // TODO
 
50
                        };
 
51
 
 
52
                        void POVRenderer::drawDot(SyntopiaCore::Math::Vector3f /*v*/,  const QString &) {
 
53
                                // TODO 
 
54
                        };
 
55
 
 
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));
 
60
                                writeline(
 
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));
 
63
                                writeline("}");
 
64
                        };
 
65
 
 
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>");
 
71
                                writeline("}");
 
72
                                writeline("");
 
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 };");
 
76
                                        writeline("");
 
77
                                writeline("// Background");
 
78
                                writeline("plane {");
 
79
                                writeline("  z, 100.0");
 
80
                                writeline("  texture {");
 
81
                                writeline("    pigment { color rgb <0.0,0.0,0.0> }");
 
82
                                writeline("    finish { ambient 1 }");
 
83
                                writeline("  }");
 
84
                                writeline("  hollow");
 
85
                                writeline("}");
 
86
                                writeline("");
 
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");
 
92
                                writeline("  up y");
 
93
                                writeline("  angle 60");
 
94
                                writeline("}");
 
95
                                writeline("");
 
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 } ");
 
100
                                writeline("");
 
101
                        };
 
102
 
 
103
                        void POVRenderer::end() {
 
104
                                // TODO
 
105
                        };
 
106
 
 
107
                        void POVRenderer::setBackgroundColor(SyntopiaCore::Math::Vector3f /*rgb*/) {
 
108
                                // TODO
 
109
                        }
 
110
 
 
111
                }
 
112
        }
 
113
}
 
114