File: ParticleType.hpp

package info (click to toggle)
criticalmass 1%3A1.0.0-6
  • links: PTS
  • area: main
  • in suites: buster
  • size: 17,180 kB
  • ctags: 10,844
  • sloc: ansic: 47,628; cpp: 25,173; sh: 11,803; xml: 3,532; perl: 3,271; makefile: 610; python: 66; awk: 40; lisp: 33
file content (50 lines) | stat: -rw-r--r-- 1,701 bytes parent folder | download | duplicates (10)
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
// Description:
//   Particle type base.
//
// Copyright (C) 2001 Frank Becker
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation;  either version 2 of the License,  or (at your option) any  later
// version.
//
// This program is distributed in the hope that it will be useful,  but  WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
//
#ifndef _ParticleType_hpp_
#define _ParticleType_hpp_

#include <string>
#include <ParticleInfo.hpp>

class ParticleType
{
public:
    ParticleType( const std::string &name, bool manage = true);
    virtual ~ParticleType();

    virtual void init( ParticleInfo *p) = 0;
    virtual bool update( ParticleInfo *p) = 0;
    virtual void draw( ParticleInfo *p) = 0;

    virtual void hit( ParticleInfo *p, int /*damage*/, int radIndex=0) { p->tod = 0; radIndex=0;}
    virtual void hit( ParticleInfo *p, ParticleInfo *p2, int radIndex=0) { hit( p, p2->damage, radIndex);}

    virtual int getRadiiCount(void) { return 1;}
    virtual float getRadius(int /*radIndex*/) { return 0.0f;}
    virtual vec3 getOffset(int /*radIndex*/) { vec3 dummy(0,0,0); return dummy;}

    const std::string& name( void){ return _name;}

protected:
    void updatePrevs( ParticleInfo *p);
    void interpolate( ParticleInfo *p, ParticleInfo &pi);
    void interpolateOther( ParticleInfo *p, ParticleInfo &pi);

private:
    void interpolateImpl( ParticleInfo *p, ParticleInfo &pi, const float &gf);
    const std::string _name;
};

#endif