summaryrefslogtreecommitdiff
path: root/src/export_png.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-09-12 05:17:17 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-09-12 05:17:17 (GMT)
commit6af6c311a12a0211545e29666c92f1806ca0c7e8 (patch)
tree5af3769a2bbd2cdc44508152cc1d2c72b2331e77 /src/export_png.cc
parentb53dde04e2a13c066cfa0c552fe5bd0cdd1b8dbd (diff)
cmdline throwntogether, integrate w chrysn tests, update resize tests
Diffstat (limited to 'src/export_png.cc')
-rw-r--r--src/export_png.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/export_png.cc b/src/export_png.cc
index c6c191c..fcc64fc 100644
--- a/src/export_png.cc
+++ b/src/export_png.cc
@@ -96,5 +96,42 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
#endif
}
+#include "ThrownTogetherRenderer.h"
+void export_png_with_throwntogether(Tree &tree, Camera &cam, std::ostream &output)
+{
+ CsgInfo csgInfo = CsgInfo();
+ if ( !csgInfo.compile_chains( tree ) ) {
+ fprintf(stderr,"Couldn't initialize OpenCSG chains\n");
+ return;
+ }
+
+ try {
+ csgInfo.glview = new OffscreenView( cam.pixel_width, cam.pixel_height );
+ } catch (int error) {
+ fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i.\n", error);
+ return;
+ }
+
+ ThrownTogetherRenderer thrownTogetherRenderer( csgInfo.root_chain,
+ csgInfo.highlights_chain, csgInfo.background_chain );
+
+ if (cam.type == Camera::NONE) {
+ cam.type = Camera::VECTOR;
+ double radius = 1.0;
+ if (csgInfo.root_chain) {
+ BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
+ cam.center = (bbox.min() + bbox.max()) / 2;
+ radius = (bbox.max() - bbox.min()).norm() / 2;
+ }
+ Vector3d cameradir(1, 1, -0.5);
+ cam.eye = cam.center - radius*1.8*cameradir;
+ }
+
+ csgInfo.glview->setCamera( cam );
+ csgInfo.glview->setRenderer(&thrownTogetherRenderer);
+ csgInfo.glview->paintGL();
+ csgInfo.glview->save(output);
+}
+
#endif // ENABLE_CGAL
contact: Jan Huwald // Impressum