Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

gldynamic.h

00001 /***************************************************************************
00002                           gldynamic.h  -  description
00003                              -------------------
00004     begin                : Thu Aug 21 2003
00005     copyright            : (C) 2003 by Jacques Gasselin de Richebourg
00006     email                : jacquesgasselin@hotmail.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU Lesser General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef GLDYNAMIC_H
00019 #define GLDYNAMIC_H
00020 
00021 #include "glvector.h"
00022 #include "glgeometricobject.h"
00023 
00027 namespace GLScene
00028 {
00029    
00030    class GLVectorFunctor
00031    {
00032    public:
00033       virtual GLVector operator ()(GLfloat time) = 0;
00034    };
00035 
00036    class GravityAccelerator: public GLVectorFunctor
00037    {
00038    public:
00039       GLVector operator ()( GLfloat time )
00040       {
00041          return (GLVector(0,-9.81,0) * time);
00042       }
00043    };
00044         
00045    class GLDynamicObject : public GLGeometricObject
00046    {
00047    protected:
00048       GLVector velocity;
00049       GLVector impactImpulses; //update every move
00050       GLfloat mass;
00051       GLVectorFunctor* acceleration;
00052    public: 
00053     GLDynamicObject( GLVector vel, GLfloat m );
00054       virtual ~GLDynamicObject();
00055 
00056       inline void setAcceleration( GLVectorFunctor* vecFunc )
00057       { acceleration = vecFunc; }
00058 
00059       virtual void collision(GLGeometricObject* obj);
00060       virtual void staticCollision(GLGeometricObject* obj) = 0;
00061       virtual void dynamicCollision(GLDynamicObject* obj) = 0;
00062       
00063       virtual void applyAcceleration( GLfloat time );
00064 
00065       virtual void move( GLfloat time );
00066    };
00067 };
00068 
00069 #endif

Generated on Wed Feb 4 23:11:33 2004 by doxygen 1.3.3