1 #pragma once
2 // Description:
3 //   Particle type base.
4 //
5 // Copyright (C) 2008 Frank Becker
6 //
7 // This program is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU General Public License as published by the Free Software
9 // Foundation;  either version 2 of the License,  or (at your option) any  later
10 // version.
11 //
12 // This program is distributed in the hope that it will be useful,  but  WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
15 //
16 
17 #include <string>
18 
19 #include <Point.hpp>
20 #include <ParticleInfo.hpp>
21 
22 class ParticleType
23 {
24 public:
25     ParticleType( const std::string &name, bool manage = true);
26     virtual ~ParticleType();
27 
28     virtual void init( ParticleInfo *p) = 0;
29     virtual bool update( ParticleInfo *p) = 0;
30     virtual void draw( ParticleInfo *p) = 0;
31 
hit(ParticleInfo * p,int,int radIndex=0)32     virtual void hit( ParticleInfo *p, int /*damage*/, int radIndex=0) { p->tod = 0; radIndex=0;}
hit(ParticleInfo * p,ParticleInfo * p2,int radIndex=0)33     virtual void hit( ParticleInfo *p, ParticleInfo *p2, int radIndex=0) { hit( p, p2->damage, radIndex);}
34 
getRadiiCount(void)35     virtual int getRadiiCount(void) { return 1;}
getRadius(int)36     virtual float getRadius(int /*radIndex*/) { return 0.0f;}
getOffset(int)37     virtual vec3 getOffset(int /*radIndex*/) { vec3 dummy(0,0,0); return dummy;}
38 
name(void)39     const std::string& name( void){ return _name;}
40 
41 protected:
42     void updatePrevs( ParticleInfo *p);
43     void interpolate( ParticleInfo *p, ParticleInfo &pi);
44     void interpolateOther( ParticleInfo *p, ParticleInfo &pi);
45 
46 private:
47     void interpolateImpl( ParticleInfo *p, ParticleInfo &pi, const float &gf);
48     const std::string _name;
49 };
50