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 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); }