source: trunk/orbital/orbital.cpp @ 1287

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

orbital: minor useless tweaks.

File size: 2.1 KB
Line 
1//
2// Orbital
3//
4// Copyright: (c) 2012 Various People
5//
6
7#if defined HAVE_CONFIG_H
8#   include "config.h"
9#endif
10
11#if defined _WIN32
12#   include <direct.h>
13#endif
14
15#if USE_SDL && defined __APPLE__
16#   include <SDL_main.h>
17#endif
18
19#include "core.h"
20#include "loldebug.h"
21
22using namespace std;
23using namespace lol;
24
25#include "orbital.h"
26#include "mesh.h"
27#include "particlesystem.h"
28
29Orbital::Orbital()
30{
31    m.SendCommand("sc1,1,0,1,asph20,16,20,24");
32    m.SendCommand("t0,0,-30,fl");
33
34    m.SendCommand("sc1,0,1,1,afcb10,10,10,2,rx45,rz45");
35    m.SendCommand("t-20,-20,0,fl");
36
37    m.SendCommand("sc0,0,0.3,1,afcb30,30,30,5,ry45,rx45,afcb30,30,30,5");
38    m.SendCommand("t40,40,0,fl");
39
40    m.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");
41
42    new ParticleSystem();
43
44    m_angle = 0;
45
46    m_ready = false;
47}
48
49void Orbital::TickGame(float deltams)
50{
51    WorldEntity::TickGame(deltams);
52
53    m_angle += deltams / 1000.0f * 90.0f;
54
55    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0))
56              * mat4::rotate(m_angle * 0.25f, vec3(0, 0, 1));
57    mat4 model = mat4::translate(vec3(0, 0, -4.5))
58               * mat4::scale(vec3(0.025));
59    mat4 view = mat4::lookat(vec3(0, 2, 0), vec3(0, 0, -4), vec3(0, 1, 0));
60    mat4 proj = mat4::perspective(45.0f, 640.0f, 480.0f, 0.1f, 10.0f);
61
62    m_modelview = view * model * anim;
63    m_proj = proj;
64    m_normalmat = transpose(inverse(mat3(m_modelview)));
65}
66
67void Orbital::TickDraw(float deltams)
68{
69    WorldEntity::TickDraw(deltams);
70
71    if (!m_ready)
72    {
73        m.SendCommand("irb");
74
75        /* FIXME: this object never cleans up */
76        m_ready = true;
77    }
78
79    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
80
81    m.Render(m_modelview, m_proj, m_normalmat);
82}
83
84Orbital::~Orbital()
85{
86    ;
87}
88
89int main(int argc, char **argv)
90{
91    Application app("Orbital", ivec2(800, 600), 60.0f);
92
93#if defined _MSC_VER && !defined _XBOX
94    _chdir("..");
95#elif defined _WIN32 && !defined _XBOX
96    _chdir("../..");
97#endif
98
99    new DebugFps(5, 5);
100    new Orbital();
101    app.ShowPointer(false);
102
103    app.Run();
104
105    return EXIT_SUCCESS;
106}
107
Note: See TracBrowser for help on using the repository browser.