diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-03-04 01:47:07 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-03-04 01:47:07 (GMT) |
commit | 42ca2151b1f671169ac51bac77ee45c676c1b967 (patch) | |
tree | 535d151c9928e6ac515ddedff733d334aaad5686 | |
parent | daf695b089be237fea1028621554b714ffe1872a (diff) |
cleanups
-rw-r--r-- | src/Camera.h | 12 | ||||
-rw-r--r-- | src/CsgInfo.h | 19 | ||||
-rw-r--r-- | src/GLView.cc | 17 | ||||
-rw-r--r-- | src/OGL_helper.h | 1 | ||||
-rw-r--r-- | src/OpenCSGRenderer.cc | 6 | ||||
-rw-r--r-- | src/export_png.cc | 3 | ||||
-rw-r--r-- | src/openscad.cc | 2 | ||||
-rw-r--r-- | tests/csgtestcore.cc | 2 |
8 files changed, 26 insertions, 36 deletions
diff --git a/src/Camera.h b/src/Camera.h index 3e71347..d79fc8f 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -12,12 +12,14 @@ There are two different types of cameras represented in this class: *Gimbal camera - uses Euler Angles, object translation, and viewer distance *Vector camera - uses 'eye', 'center', and 'up' vectors ('lookat' style) -There are two modes of projection, Perspective and Orthogonal. +They are not necessarily kept in sync. There are two modes of +projection, Perspective and Orthogonal. */ #include <vector> #include <Eigen/Geometry> +#include "rendersettings.h" class Camera { @@ -26,7 +28,6 @@ public: enum ProjectionType { ORTHOGONAL, PERSPECTIVE } projection; Camera() { type = Camera::NONE; - projection = Camera::PERSPECTIVE; } Camera( enum CameraType e ) { @@ -40,8 +41,8 @@ public: Eigen::Vector3d cameradir(1, 1, -0.5); eye = center - 500 * cameradir; } - pixel_width = 512; - pixel_height = 512; + pixel_width = RenderSettings::inst()->img_width; + pixel_height = RenderSettings::inst()->img_height; projection = Camera::PERSPECTIVE; } @@ -58,12 +59,13 @@ public: } else { assert( "Gimbal cam needs 7 numbers, Vector camera needs 6" ); } + projection = Camera::PERSPECTIVE; } // Vectorcam Eigen::Vector3d eye; Eigen::Vector3d center; // (aka 'target') - Eigen::Vector3d up; + Eigen::Vector3d up; // not used currently // Gimbalcam Eigen::Vector3d object_trans; diff --git a/src/CsgInfo.h b/src/CsgInfo.h index 0413bec..37fe0d0 100644 --- a/src/CsgInfo.h +++ b/src/CsgInfo.h @@ -29,20 +29,15 @@ public: CSGChain *highlights_chain; std::vector<shared_ptr<CSGTerm> > background_terms; CSGChain *background_chain; - int normalizelimit; - void (*progress_function)(void); - void set_progress_function( void (*funcname)(void) ) - { - progress_function = funcname; - } + void (*progress_function)(); void call_progress_function() { if (progress_function) progress_function(); } - bool prep_chains( const Tree &tree ) + bool compile_chains( const Tree &tree ) { const AbstractNode *root_node = tree.root(); CGALEvaluator cgalevaluator(tree); @@ -50,7 +45,7 @@ public: boost::shared_ptr<CSGTerm> root_raw_term = evaluator.evaluateCSGTerm( *root_node, this->highlight_terms, this->background_terms ); if (!root_raw_term) { - fprintf(stderr, "Error: CSG generation failed! (no top level object found)\n"); + PRINT("Error: CSG generation failed! (no top level object found)"); call_progress_function(); return false; } @@ -62,16 +57,16 @@ public: if (this->root_norm_term) { this->root_chain = new CSGChain(); this->root_chain->import(this->root_norm_term); - fprintf(stderr, "Normalized CSG tree has %d elements\n", int(this->root_chain->polysets.size())); + fprintf(stderr, "Normalized CSG tree has %d elements", int(this->root_chain->polysets.size())); } else { this->root_chain = NULL; - fprintf(stderr, "WARNING: CSG normalization resulted in an empty tree\n"); + PRINT("WARNING: CSG normalization resulted in an empty tree"); call_progress_function(); } if (this->highlight_terms.size() > 0) { - std::cerr << "Compiling highlights (" << this->highlight_terms.size() << " CSG Trees)...\n"; + PRINTB("Compiling highlights (%i CSG Trees)...", this->highlight_terms.size() ); call_progress_function(); this->highlights_chain = new CSGChain(); for (unsigned int i = 0; i < this->highlight_terms.size(); i++) { @@ -81,7 +76,7 @@ public: } if (this->background_terms.size() > 0) { - std::cerr << "Compiling background (%d CSG Trees)..." << this->background_terms.size() << " CSG Trees)...\n"; + PRINTB("Compiling background (%i CSG Trees)...", this->background_terms.size()); call_progress_function(); this->background_chain = new CSGChain(); for (unsigned int i = 0; i < this->background_terms.size(); i++) { diff --git a/src/GLView.cc b/src/GLView.cc index e7878ea..aff3583 100644 --- a/src/GLView.cc +++ b/src/GLView.cc @@ -87,8 +87,6 @@ void GLView::setupVectorCamOrtho(bool offset) void GLView::setCamera( Camera &cam ) { this->cam = cam; - // kludge to make showAxes() work on vector camera - cam.viewer_distance = 10*3*(cam.center - cam.eye).norm(); } void GLView::paintGL() @@ -412,10 +410,10 @@ void GLView::showSmallaxes() // FIXME: This was an attempt to keep contrast with background, but is suboptimal // (e.g. nearly invisible against a gray background). -// int r,g,b; -// r=g=b=0; -// bgcol.getRgb(&r, &g, &b); -// glColor3f((255.0f-r)/255.0f, (255.0f-g)/255.0f, (255.0f-b)/255.0f); + // int r,g,b; + // r=g=b=0; + // bgcol.getRgb(&r, &g, &b); + // glColor3f((255.0f-r)/255.0f, (255.0f-g)/255.0f, (255.0f-b)/255.0f); glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); // X Label @@ -428,6 +426,8 @@ void GLView::showSmallaxes() glVertex3d(zlabel_x-3, zlabel_y-3, 0); glVertex3d(zlabel_x+3, zlabel_y-3, 0); glVertex3d(zlabel_x-3, zlabel_y+3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0); glVertex3d(zlabel_x-3, zlabel_y-3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0); + // FIXME - depends on gimbal camera 'viewer distance'.. how to fix this + // for VectorCamera? glEnd(); //Restore perspective for next paint @@ -437,10 +437,9 @@ void GLView::showSmallaxes() void GLView::showAxes() { + // FIXME: doesn't work under Vector Camera // Large gray axis cross inline with the model // FIXME: This is always gray - adjust color to keep contrast with background - // FIXME - depends on gimbal camera 'viewer distance'.. how to fix this - // for VectorCamera? glLineWidth(1); glColor3d(0.5, 0.5, 0.5); glBegin(GL_LINES); @@ -456,7 +455,7 @@ void GLView::showAxes() void GLView::showCrosshairs() { - // FIXME: this might not work with non-gimbal camera? + // FIXME: this might not work with Vector camera // FIXME: Crosshairs and axes are lighted, this doesn't make sense and causes them // to change color based on view orientation. glLineWidth(3); diff --git a/src/OGL_helper.h b/src/OGL_helper.h index 24611e7..74f92bf 100644 --- a/src/OGL_helper.h +++ b/src/OGL_helper.h @@ -544,7 +544,6 @@ namespace OGL { if (switches[SNC_AXES]) glCallList(object_list_+3); // axis } - void debug(std::ostream& os = std::cerr) const { os << "OGL::Polyhedron" << std::endl; diff --git a/src/OpenCSGRenderer.cc b/src/OpenCSGRenderer.cc index 8e4aba9..eb66687 100644 --- a/src/OpenCSGRenderer.cc +++ b/src/OpenCSGRenderer.cc @@ -38,7 +38,7 @@ class OpenCSGPrim : public OpenCSG::Primitive public: OpenCSGPrim(OpenCSG::Operation operation, unsigned int convexity) : OpenCSG::Primitive(operation, convexity) { } - boost::shared_ptr<PolySet> ps; + shared_ptr<PolySet> ps; Transform3d m; PolySet::csgmode_e csgmode; virtual void render() { @@ -71,10 +71,6 @@ void OpenCSGRenderer::draw(bool /*showfaces*/, bool showedges) const } } -#include "CGALEvaluator.h" -#include "CSGTermEvaluator.h" -#include "csgtermnormalizer.h" - void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo, bool highlight, bool background) const { diff --git a/src/export_png.cc b/src/export_png.cc index 33fb85b..5c11b9f 100644 --- a/src/export_png.cc +++ b/src/export_png.cc @@ -59,7 +59,7 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output) { #ifdef ENABLE_OPENCSG CsgInfo csgInfo = CsgInfo(); - if ( !csgInfo.prep_chains( tree ) ) { + if ( !csgInfo.compile_chains( tree ) ) { fprintf(stderr,"Couldn't initialize OpenCSG chains\n"); return; } @@ -75,7 +75,6 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output) if (cam.type == Camera::NONE) { cam.type = Camera::VECTOR; - cam.center << 0,0,0; double radius = 1.0; if (csgInfo.root_chain) { BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); diff --git a/src/openscad.cc b/src/openscad.cc index c2aab3d..6c46bb4 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -124,7 +124,7 @@ Camera get_camera( po::variables_map vm ) string proj = vm["projection"].as<string>(); if (proj=="o" || proj=="ortho" || proj=="orthogonal") camera.projection = Camera::ORTHOGONAL; - else if (proj=="p" || proj == "perspective") + else if (proj=="p" || proj=="perspective") camera.projection = Camera::PERSPECTIVE; else { fprintf(stderr,"projection needs to be 'o' or 'p' for ortho or perspective"); diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 5820e44..7583a41 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -167,7 +167,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) Tree tree(root_node); CsgInfo csgInfo = CsgInfo(); - if ( !csgInfo.prep_chains( tree ) ) return 1; + if ( !csgInfo.compile_chains( tree ) ) return 1; fs::current_path(original_path); |