From 5dc6abb7062e7767127db33cf628310e08b9a026 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 11 Jan 2016 12:35:54 +0100 Subject: Add method for calculating field positions --- src/glchessboard.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/glchessboard.cpp') diff --git a/src/glchessboard.cpp b/src/glchessboard.cpp index afab9e8..c47fea5 100644 --- a/src/glchessboard.cpp +++ b/src/glchessboard.cpp @@ -30,3 +30,11 @@ void GLChessboard::drawBoard(GLESRenderer *renderer) field.draw(renderer); } } + +QVector3D GLChessboard::fieldToPosition(const QPoint &field) +{ + double fieldWidth = m_width / 8; + double fieldHeight = m_height / 8; + + return QVector3D(fieldWidth/2 + field.x() * fieldWidth, fieldHeight/2 + field.y() * fieldHeight, 0.0); +} -- cgit v1.2.3-70-g09d2