diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-12-07 14:27:09 +0100 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-12-07 14:27:09 +0100 |
| commit | 8015c4c0e157e89d362fc4e12790d22e2e9fa875 (patch) | |
| tree | b0aac068de583ce9c86f76d836c1cc0af5699847 /src/gldisc.cpp | |
| parent | ea5d94326bb6c159d7ee3d7965d7fc17992af09d (diff) | |
| download | Multimedia-8015c4c0e157e89d362fc4e12790d22e2e9fa875.tar.gz Multimedia-8015c4c0e157e89d362fc4e12790d22e2e9fa875.zip | |
Implement skeleton
Diffstat (limited to 'src/gldisc.cpp')
| -rw-r--r-- | src/gldisc.cpp | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/src/gldisc.cpp b/src/gldisc.cpp index cf65450..5002fe8 100644 --- a/src/gldisc.cpp +++ b/src/gldisc.cpp @@ -3,15 +3,83 @@ GLDisc::GLDisc(double radius, double height, int sides) :GLBody(radius) { - + m_height = height; + m_sides = sides; } void GLDisc::makeSurface(QVector<GLPoint> *pointContainer, QVector<GLshort> *indexContainer) { + GLBody::makeSurface(pointContainer, indexContainer); + + QVector3D t0 = QVector3D(0.0, 0.0, 0.0); //dummy texture + + m_firstPoint = m_points->size(); + + m_points->append(GLPoint(v_Zero, -v_Z, t0, m_color)); + + for(int side = 0; side < m_sides; side++) + { + QVector2D tmp = calculatePoint(side * 2 * M_PI / m_sides); + + m_points->append(GLPoint(m_radius * tmp, -v_Z, t0, m_color)); + m_points->append(GLPoint(m_radius * tmp, tmp, t0, m_color)); + m_points->append(GLPoint(QVector3D(m_radius * tmp, m_height), tmp, t0, m_color)); + m_points->append(GLPoint(QVector3D(m_radius * tmp, m_height), v_Z, t0, m_color)); + } + + m_points->append(GLPoint(m_height * v_Z, v_Z, t0, m_color)); + + m_nextPoint = m_points->size(); + + m_firstIndex = m_indices->size(); + + for(int side = 0; side < m_sides - 1; side++) + { + m_indices->append(m_firstPoint); + m_indices->append(m_firstPoint + 1 + 4 * side); + m_indices->append(m_firstPoint + 5 + 4 * side); + + m_indices->append(m_firstPoint + 2 + 4 * side); + m_indices->append(m_firstPoint + 6 + 4 * side); + m_indices->append(m_firstPoint + 3 + 4 * side); + m_indices->append(m_firstPoint + 3 + 4 * side); + m_indices->append(m_firstPoint + 7 + 4 * side); + m_indices->append(m_firstPoint + 6 + 4 * side); + + m_indices->append(m_firstPoint + 4 + 4 * side); + m_indices->append(m_firstPoint + 8 + 4 * side); + m_indices->append(m_nextPoint - 1); + } + + m_indices->append(m_firstPoint); + m_indices->append(m_firstPoint + 1 + 4 * (m_sides - 1)); + m_indices->append(m_firstPoint + 1); + + m_indices->append(m_firstPoint + 2 + 4 * (m_sides - 1)); + m_indices->append(m_firstPoint + 2); + m_indices->append(m_firstPoint + 3 + 4 * (m_sides - 1)); + + m_indices->append(m_firstPoint + 3 + 4 * (m_sides - 1)); + m_indices->append(m_firstPoint + 3); + m_indices->append(m_firstPoint + 2); + + m_indices->append(m_firstPoint + 4 + 4 * (m_sides - 1)); + m_indices->append(m_firstPoint + 4); + m_indices->append(m_nextPoint - 1); + + m_nextIndex = m_indices->size(); } bool GLDisc::isHit(QVector3D p1, QVector3D p2) { } + +QVector2D GLDisc::calculatePoint(double sideAngle) +{ + double x = sin(sideAngle); + double y = cos(sideAngle); + + return QVector2D(x, y); +} |
