Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

party version

  • Loading branch information...
commit e9905df192bd792b5a8f0a50d5394f317678aa13 1 parent 2cf89c7
Erik Faye-Lund authored
5 very_last_engine_ever.sln
... ... @@ -1,18 +1,21 @@
1 1 
2 2 Microsoft Visual Studio Solution File, Format Version 9.00
3   -# Visual Studio 2005
  3 +# Visual C++ Express 2005
4 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "very_last_engine_ever", "very_last_engine_ever\very_last_engine_ever.vcproj", "{CD862F66-C73B-4E6B-87DE-FB5519A91A5D}"
5 5 EndProject
6 6 Global
7 7 GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 8 Debug|Win32 = Debug|Win32
9 9 Release|Win32 = Release|Win32
  10 + Sync|Win32 = Sync|Win32
10 11 EndGlobalSection
11 12 GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 13 {CD862F66-C73B-4E6B-87DE-FB5519A91A5D}.Debug|Win32.ActiveCfg = Debug|Win32
13 14 {CD862F66-C73B-4E6B-87DE-FB5519A91A5D}.Debug|Win32.Build.0 = Debug|Win32
14 15 {CD862F66-C73B-4E6B-87DE-FB5519A91A5D}.Release|Win32.ActiveCfg = Release|Win32
15 16 {CD862F66-C73B-4E6B-87DE-FB5519A91A5D}.Release|Win32.Build.0 = Release|Win32
  17 + {CD862F66-C73B-4E6B-87DE-FB5519A91A5D}.Sync|Win32.ActiveCfg = Sync|Win32
  18 + {CD862F66-C73B-4E6B-87DE-FB5519A91A5D}.Sync|Win32.Build.0 = Sync|Win32
16 19 EndGlobalSection
17 20 GlobalSection(SolutionProperties) = preSolution
18 21 HideSolutionNode = FALSE
4 very_last_engine_ever/data/blur.fx
@@ -7,6 +7,7 @@ float4x4 texcoord_transform;
7 7 float2x2 texture_transform;
8 8 float3x3 texel_transform;
9 9 float brightness = 1.0 / ITERATIONS;
  10 +float2 texcoord_translate = float2(0.5, 0.5);
10 11
11 12 texture tex;
12 13 sampler tex_sampler = sampler_state
@@ -41,8 +42,7 @@ float4 pixel(VS_OUTPUT In) : COLOR
41 42 float2 tex = float2(In.tex);
42 43 for (int i = 0; i < ITERATIONS; i++)
43 44 {
44   -// color += tex2D(tex_sampler, mul(tex, texture_transform));
45   - color += tex2D(tex_sampler, float2(tex.x * 0.5 + 0.5f, -tex.y * 0.5 + 0.5f));
  45 + color += tex2D(tex_sampler, float2(tex.x * 0.5, -tex.y * 0.5) + texcoord_translate);
46 46 tex = mul(float3(tex, 1.0), texel_transform);
47 47 }
48 48 return color * brightness;
BIN  very_last_engine_ever/data/logo.png
4 very_last_engine_ever/data/particle.fx
@@ -11,6 +11,7 @@ float4x4 tex_transform;
11 11
12 12 float3 up;
13 13 float3 left;
  14 +float3 fog_color = float3(1, 1, 1);
14 15
15 16
16 17 float4x4 WorldViewProjection : WORLDVIEWPROJECTION;
@@ -64,9 +65,8 @@ VS_OUTPUT vertex(VS_INPUT In)
64 65 float4 pixel(VS_OUTPUT In) : COLOR
65 66 {
66 67 float fog_factor = In.z;
67   - float4 fog_color = float4(1, 1, 1, 1);
68 68 float4 col = tex2D(tex_samp, In.tex);
69   - return float4(lerp(col.xyz, fog_color.xyz, fog_factor), col.a);
  69 + return float4(lerp(col.xyz, fog_color, fog_factor), col.a);
70 70 // return tex2D(tex_samp, In.tex);
71 71 // return float4(In.tex, 0, 0);
72 72 }
BIN  very_last_engine_ever/data/rider_igjen-04.mp3
Binary file not shown
BIN  very_last_engine_ever/data/rider_igjen-05.mp3
Binary file not shown
BIN  very_last_engine_ever/data/stpeters_cross3.dds
Binary file not shown
160,650 very_last_engine_ever/data/test.x
0 additions, 160,650 deletions not shown
11 very_last_engine_ever/data/tunelle.fx
@@ -9,6 +9,8 @@ float4x4 View : VIEW;
9 9
10 10 float fade = 1.0;
11 11 float overbright = 1.0;
  12 +float3 fog_color = float3(1, 1, 1);
  13 +
12 14
13 15 // textures
14 16 texture map;
@@ -70,13 +72,12 @@ float4 pixel(VS_OUTPUT In) : COLOR
70 72 // float3 ref_vec = reflect(N, L);
71 73 float3 ref_vec = reflect(L, N);
72 74
73   - color = max(dot(-N, L), 0);
74   - color += texCUBE(env_samp, ref_vec) * pow(1 - max(dot(-N, L), 0), 1);
  75 +// color = max(dot(-N, L), 0);
  76 + color = 1; // texCUBE(env_samp, ref_vec);
75 77 color *= tex2D(tex_samp, In.tex);
76   - color *= 0.25;
  78 + color *= 0.5;
77 79
78   - float4 fog_color = float4(1, 1, 1, 1);
79   - return float4(lerp(color.xyz, fog_color.xyz, In.fog_factor), color.a);
  80 + return float4(lerp(color.xyz, fog_color, In.fog_factor), color.a);
80 81
81 82 return color * overbright;
82 83 }
9 very_last_engine_ever/engine/particlestreamer.h
@@ -95,13 +95,7 @@ namespace engine
95 95 *locked_pointer++ = pos.z;
96 96 *locked_pointer++ = size;
97 97 }
98   -
99   - if (--locked_particles == 0)
100   - {
101   - end();
102   - draw();
103   - begin();
104   - }
  98 + locked_particles--;
105 99 }
106 100
107 101 void end()
@@ -112,6 +106,7 @@ namespace engine
112 106
113 107 void draw()
114 108 {
  109 +
115 110 int max_vertex = PARTICLE_STREAMER_VERTEX_COUNT - (locked_particles * 4);
116 111 int primitive_count = 2 * (PARTICLE_STREAMER_PARTICLE_COUNT - locked_particles);
117 112
4 very_last_engine_ever/main.cpp
@@ -55,7 +55,7 @@ int main(int /*argc*/, char* /*argv*/ [])
55 55 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
56 56 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
57 57 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
58   -// _CrtSetBreakAlloc(68);
  58 +// _CrtSetBreakAlloc(68)
59 59 #endif
60 60
61 61 _Module.Init(NULL, GetModuleHandle(0));
@@ -92,7 +92,7 @@ int main(int /*argc*/, char* /*argv*/ [])
92 92
93 93 #ifndef VJSYS
94 94 if (!BASS_Init(config.get_soundcard(), 44100, BASS_DEVICE_LATENCY, 0, 0)) throw FatalException("failed to init bass");
95   - stream = BASS_StreamCreateFile(false, "data/rider_igjen-04.mp3", 0, 0, BASS_MP3_SETPOS | ((0 == config.get_soundcard()) ? BASS_STREAM_DECODE : 0));
  95 + stream = BASS_StreamCreateFile(false, "data/rider_igjen-06.mp3", 0, 0, BASS_MP3_SETPOS | ((0 == config.get_soundcard()) ? BASS_STREAM_DECODE : 0));
96 96 if (!stream) throw FatalException("failed to open tune");
97 97 #else
98 98 BASS_RecordInit(config.get_soundcard());
548 very_last_engine_ever/megademo.h
@@ -2,6 +2,7 @@
2 2 #define MEGADEMO_H
3 3
4 4 #define END_TIME (60 * 3 + 30) /* 3:30 */
  5 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
5 6
6 7 #include "renderer/texture.h"
7 8 #include "renderer/rendertexture.h"
@@ -9,6 +10,7 @@
9 10 #include "engine/demo.h"
10 11 #include "engine/image.h"
11 12 #include "engine/particlestreamer.h"
  13 +#include "engine/particlecloud.h"
12 14 #include "math/vector3.h"
13 15 #include "math/vector2.h"
14 16 #include "math/matrix4x4.h"
@@ -24,17 +26,78 @@ using math::Matrix4x4;
24 26
25 27 namespace engine
26 28 {
27   - Texture load_texture(renderer::Device &device, std::string filename)
  29 + Texture load_texture(renderer::Device &device, ::std::string filename)
28 30 {
29 31 Texture tex;
30 32
31 33 HRESULT hr = D3DXCreateTextureFromFile(device, filename.c_str(), &tex);
32   - if (FAILED(hr)) throw core::FatalException(std::string("failed to load mesh \"") + filename + std::string("\"\n\n") + core::d3d_get_error(hr));
  34 + if (FAILED(hr)) throw core::FatalException(::std::string("failed to load mesh \"") + filename + ::std::string("\"\n\n") + core::d3d_get_error(hr));
33 35
34 36 return tex;
35 37 }
36 38 }
37 39
  40 +class Video
  41 +{
  42 +public:
  43 + Texture &get_tex(float pos)
  44 + {
  45 + assert(0 != textures.size());
  46 + int idx = pos * textures.size();
  47 + idx %= textures.size();
  48 + return textures[idx];
  49 + }
  50 +
  51 + /**
  52 +
  53 + 0 0
  54 + 1 1
  55 + 2 2
  56 + 3 3
  57 + 4 4
  58 + 3 5
  59 + 2 6
  60 + 1 7
  61 + 0 8
  62 + 1 9
  63 + 2 10
  64 +
  65 + */
  66 +
  67 + Texture &get_tex_pingpong(float pos)
  68 + {
  69 + assert(0 != textures.size());
  70 + int idx = pos * textures.size();
  71 + idx %= (textures.size() * 2) - 2;
  72 + if (idx >= textures.size()) idx = textures.size() - 1 - (idx - textures.size());
  73 + assert(idx >= 0);
  74 + assert(idx < textures.size());
  75 + return textures[idx];
  76 + }
  77 +
  78 + std::vector<Texture> textures;
  79 +};
  80 +
  81 +Video load_video(Device &device, std::string folder)
  82 +{
  83 + Video vid;
  84 + for (int i = 0; true; ++i)
  85 + {
  86 + char temp[256];
  87 + sprintf(temp, "%s/%04d.jpg", folder.c_str(), i);
  88 + Texture tex;
  89 + if (FAILED(D3DXCreateTextureFromFile(device, temp, &tex))) break;
  90 + vid.textures.push_back(tex);
  91 + }
  92 +
  93 + if (0 == vid.textures.size())
  94 + {
  95 + throw FatalException("no frames in video");
  96 + }
  97 +
  98 + return vid;
  99 +}
  100 +
38 101 void set_ramp(float alphas[], float base)
39 102 {
40 103 for (unsigned i = 0; i < 8; i++)
@@ -53,87 +116,26 @@ void blit(IDirect3DDevice9 *device, IDirect3DTexture9 *tex, Effect &eff, Mesh &p
53 116 eff.draw(polygon);
54 117 }
55 118
56   -template <typename T>
57   -void insertion_sort(T* a, size_t len)
  119 +bool blink_inout(float time, float startblink, float endblink, float blinklen)
58 120 {
59   - for (int j = 2; j < len; j++)
60   - {
61   - for (int k = 0; k < j; k++)
62   - {
63   - if (a[j] < a[k])
64   - {
65   - temp = a[k];
66   - a[k] = a[j];
67   - a[j] = temp;
68   - }
69   - }
70   - }
  121 + return ((time > (startblink + blinklen) && time < (endblink - blinklen)) || ((time > startblink && time < endblink) && (int(time) & 1)));
71 122 }
72 123
73   -#if 0
74   -typedef D3DXVECTOR2 Vector2;
75   -/* typedef D3DXVECTOR3 Vector3; */
76   -typedef D3DXVECTOR4 Vector4;
77   -#endif
78   -
79   -class Particle
80   -{
81   -public:
82   - Particle(const Vector3 &pos, const float size) : pos(pos), size(size) {}
83   -
84   - Vector3 pos;
85   - float size;
86   -};
87   -
88   -
89   -#include <list>
90   -
91   -class ParticleCompare
92   -{
93   -public:
94   - ParticleCompare(const Vector3 &dir) : dir(dir) {}
95   -
96   - bool operator()(const Particle &a, const Particle &b)
97   - {
98   - float za = dir.x * a.pos.x + dir.y * a.pos.y + dir.z * a.pos.z;
99   - float zb = dir.x * b.pos.x + dir.y * b.pos.y + dir.z * b.pos.z;
100   - if (fabs(za - zb) > 1e-5) return za > zb;
101   - else return false;
102   - }
103   -
104   - const Vector3 &dir;
105   -};
106   -
107   -#include <algorithm>
108   -
109   -class ParticleCloud
110   -{
111   -public:
112   - ParticleCloud() : streamer(NULL) {}
113   - ParticleCloud(engine::ParticleStreamer *streamer) : streamer(streamer) {}
114   -
115   - void sort(const Vector3 &dir)
116   - {
117   - particles.sort(ParticleCompare(dir));
118   - }
119   -
120   - std::list<Particle> particles;
121   - engine::ParticleStreamer *streamer;
122   -};
123   -
124 124 Matrix4x4 texture_matrix(const Texture &tex)
125 125 {
126 126 Matrix4x4 mat, trans1, trans2, scale;
127   - D3DXMatrixIdentity(&trans1);
128   - trans1._31 = 0.5 / tex.get_surface().get_desc().Width;
129   - trans1._32 = 0.5 / tex.get_surface().get_desc().Height;
  127 +
  128 + // D3DXMatrixIdentity(&trans2);
  129 +// trans1._31 = 0.5;
  130 +// trans1._32 = 0.5;
130 131
131 132 D3DXMatrixIdentity(&trans2);
132   - trans1._31 = 0.5;
133   - trans1._32 = 0.5;
  133 + trans2._31 = -10.5 / tex.get_surface().get_desc().Width;
  134 + trans2._32 = -10.5 / tex.get_surface().get_desc().Height;
134 135
135 136 D3DXMatrixScaling(&scale, 0.5, 0.5, 1.0);
136   - mat = scale * trans2;
  137 + return trans2;
  138 +// mat = trans2 * scale;
137 139
138 140 // mat = trans1 * scale;
139 141 return mat;
@@ -143,7 +145,7 @@ Matrix4x4 radialblur_matrix(const Texture &tex, const Vector2 &center, const flo
143 145 {
144 146 Matrix4x4 mat;
145 147 mat.make_scaling(Vector3(amt, amt, 1.0));
146   -#if 1
  148 +#if 0
147 149 mat._31 = 0.005;
148 150 mat._32 = 0.005;
149 151 #endif
@@ -160,16 +162,38 @@ class MegaDemo : public engine::Demo
160 162
161 163 Mesh tunelle_mesh;
162 164 Texture tunelle_tex;
  165 + Effect tunelle_fx;
  166 +
  167 + Mesh kuber_mesh;
  168 + Texture kuber_tex;
  169 + Effect kuber_fx;
163 170
164 171 Effect test_fx;
165 172 Effect blur_fx;
166 173 Effect tex_fx;
167   - Effect tunelle_fx;
168 174 Effect particle_fx;
169 175
170 176 Texture logo_tex;
171 177 Image logo;
172 178
  179 + Texture analog_tex;
  180 + Image analog;
  181 +
  182 + Texture ramme_tex;
  183 + Image ramme;
  184 +
  185 + Texture end_tex;
  186 + Image end;
  187 +
  188 + Texture end2_tex;
  189 + Image end2;
  190 +
  191 + Texture greets_tex;
  192 + Image greets;
  193 +
  194 + Texture fucks_tex;
  195 + Image fucks;
  196 +
173 197 RenderTexture blurme1_tex;
174 198 Image blurme1;
175 199
@@ -177,6 +201,7 @@ class MegaDemo : public engine::Demo
177 201 Image blurme2;
178 202
179 203 Texture bartikkel_tex;
  204 + CComPtr<IDirect3DCubeTexture9> env;
180 205
181 206 // engine::TextureProxy texloader;
182 207
@@ -187,13 +212,21 @@ class MegaDemo : public engine::Demo
187 212 Sync &sync;
188 213 SyncTrack &fade, &flash, &part;
189 214 SyncTrack &xrot, &yrot, &zrot;
  215 + SyncTrack &zrot2, &scrolly;
190 216 SyncTrack &cam_seed, &cam_rand;
191 217 SyncTrack &cam_x, &cam_y, &cam_z;
  218 + SyncTrack &at_x, &at_y, &at_z;
192 219 SyncTrack &cam_fov;
193 220 SyncTrack &blur_amt;
  221 + SyncTrack &clear_color_param;
  222 + SyncTrack &morph;
  223 + SyncTrack &vid_track;
  224 + SyncTrack &vid_flip;
  225 +
  226 + std::vector<Video> vids;
194 227
195 228 engine::ParticleStreamer streamer;
196   - ParticleCloud cloud;
  229 + engine::ParticleCloud<float> cloud;
197 230
198 231 public:
199 232 MegaDemo(renderer::Device &device, renderer::Surface &backbuffer, float aspect, Sync &sync) :
@@ -207,13 +240,23 @@ class MegaDemo : public engine::Demo
207 240 xrot( sync.getTrack("x", "rotation", 5, true)),
208 241 yrot( sync.getTrack("y", "rotation", 5, true)),
209 242 zrot( sync.getTrack("z", "rotation", 5, true)),
  243 + zrot2( sync.getTrack("z2", "rotation", 5, true)),
  244 + scrolly( sync.getTrack("scrolly", "rotation", 5, true)),
  245 +
  246 + vid_track( sync.getTrack("track", "vid", 5, true)),
  247 + vid_flip( sync.getTrack("flip", "vid", 5, true)),
210 248
211 249 cam_x( sync.getTrack("x", "cam", 5, true)),
212 250 cam_y( sync.getTrack("y", "cam", 5, true)),
213 251 cam_z( sync.getTrack("z", "cam", 5, true)),
214 252 cam_fov( sync.getTrack("fov", "cam", 5, true)),
215 253 cam_seed( sync.getTrack("seed", "cam", 5, true)),
216   - cam_rand( sync.getTrack("rand", "cam", 5, true))
  254 + cam_rand( sync.getTrack("rand", "cam", 5, true)),
  255 + at_x( sync.getTrack("x", "at", 5, true)),
  256 + at_y( sync.getTrack("y", "at", 5, true)),
  257 + at_z( sync.getTrack("z", "at", 5, true)),
  258 + clear_color_param( sync.getTrack("clear", "global", 5, true)),
  259 + morph( sync.getTrack("morph", "global", 5, true))
217 260 {
218 261 streamer = engine::ParticleStreamer(device);
219 262
@@ -226,33 +269,55 @@ class MegaDemo : public engine::Demo
226 269
227 270 tunelle_mesh = engine::load_mesh(device, "data/tunelle.x");
228 271 tunelle_tex = engine::load_texture(device, "data/tunelle.dds");
  272 + tunelle_fx = engine::load_effect(device, "data/tunelle.fx");
  273 +
  274 + kuber_mesh = engine::load_mesh(device, "data/kuber.x");
  275 + kuber_tex = engine::load_texture(device, "data/kuber.dds");
  276 + kuber_fx = engine::load_effect(device, "data/kuber.fx");
229 277
230 278 test_fx = engine::load_effect(device, "data/test.fx");
231 279 blur_fx = engine::load_effect(device, "data/blur.fx");
232 280 tex_fx = engine::load_effect(device, "data/tex.fx");
233 281 particle_fx = engine::load_effect(device, "data/particle.fx");
234   - tunelle_fx = engine::load_effect(device, "data/tunelle.fx");
235 282
236 283 logo_tex = engine::load_texture(device, "data/logo.png");
237 284 logo = Image(logo_tex, tex_fx, polygon);
  285 +
  286 + analog_tex = engine::load_texture(device, "data/analog.dds");
  287 + analog = Image(analog_tex, tex_fx, polygon);
  288 +
  289 + ramme_tex = engine::load_texture(device, "data/ramme.png");
  290 + ramme = Image(ramme_tex, tex_fx, polygon);
238 291
  292 + end_tex = engine::load_texture(device, "data/end.dds");
  293 + end = Image(end_tex, tex_fx, polygon);
  294 +
  295 + end2_tex = engine::load_texture(device, "data/end2.dds");
  296 + end2 = Image(end2_tex, tex_fx, polygon);
  297 +
  298 + greets_tex = engine::load_texture(device, "data/greets.dds");
  299 + greets = Image(greets_tex, tex_fx, polygon);
  300 +/*
  301 + fucks_tex = engine::load_texture(device, "data/fucks.dds");
  302 + fucks = Image(fucks_tex, tex_fx, polygon);
  303 +*/
239 304 bartikkel_tex = engine::load_texture(device, "data/bartikkel.dds");
240 305
241   - CComPtr<IDirect3DCubeTexture9> env;
242 306 d3d_err(D3DXCreateCubeTextureFromFile(device, "data/stpeters_cross2.dds", &env));
243 307 test_fx->SetTexture("env", env);
244   -
245   - blurme1_tex = RenderTexture(device, backbuffer.get_desc().Width / 2, int(backbuffer.get_desc().Height * aspect * (9 / 16.f)) / 2);
246   - blurme2_tex = RenderTexture(device, backbuffer.get_desc().Width / 2, int(backbuffer.get_desc().Height * aspect * (9 / 16.f)) / 2);
247 308
248   - for (int i = 0; i < 1024 * 16; ++i)
  309 + log::printf("aspect correction: %f\n", aspect * (16.f / 9));
  310 + blurme1_tex = RenderTexture(device, backbuffer.get_desc().Width, int(backbuffer.get_desc().Width / (16.f / 9.f)));
  311 + blurme2_tex = RenderTexture(device, backbuffer.get_desc().Width, int(backbuffer.get_desc().Width / (16.f / 9.f)));
  312 +#if 1
  313 + for (int i = 0; i < 1024 * 8; ++i)
249 314 {
250 315 #if 1
251 316 float x = (randf() - 0.5f) * 200;
252 317 float z = (randf() - 0.5f) * 200;
253 318 float y = (randf() - 0.5f) * 200;
254   - float s = (randf() + 0.5f) * 4.f;
255   -#else
  319 + float s = (randf() + 0.5f) * 3.f;
  320 +#elif 0
256 321 float p = i;
257 322 float rad = 50 + sin(p * 0.0001f) * 10;
258 323 float x = (sin(p * 0.01)) * rad;
@@ -261,17 +326,57 @@ class MegaDemo : public engine::Demo
261 326 float s = 3.f + sin(p * 0.189) * 2;
262 327 s *= 0.5;
263 328 #endif
264   - cloud.particles.insert(cloud.particles.end(), Particle(Vector3(x, y, z), s));
  329 + cloud.particles.insert(cloud.particles.end(), engine::Particle<float>(Vector3(x, y, z), s));
265 330 }
266   - }
  331 +#else
  332 + for (int j = 0; j < 1; ++j)
  333 + {
  334 + float x = (randf() - 0.5f);
  335 + float z = (randf() - 0.5f);
  336 + float y = (randf() - 0.5f);
  337 + Vector3 pos(x, y, z);
  338 + pos.normalize();
  339 +
  340 + Vector3 dir = pos;
  341 +
  342 + const int max = 4096;
  343 + for (int i = 0; i < max; ++i)
  344 + {
  345 +// cloud.particles.insert(cloud.particles.end(), engine::Particle(pos, 1.0 / (1 + (i * 0.05f)) ));
  346 +// float s = min(float(i) / max, float(max - i) / max);
  347 + float s = float(i) / max;
  348 +
  349 + pos = Vector3(cos(s * M_PI * 10), sin(s * M_PI * 8), cos(1 - s * M_PI * 9));
  350 + pos.x += cos(pos.y * 2);
  351 + pos.y += cos(pos.z * 2);
  352 + pos.z += cos(pos.x * 2);
  353 +
  354 + pos *= 3;
  355 +// pos *= sin(s);
  356 +
  357 + s = 1 - cos(s * M_PI * 2);
  358 + s = (1 + cos(s * M_PI * 10) * 0.75) * s;
  359 + s *= 0.35;
267 360
  361 + cloud.particles.insert(cloud.particles.end(), engine::Particle(pos, s));
  362 + pos += dir * 0.05;
  363 + }
  364 + }
  365 +#endif
  366 + vids.push_back(load_video(device, "data/vid1"));
  367 + vids.push_back(load_video(device, "data/vid2"));
  368 + vids.push_back(load_video(device, "data/vid3"));
  369 + vids.push_back(load_video(device, "data/vid4"));
  370 + }
  371 +
268 372 void start()
269 373 {
270 374 /* music.play(); */
271 375 }
272   -
  376 +
273 377 void draw(float time)
274 378 {
  379 + time -= 10.f / (1000000);
275 380 double beat = time * (double(BPM) / 60);
276 381
277 382 #ifdef VJSYS
@@ -286,15 +391,42 @@ class MegaDemo : public engine::Demo
286 391 BASS_ChannelGetData(stream, spectrum, BASS_DATA_FFT512);
287 392 }
288 393
  394 + float spec1_val = spectrum[0];
  395 +
  396 + D3DXCOLOR clear_color;
  397 + clear_color.r = clear_color_param.getFloatValue() * (1.0 / 256);
  398 + clear_color.g = clear_color_param.getFloatValue() * (1.0 / 256);
  399 + clear_color.b = clear_color_param.getFloatValue() * (1.0 / 256);
  400 +/*
  401 + clear_color.r = 0;
  402 + clear_color.g = 0;
  403 + clear_color.b = 0;
  404 +*/
  405 +
  406 + static float last_blink = 0.f;
  407 + float blink = last_blink + (spectrum[0] - last_blink) * 0.1f;
  408 + last_blink = blink;
  409 +
  410 + blink *= 0.05;
  411 +
  412 + clear_color.r += blink;
  413 + clear_color.g += blink;
  414 + clear_color.b += blink;
  415 +
  416 + particle_fx->SetFloatArray("fog_color", clear_color, 3);
  417 +
  418 +
  419 +
289 420 if (true)
290 421 {
291 422 device->SetRenderTarget(0, blurme1_tex.get_surface());
292   - device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0xffffff, 1.f, 0);
  423 + device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, clear_color, 1.f, 0);
293 424
294 425 // setup projection
295 426 D3DXMATRIX proj;
296 427
297 428 D3DXMatrixPerspectiveFovLH(&proj, D3DXToRadian(cam_fov.getFloatValue()), 16.f / 9, 0.01f, 1000.f);
  429 + D3DXMatrixPerspectiveFovLH(&proj, D3DXToRadian(90.0), float(blurme1_tex.get_surface().get_desc().Width) / blurme1_tex.get_surface().get_desc().Height, 0.01f, 1000.f);
298 430 device->SetTransform(D3DTS_PROJECTION, &proj);
299 431
300 432 float rot = time * 0.4f;
@@ -305,14 +437,22 @@ class MegaDemo : public engine::Demo
305 437 // setup camera (animate parameters)
306 438
307 439 srand(0);
308   - D3DXVECTOR3 at(0, 0.f, 10.f);
  440 + Vector3 at(0, 0.f, 0.f);
  441 + at = Vector3(at_x.getFloatValue(), at_y.getFloatValue(), at_z.getFloatValue());
309 442 D3DXVECTOR3 up(0.f, 1.f, 0.f);
310   - D3DXVECTOR3 eye(
  443 + Vector3 eye = Vector3
  444 + (
311 445 cam_x.getFloatValue(), // cam_rand.getFloatValue(),
312 446 cam_y.getFloatValue(), // cam_rand.getFloatValue(),
313 447 cam_z.getFloatValue()
314   - ); // cam_rand.getFloatValue(),
315   -
  448 + ); // cam_rand.getFloatValue(),
  449 +/*
  450 + eye = Vector3(
  451 + sin(time) * 4,
  452 + 0.f,
  453 + cos(time) * 4
  454 + );
  455 +*/
316 456 // setup camera (view matrix)
317 457 D3DXMATRIX view;
318 458 D3DXMatrixLookAtLH(&view, &eye, &at, &up);
@@ -330,86 +470,132 @@ class MegaDemo : public engine::Demo
330 470 device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
331 471 test_fx.draw(mesh2);
332 472 */
333   -
334   - if (beat > (64 + 16))
  473 + if (beat < 256 - 64)
335 474 {
336   - for (int i = 0; i < 10; ++i)
337   - {
338   - Vector3 scale(0.1, 0.1, 0.1);
339   - Vector3 translation(0,0,i * 25);
340   - D3DXQUATERNION rotation;
341   - D3DXQuaternionRotationYawPitchRoll(&rotation, 0, M_PI / 2, 0);
342   - D3DXMatrixTransformation(&world, NULL, NULL, &scale, NULL, &rotation, &translation);
343 475
344   - tunelle_fx.set_matrices(world, view, proj);
345   - tunelle_fx->SetTexture("map", tunelle_tex);
346   - tunelle_fx->SetFloat("overbright", 1.0);
347   - tunelle_fx->CommitChanges();
348   - device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
349   - tunelle_fx.draw(tunelle_mesh);
  476 + if (beat > (64 + 8))
  477 + {
  478 + tunelle_fx->SetFloatArray("fog_color", clear_color, 3);
  479 + for (int i = 0; i < 24; ++i)
  480 + {
  481 + Vector3 scale(0.1, 0.1, 0.1);
  482 + Vector3 translation(0,0,i * 25);
  483 + D3DXQUATERNION rotation;
  484 + D3DXQuaternionRotationYawPitchRoll(&rotation, 0, M_PI / 2, 0);
  485 + D3DXQUATERNION rotation2;
  486 + D3DXQuaternionRotationYawPitchRoll(&rotation2, 0, 0, zrot.getFloatValue());
  487 +
  488 + rotation *= rotation2;
  489 +
  490 + Matrix4x4 world;
  491 + D3DXMatrixTransformation(&world, NULL, NULL, &scale, NULL, &rotation, &translation);
  492 +
  493 + tunelle_fx.set_matrices(world, view, proj);
  494 + tunelle_fx->SetTexture("map", tunelle_tex);
  495 + tunelle_fx->SetFloat("overbright", 1.0);
  496 + tunelle_fx->CommitChanges();
  497 + device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
  498 + tunelle_fx.draw(tunelle_mesh);
  499 + }
350 500 }
351   - }
352 501
353   - world.make_identity();
  502 + if (beat > (64 + 64))
  503 + {
  504 + Vector3 scale(0.05, 0.05, 0.05);
  505 + Vector3 translation(0, 0, scrolly.getFloatValue());
  506 + D3DXQUATERNION rotation;
  507 + D3DXQuaternionRotationYawPitchRoll(&rotation, 0, 0, zrot2.getFloatValue());
354 508
355   - Matrix4x4 modelview = world * view;
356   - cloud.sort(Vector3(modelview._13, modelview._23, modelview._33));
  509 + Matrix4x4 world;
  510 + D3DXMatrixTransformation(&world, NULL, NULL, &scale, NULL, &rotation, &translation);
357 511
358   - particle_fx.set_matrices(world, view, proj);
359   - particle_fx->SetTexture("tex", bartikkel_tex);
  512 + kuber_fx->SetFloatArray("fog_color", clear_color, 3);
  513 + kuber_fx->SetFloat("morph", morph.getFloatValue() * (1.f / 256));
  514 + kuber_fx.set_matrices(world, view, proj);
  515 + kuber_fx->SetTexture("map", kuber_tex);
  516 + kuber_fx->SetTexture("env", env);
  517 + kuber_fx->CommitChanges();
  518 + kuber_fx.draw(kuber_mesh);
  519 + }
360 520
361   - {
362   - Vector3 up(modelview._12, modelview._22, modelview._32);
363   - Vector3 left(modelview._11, modelview._21, modelview._31);
364   - up.normalize();
365   - left.normalize();
366   -
367   - particle_fx->SetFloatArray("up", up, 3);
368   - particle_fx->SetFloatArray("left", left, 3);
369   - particle_fx->CommitChanges();
370   - }
371   - device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
372   - device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
373   - device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
374   - device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
375   - device->SetRenderState(D3DRS_ZWRITEENABLE, false);
  521 + world.make_identity();
376 522
377   - std::list<Particle>::const_iterator iter = cloud.particles.begin();
378   - bool iter_done = false;
  523 + Matrix4x4 modelview = world * view;
  524 + cloud.sort(Vector3(modelview._13, modelview._23, modelview._33));
  525 +
  526 + particle_fx.set_matrices(world, view, proj);
  527 + particle_fx->SetTexture("tex", bartikkel_tex);
  528 +
  529 + {
  530 + Vector3 up(modelview._12, modelview._22, modelview._32);
  531 + Vector3 left(modelview._11, modelview._21, modelview._31);
  532 + up.normalize();
  533 + left.normalize();
  534 +
  535 + particle_fx->SetFloatArray("up", up, 3);
  536 + particle_fx->SetFloatArray("left", left, 3);
  537 + particle_fx->CommitChanges();
  538 + }
379 539
380   - int cnt = 0;
381   - while (!iter_done)
382   - {
383   - streamer.begin();
384   - for (int i = 0; i < 1023; ++i)
  540 + device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
  541 + device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
  542 + device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
  543 + device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
  544 + device->SetRenderState(D3DRS_ZWRITEENABLE, false);
  545 +
  546 + std::list<engine::Particle<float> >::const_iterator iter = cloud.particles.begin();
  547 + bool iter_done = false;
  548 +
  549 + while (!iter_done)
385 550 {
386   - cnt++;
387   - if (cloud.particles.end() == iter)
  551 + streamer.begin();
  552 + for (int i = 0; i < 1024; ++i)
388 553 {
389   - iter_done = true;
390   - break;
  554 + streamer.add(
  555 + Vector3(iter->pos.x,
  556 + iter->pos.y,
  557 + iter->pos.z
  558 + ),
  559 + iter->data // + (1 - fmod(beat, 1.0)) * 2
  560 + );
  561 + ++iter;
  562 +
  563 + if (cloud.particles.end() == iter)
  564 + {
  565 + iter_done = true;
  566 + break;
  567 + }
391 568 }
392   -
393   - streamer.add(
394   - Vector3(iter->pos.x,
395   - iter->pos.y,
396   - iter->pos.z
397   - ),
398   -#if 0
399   - 2.f + sin(cnt * 0.00589)
400   -#else
401   - iter->size + (1 - fmod(beat, 1.0)) * 2
402   -#endif
403   - );
404   - ++iter;
  569 + streamer.end();
  570 + particle_fx.draw(streamer);
405 571 }
406   - streamer.end();
407   - particle_fx.draw(streamer);
  572 +
  573 + device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
  574 + device->SetRenderState(D3DRS_ZWRITEENABLE, true);
408 575 }
  576 + else
  577 + {
  578 + int vid = vid_track.getIntValue() % vids.size();
409 579
410   - device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
411   - device->SetRenderState(D3DRS_ZWRITEENABLE, true);
  580 + float tbeat = beat;
  581 + if (vid == 1) beat *= 2;
412 582
  583 + float x_scale = 1.0f;
  584 + if (vid_flip.getIntValue() & 1) x_scale = -1.0f;
  585 +
  586 + Matrix4x4 tex_transform;
  587 + tex_transform.make_scaling(Vector3(x_scale, 1, 1));
  588 + tex_fx->SetMatrix("tex_transform", &tex_transform);
  589 +
  590 + blit(device, vids[vid].get_tex_pingpong(beat), tex_fx, polygon);
  591 +
  592 + if (beat > (512 + 128 + 32 - 8))
  593 + {
  594 + tex_fx->SetFloat("alpha", 1.0);
  595 + end2.draw(device);
  596 + }
  597 +
  598 + }
413 599
414 600 Matrix4x4 texcoord_transform;
415 601 Matrix4x4 texel_transform;
@@ -418,6 +604,11 @@ class MegaDemo : public engine::Demo
418 604 // float amt = 1.0 - pow((1.0 - fmod(beat / 2, 1.0)) * 0.1, 2.0);
419 605 float amt = 1.0 - pow((blur_amt.getFloatValue()) * 0.1, 2.0);
420 606
  607 + Vector3 texcoord_translate(
  608 + 0.5 + (0.5 / blurme1_tex.get_surface().get_desc().Width),
  609 + 0.5 + (0.5 / blurme1_tex.get_surface().get_desc().Height),
  610 + 0.0);
  611 + blur_fx->SetFloatArray("texcoord_translate", texcoord_translate, 2);
421 612 texcoord_transform.make_scaling(Vector3(1,1,1));
422 613 blur_fx->SetMatrix("texcoord_transform", &texcoord_transform);
423 614 blur_fx->SetMatrix("texture_transform", &texture_transform);
@@ -457,16 +648,53 @@ class MegaDemo : public engine::Demo
457 648 blit(device, blurme2_tex, blur_fx, polygon);
458 649 // blur.draw(device);
459 650
  651 +
460 652 device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
461 653 device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
462 654 device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
463 655 Matrix4x4 tex_transform;
464   - tex_transform.make_scaling(Vector3(pow(1.0 - fmod(beat / 4, 1.0), 8.0) * cos(beat * M_PI * 4) * 0.25 + 1.0, 1, 1));
  656 +// tex_transform.make_scaling(Vector3(pow(1.0 - fmod(beat / 4, 1.0), 8.0) * cos(beat * M_PI * 4) * 0.25 + 1.0, 1, 1));
  657 + tex_transform.make_scaling(Vector3(1.0, 1, 1));
465 658 tex_fx->SetMatrix("tex_transform", &tex_transform);
466   - logo.draw(device);
  659 +
  660 + if (beat > 256 + 64 && (beat < (512 + 128 + 32 - 8)))
  661 + {
  662 + tex_fx->SetFloat("alpha", fade.getFloatValue());
  663 + end.draw(device);
  664 + }
  665 +
  666 + tex_fx->SetFloat("alpha", 1.0f);
  667 + ramme.draw(device);
  668 +
  669 +// if (blink_inout(beat * 8, (64 + 4) * 8, (64 + 4 + 8) * 8, 1 * 8))
  670 + if ((beat > 64) && (beat < (64 + 16)))
  671 + {
  672 + tex_transform.make_scaling(Vector3(1, 1, 1));
  673 + tex_fx->SetMatrix("tex_transform", &tex_transform);
  674 + if (beat < (64 + 8)) tex_fx->SetFloat("alpha", 1.f - clear_color.r);
  675 + else tex_fx->SetFloat("alpha", 1.f - (beat - (64 + 8)) / 8 );
  676 + logo.draw(device);
  677 + }
  678 +
  679 + if (blink_inout(beat * 8, (64 + 18) * 8, (64 + 18 + 8) * 8, 1 * 8))
  680 + {
  681 + tex_transform.make_scaling(Vector3(pow(1.0 - fmod(beat / 4, 1.0), 8.0) * cos(beat * M_PI * 4) * 0.25 + 1.0, 1, 1));
  682 + tex_fx->SetMatrix("tex_transform", &tex_transform);
  683 + tex_fx->SetFloat("alpha", 1.0f);
  684 + analog.draw(device);
  685 + }
  686 +
  687 + if (blink_inout(beat * 8, (256 + 32) * 8, (256 + 64) * 8, 1 * 8))
  688 + {
  689 + tex_transform.make_scaling(Vector3(pow(1.0 - fmod(beat / 4, 1.0), 8.0) * cos(beat * M_PI * 4) * 0.25 + 1.0, 1, 1));
  690 + tex_fx->SetMatrix("tex_transform", &tex_transform);
  691 + tex_fx->SetFloat("alpha", 1.0f);
  692 + greets.draw(device);
  693 + }
  694 +
467 695 device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
468 696 #endif
469   -
  697 +
470 698 if (time > END_TIME) done = true;
471 699 }
472 700 };
2  very_last_engine_ever/very_last_engine_ever.vcproj
@@ -42,7 +42,7 @@
42 42 Name="VCCLCompilerTool"
43 43 Optimization="0"
44 44 AdditionalIncludeDirectories="C:\WTL75\include;include"
45   - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;D3D_DEBUG_INFO;_CRT_SECURE_NO_DEPRECATE"
  45 + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;D3D_DEBUG_INFO;_CRT_SECURE_NO_DEPRECATE;WINDOWED"
46 46 MinimalRebuild="true"
47 47 BasicRuntimeChecks="3"
48 48 RuntimeLibrary="1"

0 comments on commit e9905df

Please sign in to comment.
Something went wrong with that request. Please try again.