source: trunk/orbital/orbital.cpp @ 1283

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

orbital: minor tuning to the default test scene.

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
28Orbital::Orbital()
29{
30    m.SendCommand("sc1,1,0,1,asph20,16,20,24");
31    m.SendCommand("t0,0,-30,fl");
32
33    m.SendCommand("sc1,0,1,1,afcb10,10,10,2,rx45,rz45");
34    m.SendCommand("t-20,-20,0,fl");
35
36    m.SendCommand("sc0,0,0.3,1,afcb30,30,30,5,ry45,rx45,afcb30,30,30,5");
37    m.SendCommand("t40,40,0,fl");
38
39    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");
40
41    m.SendCommand("scb1,.5,.5,1,acg11,8,12,18,2,2,0,0");
42    m.SendCommand("t-40,0,30,fl");
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    m.Render(m_modelview, m_proj, m_normalmat);
80}
81
82Orbital::~Orbital()
83{
84    ;
85}
86
87int main(int argc, char **argv)
88{
89    Application app("Orbital", ivec2(800, 600), 60.0f);
90
91#if defined _MSC_VER && !defined _XBOX
92    _chdir("..");
93#elif defined _WIN32 && !defined _XBOX
94    _chdir("../..");
95#endif
96
97    new DebugFps(5, 5);
98    new Orbital();
99    app.ShowPointer(false);
100
101    app.Run();
102
103    return EXIT_SUCCESS;
104}
105
Note: See TracBrowser for help on using the repository browser.