From 68f0d317f5908d8c9f305d487dc30cbdb6ab72ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Jacob?= Date: Sun, 25 Jun 2006 13:08:39 +0000 Subject: [PATCH] Add intelligent (so to speak) level-of-detail handling in Kalzium's OpenGL engine. For instance smaller spheres will be drawn with smaller detail level. CCMAIL: cniehaus@gmx.de M kalzium/src/kalziumglwidget.cpp svn path=/trunk/KDE/kdeedu/kalzium/src/kalziumglwidget.cpp; revision=554822 --- kalzium/kalziumglwidget.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kalzium/kalziumglwidget.cpp b/kalzium/kalziumglwidget.cpp index cd22ecd..7dfb285 100644 --- a/kalzium/kalziumglwidget.cpp +++ b/kalzium/kalziumglwidget.cpp @@ -275,8 +275,22 @@ void KalziumGLWidget::mouseMoveEvent( QMouseEvent * event ) void KalziumGLWidget::setupObjects() { - m_sphere.setup( 3 * ( m_detail + 1 ), atomRadius() ); - m_cylinder.setup( 8 * ( m_detail + 1 ), bondRadius() ); + int sphere_detail, cylinder_faces; + + if( m_atomRadiusCoeff < 0.05) sphere_detail = 1; + else if( m_atomRadiusCoeff < 0.30) sphere_detail = 2; + else sphere_detail = 3; + + sphere_detail *= ( m_detail + 1 ); + + if( m_bondRadiusCoeff < 0.02) cylinder_faces = 4; + else if( m_bondRadiusCoeff < 0.10) cylinder_faces = 6; + else cylinder_faces = 8; + + cylinder_faces *= ( m_detail + 1 ); + + m_sphere.setup( sphere_detail, atomRadius() ); + m_cylinder.setup( cylinder_faces, bondRadius() ); } void KalziumGLWidget::drawSphere( GLdouble x, GLdouble y, GLdouble z, -- 2.47.3