source: trunk/orbital/tank.h @ 1335

Last change on this file since 1335 was 1335, checked in by sam, 11 years ago

core: make WorldEntity rotation a quaternion.

File size: 1.3 KB
Line 
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 __TANK_H__
10#define __TANK_H__
11
12class Tank : public WorldEntity
13{
14public:
15    Tank()
16      : m_angle(0.f),
17        m_ready(false)
18    {
19        m_body.SendCommand("sc0.1,0.1,0,1,ab6,6,15,ty-2,sc1,1,1,1,afcb4,5,16,0.4,tx4,mx,fl,sc0.2,0.7,0,1,afcb8,7,10,0.4,tz-4,fl");
20        m_head.SendCommand("sc0.2,0.7,0,1,afcb3,6,10,0.4,tx-8,afcb3,6,10,0.4,tx4,ty10,fl,sc1,1,1,1,afcb3,6,10,0.4,rx-30,ty10,fl");
21    }
22
23    ~Tank()
24    {
25    }
26
27    char const *GetName() { return "<tank>"; }
28
29protected:
30    virtual void TickGame(float seconds)
31    {
32        WorldEntity::TickGame(seconds);
33
34        m_rotation *= quat::rotate(seconds * 20.f, vec3(0, 1, 0));
35        m_angle += seconds * 50.f;
36    }
37
38    virtual void TickDraw(float seconds)
39    {
40        WorldEntity::TickDraw(seconds);
41
42        if (!m_ready)
43        {
44            m_body.SendCommand("irb");
45            m_head.SendCommand("irb");
46            m_ready = true;
47        }
48
49        mat4 model = mat4::translate(m_position) * mat4(m_rotation);
50        m_body.Render(model);
51
52        model = model * mat4::rotate(m_angle, vec3(0, 1, 0));
53        m_head.Render(model);
54    }
55
56private:
57    Mesh m_body, m_head;
58    float m_angle;
59    bool m_ready;
60};
61
62#endif /* __TANK_H__ */
63
Note: See TracBrowser for help on using the repository browser.