void RotateHandle::renderRing(Model::RotateHandleHit* hit, Renderer::Vbo& vbo, Renderer::RenderContext& context, float angle) { assert(hit != NULL); Vec3f xAxis, yAxis, zAxis; axes(context.camera().position(), xAxis, yAxis, zAxis); Renderer::ActivateShader shader(context.shaderManager(), Renderer::Shaders::HandleShader); Mat4f rotation; if (hit->hitArea() == Model::RotateHandleHit::HAXAxis) { rotation = rotationMatrix(angle, Vec3f::PosX); Renderer::ApplyModelMatrix applyRotation(context.transformation(), rotation); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f)); Renderer::RingFigure(Axis::AX, yAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, context); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 1.0f)); Renderer::CircleFigure(Axis::AX, 0.0f, 2.0f * Math<float>::Pi, m_ringRadius + m_ringThickness, 32, false).render(vbo, context); } else if (hit->hitArea() == Model::RotateHandleHit::HAYAxis) { rotation = rotationMatrix(angle, Vec3f::PosY); Renderer::ApplyModelMatrix applyRotation(context.transformation(), rotation); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f)); Renderer::RingFigure(Axis::AY, xAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, context); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 1.0f)); Renderer::CircleFigure(Axis::AY, 0.0f, 2.0f * Math<float>::Pi, m_ringRadius + m_ringThickness, 32, false).render(vbo, context); } else { rotation = rotationMatrix(angle, Vec3f::PosZ); Renderer::ApplyModelMatrix applyRotation(context.transformation(), rotation); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f)); Renderer::RingFigure(Axis::AZ, xAxis, yAxis, m_ringRadius, m_ringThickness, 8).render(vbo, context); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 1.0f)); Renderer::CircleFigure(Axis::AZ, 0.0f, 2.0f * Math<float>::Pi, m_ringRadius + m_ringThickness, 32, false).render(vbo, context); } }
void doRender(Renderer::RenderContext& renderContext) { const Model::BrushFace* face = m_helper.face(); const Mat4x4 fromFace = face->fromTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true); const Plane3& boundary = face->boundary(); const Mat4x4 toPlane = planeProjectionMatrix(boundary.distance, boundary.normal); const Mat4x4 fromPlane = invertedMatrix(toPlane); const Vec2f originPosition(toPlane * fromFace * Vec3(m_helper.originInFaceCoords())); const Vec2f faceCenterPosition(toPlane * m_helper.face()->boundsCenter()); const Color& handleColor = pref(Preferences::HandleColor); const Color& highlightColor = pref(Preferences::SelectedHandleColor); Renderer::ActiveShader shader(renderContext.shaderManager(), Renderer::Shaders::VaryingPUniformCShader); const Renderer::MultiplyModelMatrix toWorldTransform(renderContext.transformation(), fromPlane); { const Mat4x4 translation = translationMatrix(Vec3(originPosition)); const Renderer::MultiplyModelMatrix centerTransform(renderContext.transformation(), translation); if (m_highlight) shader.set("Color", highlightColor); else shader.set("Color", handleColor); m_outer.render(); } { const Mat4x4 translation = translationMatrix(Vec3(faceCenterPosition)); const Renderer::MultiplyModelMatrix centerTransform(renderContext.transformation(), translation); shader.set("Color", highlightColor); m_center.render(); } }
void RotateHandle::render(Model::RotateHandleHit* hit, Renderer::Vbo& vbo, Renderer::RenderContext& renderContext, float angle) { Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences(); const float distance = renderContext.camera().distanceTo(position()); const float factor = prefs.getFloat(Preferences::HandleScalingFactor) * distance; const Mat4f matrix = translationMatrix(position()) * scalingMatrix(factor); Renderer::ApplyModelMatrix applyTranslation(renderContext.transformation(), matrix); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); Renderer::SetVboState activateVbo(vbo, Renderer::Vbo::VboActive); if (hit != NULL) { renderAxis(hit, vbo, renderContext); renderRing(hit, vbo, renderContext, angle); } else { Vec3f xAxis, yAxis, zAxis; axes(renderContext.camera().position(), xAxis, yAxis, zAxis); Renderer::ActivateShader coloredShader(renderContext.shaderManager(), Renderer::Shaders::ColoredHandleShader); Renderer::AxisFigure axisFigure(m_axisLength); axisFigure.setAxes(true, true, true); axisFigure.setXColor(prefs.getColor(Preferences::XColor)); axisFigure.setYColor(prefs.getColor(Preferences::YColor)); axisFigure.setZColor(prefs.getColor(Preferences::ZColor)); axisFigure.render(vbo, renderContext); Renderer::ActivateShader shader(renderContext.shaderManager(), Renderer::Shaders::HandleShader); shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f)); Renderer::RingFigure(Axis::AX, yAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext); Renderer::RingFigure(Axis::AY, xAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext); Renderer::RingFigure(Axis::AZ, xAxis, yAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext); } glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); }