source: trunk/orbital/orbital.cpp @ 1275

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

orbital: port the current shader to HLSL (together with its bugs for now).

File size: 2.0 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");
40
41    m_angle = 0;
42
43    m_ready = false;
44}
45
46void Orbital::TickGame(float deltams)
47{
48    WorldEntity::TickGame(deltams);
49
50    m_angle += deltams / 1000.0f * 90.0f;
51
52    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0))
53              * mat4::rotate(m_angle * 0.25f, vec3(0, 0, 1));
54    mat4 model = mat4::translate(vec3(0, 0, -4.5))
55               * mat4::scale(vec3(0.025));
56    mat4 view = mat4::lookat(vec3(0, 2, 0), vec3(0, 0, -4), vec3(0, 1, 0));
57    mat4 proj = mat4::perspective(45.0f, 640.0f, 480.0f, 0.1f, 10.0f);
58
59    m_modelview = view * model * anim;
60    m_proj = proj;
61    m_normalmat = transpose(inverse(mat3(m_modelview)));
62}
63
64void Orbital::TickDraw(float deltams)
65{
66    WorldEntity::TickDraw(deltams);
67
68    if (!m_ready)
69    {
70        m.SendCommand("irb");
71
72        /* FIXME: this object never cleans up */
73        m_ready = true;
74    }
75
76    m.Render(m_modelview, m_proj, m_normalmat);
77}
78
79Orbital::~Orbital()
80{
81    ;
82}
83
84int main(int argc, char **argv)
85{
86    Application app("Orbital", ivec2(800, 600), 60.0f);
87
88#if defined _MSC_VER && !defined _XBOX
89    _chdir("..");
90#elif defined _WIN32 && !defined _XBOX
91    _chdir("../..");
92#endif
93
94    new DebugFps(5, 5);
95    new Orbital();
96    app.ShowPointer(false);
97
98    app.Run();
99
100    return EXIT_SUCCESS;
101}
102
Note: See TracBrowser for help on using the repository browser.