00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Arjen Hiemstra <ahiemstra@heimr.nl> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #ifndef GLUONENGINE_SPHERECOLLISIONCOMPONENT_H 00021 #define GLUONENGINE_SPHERECOLLISIONCOMPONENT_H 00022 00023 #include "gluon_engine_export.h" 00024 #include "component.h" 00025 00026 namespace GluonEngine 00027 { 00036 class GLUON_ENGINE_EXPORT SphereCollisionComponent : public Component 00037 { 00038 Q_OBJECT 00039 GLUON_OBJECT( GluonEngine::SphereCollisionComponent ) 00040 Q_INTERFACES( GluonEngine::Component ) 00041 00042 Q_PROPERTY( int collisionGroup READ collisionGroup WRITE setCollisionGroup ) 00043 Q_PROPERTY( float radius READ radius WRITE setRadius ) 00044 00045 public: 00049 Q_INVOKABLE SphereCollisionComponent( QObject* parent = 0 ); 00053 ~SphereCollisionComponent(); 00054 virtual QString category() const; 00055 00056 virtual void start(); 00057 00058 virtual void stop(); 00059 00066 virtual void update( int elapsedMilliseconds ); 00067 00071 int collisionGroup() const; 00075 float radius() const; 00076 00080 Q_INVOKABLE bool isColliding() const; 00087 Q_INVOKABLE QObject* collidesWith() const; 00088 00089 public Q_SLOTS: 00093 void setCollisionGroup( int group ); 00097 void setRadius( float radius ); 00098 void componentDestroyed( QObject* obj ); 00099 void addComponent( SphereCollisionComponent* comp ); 00100 00101 /*Q_SIGNALS: 00102 * 00103 * Emitted when a collision occurs. 00104 * 00105 * @param comp The object this object collided with. 00106 */ 00107 // void collides(SphereCollisionComponent* comp); 00108 00109 private: 00110 class SphereCollisionComponentPrivate; 00111 SphereCollisionComponentPrivate* const d; 00112 }; 00113 00114 } 00115 00116 Q_DECLARE_METATYPE( GluonEngine::SphereCollisionComponent ) 00117 Q_DECLARE_METATYPE( GluonEngine::SphereCollisionComponent* ) 00118 00119 #endif // GLUONENGINE_SPHERECOLLISIONCOMPONENT_H