1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef ENTITY_H
#define ENTITY_H
#include <Qt3DCore/QEntity>
#include <QtGui/QColor>
#include <QtGui/QVector3D>
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
class QTransform;
}
namespace Qt3DRender {
class QEffect;
class QGeometryRenderer;
class QMaterial;
class QParameter;
}
QT_END_NAMESPACE
class Entity : public Qt3DCore::QEntity
{
Q_OBJECT
Q_PROPERTY(float theta READ theta WRITE setTheta NOTIFY thetaChanged)
Q_PROPERTY(float phi READ phi WRITE setPhi NOTIFY phiChanged)
Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged)
public:
Entity(Qt3DRender::QEffect *effect, Qt3DCore::QNode *parent = 0);
float theta() const;
float phi() const;
QVector3D position() const;
QColor diffuseColor() const;
public slots:
void setTheta(float theta);
void setPhi(float phi);
void setPosition(QVector3D position);
void setDiffuseColor(QColor diffuseColor);
signals:
void thetaChanged(float theta);
void phiChanged(float phi);
void positionChanged(QVector3D position);
void diffuseColorChanged(QColor diffuseColor);
private:
void updateTransform();
private:
Qt3DCore::QTransform *m_transform;
Qt3DRender::QMaterial *m_material;
Qt3DRender::QParameter *m_diffuseColorParam;
float m_theta;
float m_phi;
QVector3D m_position;
};
#endif // ENTITY_H
|