qtmobility/examples/sensors/cubehouse/light.h
changeset 4 90517678cc4f
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt3D module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef LIGHT_H
       
    43 #define LIGHT_H
       
    44 
       
    45 #include <QtCore/qobject.h>
       
    46 #include <QtCore/qscopedpointer.h>
       
    47 #include <QtGui/qcolor.h>
       
    48 #include <QtGui/qvector3d.h>
       
    49 #include <QtGui/qvector4d.h>
       
    50 
       
    51 class LightPrivate;
       
    52 QT_BEGIN_NAMESPACE
       
    53 class QMatrix4x4;
       
    54 QT_END_NAMESPACE
       
    55 
       
    56 class Light : public QObject
       
    57 {
       
    58     Q_OBJECT
       
    59     Q_ENUMS(LightType)
       
    60     Q_PROPERTY(LightType type READ type)
       
    61     Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
       
    62     Q_PROPERTY(QVector3D direction READ direction WRITE setDirection NOTIFY directionChanged)
       
    63     Q_PROPERTY(QColor ambientColor READ ambientColor WRITE setAmbientColor NOTIFY ambientColorChanged)
       
    64     Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged)
       
    65     Q_PROPERTY(QColor specularColor READ specularColor WRITE setSpecularColor NOTIFY specularColorChanged)
       
    66     Q_PROPERTY(QVector3D spotDirection READ spotDirection WRITE setSpotDirection NOTIFY spotDirectionChanged)
       
    67     Q_PROPERTY(qreal spotExponent READ spotExponent WRITE setSpotExponent NOTIFY spotExponentChanged)
       
    68     Q_PROPERTY(qreal spotAngle READ spotAngle WRITE setSpotAngle NOTIFY spotAngleChanged)
       
    69     Q_PROPERTY(qreal constantAttenuation READ constantAttenuation WRITE setConstantAttenuation NOTIFY constantAttenuationChanged)
       
    70     Q_PROPERTY(qreal linearAttenuation READ linearAttenuation WRITE setLinearAttenuation NOTIFY linearAttenuationChanged)
       
    71     Q_PROPERTY(qreal quadraticAttenuation READ quadraticAttenuation WRITE setQuadraticAttenuation NOTIFY quadraticAttenuationChanged)
       
    72 public:
       
    73     enum LightType {
       
    74         Directional,
       
    75         Positional
       
    76     };
       
    77 
       
    78     Light(QObject *parent = 0);
       
    79     ~Light();
       
    80 
       
    81     Light::LightType type() const;
       
    82 
       
    83     QVector3D position() const;
       
    84     void setPosition(const QVector3D& value);
       
    85 
       
    86     QVector3D direction() const;
       
    87     void setDirection(const QVector3D& value);
       
    88 
       
    89     QColor ambientColor() const;
       
    90     void setAmbientColor(const QColor& value);
       
    91 
       
    92     QColor diffuseColor() const;
       
    93     void setDiffuseColor(const QColor& value);
       
    94 
       
    95     QColor specularColor() const;
       
    96     void setSpecularColor(const QColor& value);
       
    97 
       
    98     QVector3D spotDirection() const;
       
    99     void setSpotDirection(const QVector3D& value);
       
   100 
       
   101     qreal spotExponent() const;
       
   102     void setSpotExponent(qreal value);
       
   103 
       
   104     qreal spotAngle() const;
       
   105     void setSpotAngle(qreal value);
       
   106 
       
   107     qreal spotCosAngle() const;
       
   108 
       
   109     qreal constantAttenuation() const;
       
   110     void setConstantAttenuation(qreal value);
       
   111 
       
   112     qreal linearAttenuation() const;
       
   113     void setLinearAttenuation(qreal value);
       
   114 
       
   115     qreal quadraticAttenuation() const;
       
   116     void setQuadraticAttenuation(qreal value);
       
   117 
       
   118     QVector4D eyePosition(const QMatrix4x4& transform) const;
       
   119     QVector3D eyeSpotDirection(const QMatrix4x4& transform) const;
       
   120 
       
   121 Q_SIGNALS:
       
   122     void positionChanged();
       
   123     void directionChanged();
       
   124     void ambientColorChanged();
       
   125     void diffuseColorChanged();
       
   126     void specularColorChanged();
       
   127     void spotDirectionChanged();
       
   128     void spotExponentChanged();
       
   129     void spotAngleChanged();
       
   130     void constantAttenuationChanged();
       
   131     void linearAttenuationChanged();
       
   132     void quadraticAttenuationChanged();
       
   133     void lightChanged();
       
   134 
       
   135 private:
       
   136     QScopedPointer<LightPrivate> d_ptr;
       
   137 
       
   138     Q_DECLARE_PRIVATE(Light)
       
   139     Q_DISABLE_COPY(Light)
       
   140 };
       
   141 
       
   142 #endif