mirror of https://github.com/vitalif/openscad
Clifford Wolf:
Improved background and highlights rendering git-svn-id: http://svn.clifford.at/openscad/trunk@71 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
f158370f5e
commit
fcde390416
|
@ -72,6 +72,8 @@ CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const
|
|||
bool first = true;
|
||||
CGAL_Nef_polyhedron N;
|
||||
foreach (AbstractNode *v, children) {
|
||||
if (v->modinst->tag_background)
|
||||
continue;
|
||||
if (first) {
|
||||
N = v->render_cgal_nef_polyhedron();
|
||||
first = false;
|
||||
|
|
74
mainwin.cc
74
mainwin.cc
|
@ -864,11 +864,10 @@ static void renderGLviaOpenCSG(void *vp)
|
|||
shaderinfo = NULL;
|
||||
renderCSGChainviaOpenCSG(m->root_chain, m->actViewModeShowEdges->isChecked() ? shaderinfo : NULL, false, false);
|
||||
if (m->background_chain) {
|
||||
renderCSGChainviaOpenCSG(m->background_chain, shaderinfo, false, true);
|
||||
renderCSGChainviaOpenCSG(m->background_chain, m->actViewModeShowEdges->isChecked() ? shaderinfo : NULL, false, true);
|
||||
}
|
||||
if (m->highlights_chain) {
|
||||
glDisable(GL_LIGHTING);
|
||||
renderCSGChainviaOpenCSG(m->highlights_chain, shaderinfo, true, false);
|
||||
renderCSGChainviaOpenCSG(m->highlights_chain, m->actViewModeShowEdges->isChecked() ? shaderinfo : NULL, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -951,35 +950,58 @@ void MainWindow::viewModeCGALGrid()
|
|||
|
||||
#endif /* ENABLE_CGAL */
|
||||
|
||||
static void renderGLThrownTogether(void *vp)
|
||||
static void renderGLThrownTogetherChain(MainWindow *m, CSGChain *chain, bool highlight, bool background)
|
||||
{
|
||||
MainWindow *m = (MainWindow*)vp;
|
||||
if (m->root_chain) {
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
QHash<PolySet*,int> polySetVisitMark;
|
||||
bool showEdges = m->actViewModeShowEdges->isChecked();
|
||||
for (int i = 0; i < m->root_chain->polysets.size(); i++) {
|
||||
if (polySetVisitMark[m->root_chain->polysets[i]]++ > 0)
|
||||
continue;
|
||||
if (m->root_chain->types[i] == CSGTerm::DIFFERENCE) {
|
||||
m->root_chain->polysets[i]->render_surface(PolySet::COLOR_CUTOUT);
|
||||
if (showEdges) {
|
||||
glDisable(GL_LIGHTING);
|
||||
m->root_chain->polysets[i]->render_edges(PolySet::COLOR_CUTOUT);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
} else {
|
||||
m->root_chain->polysets[i]->render_surface(PolySet::COLOR_MATERIAL);
|
||||
if (showEdges) {
|
||||
glDisable(GL_LIGHTING);
|
||||
m->root_chain->polysets[i]->render_edges(PolySet::COLOR_MATERIAL);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
QHash<PolySet*,int> polySetVisitMark;
|
||||
bool showEdges = m->actViewModeShowEdges->isChecked();
|
||||
for (int i = 0; i < chain->polysets.size(); i++) {
|
||||
if (polySetVisitMark[chain->polysets[i]]++ > 0)
|
||||
continue;
|
||||
if (highlight) {
|
||||
chain->polysets[i]->render_surface(PolySet::COLOR_HIGHLIGHT);
|
||||
if (showEdges) {
|
||||
glDisable(GL_LIGHTING);
|
||||
chain->polysets[i]->render_edges(PolySet::COLOR_HIGHLIGHT);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
} else if (background) {
|
||||
chain->polysets[i]->render_surface(PolySet::COLOR_BACKGROUND);
|
||||
if (showEdges) {
|
||||
glDisable(GL_LIGHTING);
|
||||
chain->polysets[i]->render_edges(PolySet::COLOR_BACKGROUND);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
} else if (chain->types[i] == CSGTerm::DIFFERENCE) {
|
||||
chain->polysets[i]->render_surface(PolySet::COLOR_CUTOUT);
|
||||
if (showEdges) {
|
||||
glDisable(GL_LIGHTING);
|
||||
chain->polysets[i]->render_edges(PolySet::COLOR_CUTOUT);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
} else {
|
||||
chain->polysets[i]->render_surface(PolySet::COLOR_MATERIAL);
|
||||
if (showEdges) {
|
||||
glDisable(GL_LIGHTING);
|
||||
chain->polysets[i]->render_edges(PolySet::COLOR_MATERIAL);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void renderGLThrownTogether(void *vp)
|
||||
{
|
||||
MainWindow *m = (MainWindow*)vp;
|
||||
if (m->root_chain)
|
||||
renderGLThrownTogetherChain(m, m->root_chain, false, false);
|
||||
if (m->background_chain)
|
||||
renderGLThrownTogetherChain(m, m->background_chain, false, true);
|
||||
if (m->highlights_chain)
|
||||
renderGLThrownTogetherChain(m, m->highlights_chain, true, false);
|
||||
}
|
||||
|
||||
void MainWindow::viewModeThrownTogether()
|
||||
{
|
||||
viewModeActionsUncheck();
|
||||
|
|
|
@ -239,8 +239,11 @@ CGAL_Nef_polyhedron AbstractNode::render_cgal_nef_polyhedron() const
|
|||
}
|
||||
|
||||
CGAL_Nef_polyhedron N;
|
||||
foreach (AbstractNode *v, children)
|
||||
foreach (AbstractNode *v, children) {
|
||||
if (v->modinst->tag_background)
|
||||
continue;
|
||||
N += v->render_cgal_nef_polyhedron();
|
||||
}
|
||||
|
||||
cgal_nef_cache.insert(cache_id, new CGAL_Nef_polyhedron(N), N.number_of_vertices());
|
||||
progress_report();
|
||||
|
|
|
@ -115,7 +115,7 @@ void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const
|
|||
#endif /* ENABLE_OPENCSG */
|
||||
}
|
||||
if (colormode == COLOR_HIGHLIGHT) {
|
||||
glColor3ub(255, 157, 81);
|
||||
glColor4ub(255, 157, 81, 128);
|
||||
#ifdef ENABLE_OPENCSG
|
||||
if (shaderinfo) {
|
||||
glUniform4f(shaderinfo[1], 255 / 255.0, 157 / 255.0, 81 / 255.0, 0.5);
|
||||
|
@ -124,7 +124,7 @@ void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const
|
|||
#endif /* ENABLE_OPENCSG */
|
||||
}
|
||||
if (colormode == COLOR_BACKGROUND) {
|
||||
glColor3ub(180, 180, 180);
|
||||
glColor4ub(180, 180, 180, 128);
|
||||
#ifdef ENABLE_OPENCSG
|
||||
if (shaderinfo) {
|
||||
glUniform4f(shaderinfo[1], 180 / 255.0, 180 / 255.0, 180 / 255.0, 0.5);
|
||||
|
@ -176,9 +176,9 @@ void PolySet::render_edges(colormode_e colormode) const
|
|||
if (colormode == COLOR_CUTOUT)
|
||||
glColor3ub(171, 216, 86);
|
||||
if (colormode == COLOR_HIGHLIGHT)
|
||||
glColor3ub(255, 171, 86);
|
||||
glColor4ub(255, 171, 86, 128);
|
||||
if (colormode == COLOR_BACKGROUND)
|
||||
glColor3ub(150, 150, 150);
|
||||
glColor4ub(150, 150, 150, 128);
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
const Polygon *poly = &polygons[i];
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
|
|
@ -86,6 +86,8 @@ CGAL_Nef_polyhedron RenderNode::render_cgal_nef_polyhedron() const
|
|||
CGAL_Nef_polyhedron N;
|
||||
foreach(AbstractNode * v, children)
|
||||
{
|
||||
if (v->modinst->tag_background)
|
||||
continue;
|
||||
if (first) {
|
||||
N = v->render_cgal_nef_polyhedron();
|
||||
first = false;
|
||||
|
|
|
@ -153,8 +153,12 @@ CGAL_Nef_polyhedron TransformNode::render_cgal_nef_polyhedron() const
|
|||
}
|
||||
|
||||
CGAL_Nef_polyhedron N;
|
||||
foreach (AbstractNode *v, children)
|
||||
foreach (AbstractNode *v, children) {
|
||||
if (v->modinst->tag_background)
|
||||
continue;
|
||||
N += v->render_cgal_nef_polyhedron();
|
||||
}
|
||||
|
||||
CGAL_Aff_transformation t(
|
||||
m[0], m[4], m[ 8], m[12],
|
||||
m[1], m[5], m[ 9], m[13],
|
||||
|
|
Loading…
Reference in New Issue