source: trunk/orbital/particlesystem.h @ 1333

Last change on this file since 1333 was 1333, checked in by sam, 9 years ago

orbital: put the tanks in a separate class.

  • Property svn:keywords set to Id
File size: 1.8 KB
RevLine 
[1286]1//
2// Orbital
3//
4// Copyright: (c) 2012 Various People
5//
6
7/* FIXME: this file is pure crap; it's only a test. */
8
9#if !defined __PARTICLESYSTEM_H__
10#define __PARTICLESYSTEM_H__
11
12class ParticleSystem : public WorldEntity
13{
14public:
15    ParticleSystem()
16      : m_angle(0.f),
17        m_ready(false)
18    {
[1287]19        m_mesh.SendCommand("sc.8,.8,.8,1,acg8,2,5,5,1.5,1.5,.1,0,rx15");
[1296]20        m_mesh.SendCommand("t0,-100,-30,fl");
[1286]21
22        for (int i = 0; i < 200; i++)
[1326]23            m_particles.Push(vec3(0), vec3(0), RandF(0.f, 2.f));
[1286]24    }
25
26    ~ParticleSystem()
27    {
28    }
29
[1333]30    char const *GetName() { return "<particlesystem>"; }
[1286]31
32protected:
[1310]33    virtual void TickGame(float seconds)
[1286]34    {
[1310]35        WorldEntity::TickGame(seconds);
[1286]36
37        for (int i = 0; i < m_particles.Count(); i++)
38        {
[1310]39            m_particles[i].m3 += seconds;
40            if (m_particles[i].m3 > 2.f)
[1286]41            {
42                m_particles[i].m1 = vec3(RandF(-1.f, 1.f), RandF(-1.f, 1.f), RandF(-1.f, 1.f));
43                m_particles[i].m2 = normalize(vec3(RandF(-1.f, 1.f), RandF(-1.f, 1.f), RandF(-1.f, 1.f)));
[1310]44                m_particles[i].m3 = RandF(0.f, 2.f);
[1286]45            }
46
[1310]47            m_particles[i].m1 += seconds * 100.f * m_particles[i].m2;
[1286]48        }
49
[1310]50        m_angle += seconds * 100.f;
[1286]51    }
52
[1310]53    virtual void TickDraw(float seconds)
[1286]54    {
[1310]55        WorldEntity::TickDraw(seconds);
[1286]56
57        if (!m_ready)
58        {
59            m_mesh.SendCommand("irb");
60            m_ready = true;
61        }
62
63        for (int i = 0; i < m_particles.Count(); i++)
64        {
[1332]65            mat4 model = mat4::translate(vec3(0, 0, -100))
66                       * mat4::translate(m_particles[i].m1);;
[1286]67
[1332]68            m_mesh.Render(model);
[1286]69        }
70    }
71
72private:
73    Mesh m_mesh;
74    Array<vec3, vec3, float> m_particles;
75    float m_angle;
76    bool m_ready;
77};
78
79#endif /* __PARTICLESYSTEM_H__ */
80
Note: See TracBrowser for help on using the repository browser.