| 1 |
/**************************************************************************** |
| 2 |
|
| 3 |
This file is part of the wolfenqt project on http://qt.gitorious.org. |
| 4 |
|
| 5 |
Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).* |
| 6 |
All rights reserved. |
| 7 |
|
| 8 |
Contact: Nokia Corporation (qt-info@nokia.com)** |
| 9 |
|
| 10 |
You may use this file under the terms of the BSD license as follows: |
| 11 |
|
| 12 |
"Redistribution and use in source and binary forms, with or without |
| 13 |
modification, are permitted provided that the following conditions are met: |
| 14 |
* Redistributions of source code must retain the above copyright notice, |
| 15 |
* this list of conditions and the following disclaimer. |
| 16 |
* Redistributions in binary form must reproduce the above copyright notice, |
| 17 |
* this list of conditions and the following disclaimer in the documentation |
| 18 |
* and/or other materials provided with the distribution. |
| 19 |
* Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the |
| 20 |
* names of its contributors may be used to endorse or promote products |
| 21 |
* derived from this software without specific prior written permission. |
| 22 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 23 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 26 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 27 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 28 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 29 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 30 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 31 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 32 |
POSSIBILITY OF SUCH DAMAGE." |
| 33 |
|
| 34 |
****************************************************************************/ |
| 35 |
#ifndef MODEL_H |
| 36 |
#define MODEL_H |
| 37 |
|
| 38 |
#include <QPainter> |
| 39 |
#include <QString> |
| 40 |
#include <QVector> |
| 41 |
|
| 42 |
#include <math.h> |
| 43 |
|
| 44 |
#include <QMatrix4x4> |
| 45 |
#include <QVector3D> |
| 46 |
|
| 47 |
class Model |
| 48 |
{ |
| 49 |
public: |
| 50 |
Model() {} |
| 51 |
Model(const QString &filePath); |
| 52 |
|
| 53 |
void render(bool wireframe = false, bool normals = false) const; |
| 54 |
void render(QPainter *painter, const QMatrix4x4 &matrix, bool normals = false) const; |
| 55 |
|
| 56 |
QString fileName() const { return m_fileName; } |
| 57 |
int faces() const { return m_pointIndices.size() / 3; } |
| 58 |
int edges() const { return m_edgeIndices.size() / 2; } |
| 59 |
int points() const { return m_points.size(); } |
| 60 |
|
| 61 |
QVector3D size() const; |
| 62 |
|
| 63 |
private: |
| 64 |
QString m_fileName; |
| 65 |
|
| 66 |
QVector<QVector3D> m_points; |
| 67 |
QVector<QVector3D> m_normals; |
| 68 |
|
| 69 |
#ifdef QT_OPENGL_ES_2 |
| 70 |
QVector<ushort> m_edgeIndices; |
| 71 |
QVector<ushort> m_pointIndices; |
| 72 |
#else |
| 73 |
QVector<uint> m_edgeIndices; |
| 74 |
QVector<uint> m_pointIndices; |
| 75 |
#endif |
| 76 |
|
| 77 |
QVector3D m_size; |
| 78 |
|
| 79 |
mutable QVector<QLineF> m_lines; |
| 80 |
mutable QVector<QVector3D> m_mapped; |
| 81 |
}; |
| 82 |
|
| 83 |
#endif |