void Scene::draw() { if(m_view_plane) ::glEnable(GL_DEPTH_TEST); else ::glDisable(GL_DEPTH_TEST); if(m_view_polyhedron) draw_polyhedron(); if(m_view_points) draw_points(); if(m_view_segments) draw_segments(); if (m_view_plane) { switch( m_cut_plane ) { case UNSIGNED_EDGES: case UNSIGNED_FACETS: draw_distance_function(m_thermal_ramp, m_thermal_ramp); break; case SIGNED_FACETS: draw_distance_function(m_red_ramp, m_blue_ramp); break; case CUT_SEGMENTS: draw_cut_segment_plane(); break; case NONE: // do nothing break; } } }
void Controller::draw_bounds() const { logger.info(mmlt_msg("Drawing bounds...")); SVGPainter painter(file_prefix_, QString("bounds_%1.svg").arg(stats_.iteration), bounding_box_); draw_segments(painter); painter.setPenColor(QColor(255, 255, 0)); segments_.draw_range(painter, stats_.lower_bound(), stats_.upper_bound()); painter.setPenColor(QColor(0, 255, 0)); segments_[stats_.lower_bound()].draw(painter); painter.setPenColor(QColor(255, 0, 0)); segments_[stats_.upper_bound()].draw(painter); draw_points(painter); }
void Controller::draw_intersections() const { logger.info( mmlt_msg( "Drawing intersections..." ) ); SegmentIndex segment_index = 0; for(const Intersections& intersections : intersection_graph_) { SVGPainter painter(file_prefix_, QString("%1_intersections.svg").arg(segment_index, 5, 10, QChar('0')), bounding_box_); draw_segments(painter); painter.setPenColor(QColor(0, 255, 0)); segments_[segment_index].draw(painter); painter.setPenColor(QColor(255, 0, 0)); intersections.draw(painter, segments_); draw_points(painter); ++segment_index; } }
idScreenRect R_CalcIntersectionScissor(const idRenderLightLocal *lightDef, const idRenderEntityLocal *entityDef, const viewDef_t *viewDef) { idMat4 omodel = make_idMat4(entityDef->modelMatrix); idMat4 lmodel = make_idMat4(lightDef->modelMatrix); // compute light polyhedron polyhedron lvol = PolyhedronFromBounds(lightDef->frustumTris->bounds); // transform it into world space //lvol.transform( lmodel ); // debug // if (r_useInteractionScissors.GetInteger() == -2) { draw_polyhedron(viewDef, lvol, colorRed); } // compute object polyhedron polyhedron vol = PolyhedronFromBounds(entityDef->referenceBounds); //viewDef->renderWorld->DebugBounds( colorRed, lightDef->frustumTris->bounds ); //viewDef->renderWorld->DebugBox( colorBlue, idBox( model->Bounds(), entityDef->parms.origin, entityDef->parms.axis ) ); // transform it into world space vol.transform(omodel); // debug // if (r_useInteractionScissors.GetInteger() == -2) { draw_polyhedron(viewDef, vol, colorBlue); } // transform light position into world space idVec4 lightpos = idVec4(lightDef->globalLightOrigin.x, lightDef->globalLightOrigin.y, lightDef->globalLightOrigin.z, 1.0f); // generate shadow volume "polyhedron" polyhedron sv = make_sv(vol, lightpos); MySegments in_segs, out_segs; // get shadow volume edges polyhedron_edges(sv, in_segs); // clip them against light bounds planes clip_segments(lvol, in_segs, out_segs); // get light bounds edges polyhedron_edges(lvol, in_segs); // clip them by the shadow volume clip_segments(sv, in_segs, out_segs); // debug // if (r_useInteractionScissors.GetInteger() == -2) { draw_segments(viewDef, out_segs, colorGreen); } idBounds outbounds; outbounds.Clear(); for (unsigned int i = 0; i < out_segs.size(); i++) { idVec4 v; world_to_hclip(viewDef, out_segs[i], v); if (v.w <= 0.0f) { return lightDef->viewLight->scissorRect; } idVec3 rv(v.x, v.y, v.z); rv /= v.w; outbounds.AddPoint(rv); } // limit the bounds to avoid an inside out scissor rectangle due to floating point to short conversion if (outbounds[0].x < -1.0f) { outbounds[0].x = -1.0f; } if (outbounds[1].x > 1.0f) { outbounds[1].x = 1.0f; } if (outbounds[0].y < -1.0f) { outbounds[0].y = -1.0f; } if (outbounds[1].y > 1.0f) { outbounds[1].y = 1.0f; } float w2 = (viewDef->viewport.x2 - viewDef->viewport.x1 + 1) / 2.0f; float x = viewDef->viewport.x1; float h2 = (viewDef->viewport.y2 - viewDef->viewport.y1 + 1) / 2.0f; float y = viewDef->viewport.y1; idScreenRect rect; rect.x1 = outbounds[0].x * w2 + w2 + x; rect.x2 = outbounds[1].x * w2 + w2 + x; rect.y1 = outbounds[0].y * h2 + h2 + y; rect.y2 = outbounds[1].y * h2 + h2 + y; rect.Expand(); rect.Intersect(lightDef->viewLight->scissorRect); // debug // if (r_useInteractionScissors.GetInteger() == -2 && !rect.IsEmpty()) { viewDef->renderWorld->DebugScreenRect(colorYellow, rect, viewDef); } return rect; }
Controller::Controller(const QString& file_prefix, QFile& input_file, const Settings& settings) : cplex_solver_(), intersection_algorithm_(), last_sat_solution_(), stats_(), file_prefix_( file_prefix ), input_file_( input_file ), settings_( settings ), points_( input_file_ ), bounding_box_(points_), convex_hull_(points_), segments_(points_), triangulation_(points_), intersection_graph_(segments_.size()) { logger.print( mmlt_msg( "points=%1 segments=%2 convex hull=%3" ) .arg(points_.size()) .arg(segments_.size()) .arg(convex_hull_.size())); if( !segments_.empty() ) { const Segment& shortest_input_segment = segments_[0]; logger.info( mmlt_msg("shortest input segment: %1 (%2)") .arg(shortest_input_segment.to_string()) .arg(segment_length_to_string(shortest_input_segment)) ); } { QElapsedTimer timer; timer.start(); intersection_algorithm_.run(settings_, intersection_graph_, segments_); logger.time( mmlt_msg( "intersection graph" ), timer.elapsed() ); } if( settings_.draw && settings_.draw_segments ) { logger.debug(mmlt_msg("Drawing segments...")); SVGPainter painter(file_prefix_, "segments.svg", bounding_box_); draw_segments(painter); draw_points(painter); } if( settings_.draw && settings_.draw_intersections ) { draw_intersections(); } if( settings_.draw && settings_.draw_separators ) { draw_separators(); } }