Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
c8c8235c
Commit
c8c8235c
authored
Jul 14, 2011
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE] massively improved povray sdl exporter
parent
cd562f78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
43 deletions
+88
-43
src/modules/writeTracts/WMWriteTracts.cpp
src/modules/writeTracts/WMWriteTracts.cpp
+88
-43
No files found.
src/modules/writeTracts/WMWriteTracts.cpp
View file @
c8c8235c
...
...
@@ -458,12 +458,25 @@ bool WMWriteTracts::saveJsonTriangles() const
bool
WMWriteTracts
::
savePOVRay
(
boost
::
shared_ptr
<
const
WDataSetFibers
>
fibers
)
const
{
// open file
const
char
*
file
=
m_savePath
->
get
().
file_string
().
c_str
();
debugLog
()
<<
"Opening "
<<
file
<<
" for write."
;
std
::
ofstream
dataFile
(
file
,
std
::
ios_base
::
binary
);
boost
::
filesystem
::
path
meshFile
(
m_savePath
->
get
());
std
::
string
fnPath
=
meshFile
.
parent_path
().
string
();
std
::
string
fnBase
=
meshFile
.
stem
();
std
::
string
fnExt
=
meshFile
.
extension
();
// construct the filenames
// the meshfile
std
::
string
fnMesh
=
fnBase
+
".mesh"
+
fnExt
;
std
::
string
fnScene
=
fnBase
+
".scene"
+
fnExt
;
// absolute paths
std
::
string
fnMeshAbs
=
fnPath
+
"/"
+
fnMesh
;
std
::
string
fnSceneAbs
=
fnPath
+
"/"
+
fnScene
;
debugLog
()
<<
"Opening "
<<
fnMeshAbs
<<
" for writing the mesh data."
;
std
::
ofstream
dataFile
(
fnMeshAbs
.
c_str
(),
std
::
ios_base
::
binary
);
if
(
!
dataFile
)
{
errorLog
()
<<
"Opening "
<<
f
ile
<<
" failed."
;
errorLog
()
<<
"Opening "
<<
f
nMeshAbs
<<
" failed."
;
return
false
;
}
...
...
@@ -481,28 +494,6 @@ bool WMWriteTracts::savePOVRay( boost::shared_ptr< const WDataSetFibers > fibers
boost
::
shared_ptr
<
WProgress
>
progress1
=
boost
::
shared_ptr
<
WProgress
>
(
new
WProgress
(
"Converting fibers"
,
fibStart
->
size
()
)
);
m_progress
->
addSubProgress
(
progress1
);
// write some head data
dataFile
<<
"#version 3.5;"
<<
std
::
endl
<<
std
::
endl
;
dataFile
<<
"#include
\"
colors.inc
\"
"
<<
std
::
endl
;
dataFile
<<
"#include
\"
rad_def.inc
\"
"
<<
std
::
endl
<<
std
::
endl
;
dataFile
<<
"global_settings {"
<<
std
::
endl
<<
" ambient_light 0"
<<
std
::
endl
<<
std
::
endl
<<
" radiosity {"
<<
std
::
endl
<<
" pretrace_start 0.08"
<<
std
::
endl
<<
" pretrace_end 0.005"
<<
std
::
endl
<<
" count 350"
<<
std
::
endl
<<
" error_bound 0.15"
<<
std
::
endl
<<
" recursion_limit 2"
<<
std
::
endl
<<
" }"
<<
std
::
endl
<<
"}"
<<
std
::
endl
<<
std
::
endl
<<
"#default{"
<<
std
::
endl
<<
" finish{"
<<
std
::
endl
<<
" ambient 0"
<<
std
::
endl
<<
" phong 1"
<<
std
::
endl
<<
//" reflection 0.9yy " << std::endl <<
" }"
<<
std
::
endl
<<
"}"
<<
std
::
endl
<<
std
::
endl
;
// for each fiber:
debugLog
()
<<
"Iterating over all fibers."
;
...
...
@@ -515,7 +506,7 @@ bool WMWriteTracts::savePOVRay( boost::shared_ptr< const WDataSetFibers > fibers
double
maxZ
=
wlimits
::
MIN_DOUBLE
;
size_t
currentStart
=
0
;
for
(
size_t
fidx
=
0
;
fidx
<
fibStart
->
size
()
;
++
fidx
)
for
(
size_t
fidx
=
0
;
fidx
<
fibStart
->
size
()
;
fidx
+=
5
)
{
++*
progress1
;
...
...
@@ -559,12 +550,14 @@ bool WMWriteTracts::savePOVRay( boost::shared_ptr< const WDataSetFibers > fibers
dataFile
<<
"cylinder"
<<
std
::
endl
<<
"{"
<<
std
::
endl
<<
" <"
<<
lastvert
.
x
()
<<
","
<<
lastvert
.
y
()
<<
","
<<
lastvert
.
z
()
<<
">,"
<<
"<"
<<
vert
.
x
()
<<
","
<<
vert
.
y
()
<<
","
<<
vert
.
z
()
<<
">,0.5"
<<
std
::
endl
<<
"<"
<<
vert
.
x
()
<<
","
<<
vert
.
y
()
<<
","
<<
vert
.
z
()
<<
">,0.
2
5"
<<
std
::
endl
<<
" pigment{color rgb <"
<<
color
.
x
()
<<
","
<<
color
.
y
()
<<
","
<<
color
.
z
()
<<
">}"
<<
std
::
endl
<<
" transform MoveToCenter"
<<
std
::
endl
<<
"}"
<<
std
::
endl
;
dataFile
<<
"sphere {"
<<
std
::
endl
<<
" <"
<<
vert
.
x
()
<<
","
<<
vert
.
y
()
<<
","
<<
vert
.
z
()
<<
">,0.5"
<<
std
::
endl
<<
" <"
<<
vert
.
x
()
<<
","
<<
vert
.
y
()
<<
","
<<
vert
.
z
()
<<
">,0.
2
5"
<<
std
::
endl
<<
" pigment{ color rgb <"
<<
color
.
x
()
<<
","
<<
color
.
y
()
<<
","
<<
color
.
z
()
<<
">}"
<<
std
::
endl
<<
" transform MoveToCenter"
<<
std
::
endl
<<
"}"
<<
std
::
endl
;
lastvert
=
vert
;
...
...
@@ -572,23 +565,75 @@ bool WMWriteTracts::savePOVRay( boost::shared_ptr< const WDataSetFibers > fibers
currentStart
+=
len
;
}
double
mX
=
minX
+
(
(
maxX
-
minX
)
/
2.0
);
double
mY
=
minY
+
(
(
maxY
-
minY
)
/
2.0
);
double
mZ
=
minZ
+
(
(
maxZ
-
minZ
)
/
2.0
);
double
sizeX
=
maxX
-
minX
;
double
sizeY
=
maxY
-
minY
;
double
sizeZ
=
maxZ
-
minZ
;
double
mX
=
minX
+
(
sizeX
/
2.0
);
double
mY
=
minY
+
(
sizeY
/
2.0
);
double
mZ
=
minZ
+
(
sizeZ
/
2.0
);
// done writing mesh. Close
infoLog
()
<<
"Done. Closing "
<<
fnMesh
<<
"."
;
dataFile
.
close
();
progress1
->
finish
();
debugLog
()
<<
"Opening "
<<
fnSceneAbs
<<
" for writing."
;
std
::
ofstream
dataFileScene
(
fnSceneAbs
.
c_str
(),
std
::
ios_base
::
binary
);
if
(
!
dataFileScene
)
{
errorLog
()
<<
"Opening "
<<
fnSceneAbs
<<
" failed."
;
return
false
;
}
// write some head data
dataFileScene
<<
"#version 3.6;"
<<
std
::
endl
<<
std
::
endl
;
dataFileScene
<<
"global_settings {"
<<
std
::
endl
<<
" ambient_light 0"
<<
std
::
endl
<<
std
::
endl
<<
" radiosity {"
<<
std
::
endl
<<
" pretrace_start 0.08"
<<
std
::
endl
<<
" pretrace_end 0.005"
<<
std
::
endl
<<
" count 350"
<<
std
::
endl
<<
" error_bound 0.15"
<<
std
::
endl
<<
" recursion_limit 2"
<<
std
::
endl
<<
" }"
<<
std
::
endl
<<
"}"
<<
std
::
endl
<<
std
::
endl
;
dataFileScene
<<
"#default{"
<<
std
::
endl
<<
" finish{"
<<
std
::
endl
<<
" ambient 0"
<<
std
::
endl
<<
" phong 1"
<<
std
::
endl
<<
//" reflection 0.9yy " << std::endl <<
" }"
<<
std
::
endl
<<
"}"
<<
std
::
endl
<<
std
::
endl
;
// save camera and add a light
dataFile
<<
"camera {"
<<
std
::
endl
<<
" location < "
<<
mX
<<
", "
<<
mY
<<
", -120.0 >"
<<
std
::
endl
<<
" look_at < "
<<
mX
<<
", "
<<
mY
<<
", 0.0 >"
<<
std
::
endl
<<
"}"
<<
std
::
endl
;
dataFile
<<
"light_source {"
<<
std
::
endl
<<
" < "
<<
mX
<<
", "
<<
mY
<<
", -10000.0 >"
<<
std
::
endl
<<
" color rgb <1.0, 1.0, 1.0>"
<<
std
::
endl
<<
"}"
<<
std
::
endl
;
double
camX
=
0
;
double
camY
=
sizeY
;
double
camZ
=
0
;
dataFileScene
<<
"#declare MoveToCenter = transform{ translate < "
<<
-
mX
<<
", "
<<
-
mY
<<
", "
<<
-
mZ
<<
" > };"
<<
std
::
endl
;
dataFileScene
<<
"#declare CamPosition = < "
<<
camX
<<
", "
<<
camY
<<
", "
<<
camZ
<<
" >;"
<<
std
::
endl
<<
std
::
endl
;
// this camera should produce a direct front view. The user surely needs to modify the camera
dataFileScene
<<
"camera {"
<<
std
::
endl
<<
" location CamPosition"
<<
std
::
endl
<<
" right 1.33*x"
<<
std
::
endl
<<
" up y "
<<
std
::
endl
<<
" // angle 45 "
<<
std
::
endl
<<
" look_at < 0, 0, 0 >"
<<
std
::
endl
<<
"}"
<<
std
::
endl
<<
std
::
endl
;
// headlight
dataFileScene
<<
"light_source {"
<<
std
::
endl
<<
" CamPosition"
<<
std
::
endl
<<
" color rgb <1.0, 1.0, 1.0>"
<<
std
::
endl
<<
"}"
<<
std
::
endl
<<
std
::
endl
;
// do not forget the mesh
dataFileScene
<<
"#include
\"
"
<<
fnMesh
<<
"
\"
"
<<
std
::
endl
;
// done. Close
infoLog
()
<<
"Done. Closing "
<<
file
<<
"."
;
dataFile
.
close
();
progress1
->
finish
();
infoLog
()
<<
"Done."
;
dataFileScene
.
close
();
return
true
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment