nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
main.cc
Go to the documentation of this file.
1// Films a film's shots through the game's own renderer, a frame at a time
2// rather than as fast as the screen goes, so that the game's clock can run
3// slower than the film's and each frame is drawn as long as it takes. Each
4// shot goes into a video with the game's sounds, heard from the camera.
5//
6// nanommo_cinema <film.txtpb> <out dir> [shots=a,b] [size=1920x1080]
7// [fps=30] [tall=0|1] [still=seconds] [cel=0|1]
8// nanommo_cinema scout <land> <radius>
9// nanommo_cinema peaks|shores <land>
10#include <raylib.h>
11#include <raymath.h>
12
13#include <algorithm>
14#include <array>
15#include <chrono>
16#include <cmath>
17#include <cstdio>
18#include <cstdlib>
19#include <fstream>
20#include <functional>
21#include <iostream>
22#include <map>
23#include <optional>
24#include <set>
25#include <span>
26#include <string>
27#include <utility>
28#include <vector>
29
30#include "absl/strings/str_cat.h"
31#include "absl/strings/str_split.h"
32#include "client/ambience.h"
33#include "client/animator.h"
34#include "client/atmosphere.h"
35#include "client/audio.h"
36#include "client/characters.h"
37#include "client/daylight.h"
38#include "client/foley.h"
39#include "client/gate.h"
40#include "client/graphics.h"
41#include "client/postprocess.h"
42#include "client/renderer.h"
43#include "client/soundscape.h"
44#include "client/synth.h"
45#include "content/content.h"
46#include "terrain/lands.h"
47#include "tools/cinema/film.h"
48
49namespace {
50
51using nanommo::cinema::Shot;
52
53struct Options {
54 std::string out;
55 int width = 1920;
56 int height = 1080;
57 float fps = 30.0f;
58 bool tall = false;
59 /// Cel shading's bands and outlines: as the film says, unless cel= says
60 /// otherwise.
61 std::optional<bool> cel;
62 /// A single frame, at this second of each shot, as a picture: -1 for none.
63 float still = -1.0f;
64};
65
66// A sound the game would play, at a moment of the film, from somewhere.
67struct Sound {
68 nanommo::Samples samples;
69 float at = 0.0f;
70 /// How fast the game ran then, which slows the sound down too.
71 float speed = 1.0f;
72 float level = 1.0f;
73 nanommo::Heard heard;
74};
75
76// A sound the game is going to play once its clock gets there: one of a
77// skill's fx, at its own moment, so that a slowed skill's sounds come with
78// what they go with.
79struct Pending {
80 float game = 0.0f;
81 nanommo::Samples samples;
82 Vector3 at;
83};
84
85// Slowed sounds drop in pitch, as on a tape played slower, but by less than
86// the picture slows, or a quarter speed would take them two octaves down.
87float Rate(float speed) { return std::clamp(std::sqrt(speed), 0.4f, 1.0f); }
88
89void WriteWave(const std::string& path, const std::vector<float>& left,
90 const std::vector<float>& right) {
91 std::ofstream file(path, std::ios::binary);
92 const auto u32 = [&](uint32_t v) {
93 file.write(reinterpret_cast<char*>(&v), 4);
94 };
95 const auto u16 = [&](uint16_t v) {
96 file.write(reinterpret_cast<char*>(&v), 2);
97 };
98 const uint32_t bytes = static_cast<uint32_t>(left.size() * 4);
99 file.write("RIFF", 4);
100 u32(36 + bytes);
101 file.write("WAVEfmt ", 8);
102 u32(16), u16(1), u16(2), u32(nanommo::kRate), u32(nanommo::kRate * 4);
103 u16(4), u16(16);
104 file.write("data", 4);
105 u32(bytes);
106 for (size_t i = 0; i < left.size(); ++i) {
107 for (const float s : {left[i], right[i]}) {
108 u16(static_cast<uint16_t>(
109 static_cast<int16_t>(std::clamp(s, -1.0f, 1.0f) * 32767.0f)));
110 }
111 }
112}
113
114// The shot's sounds, mixed over what's playing all along, the weather and the
115// music, into two channels as long as the shot.
116void Mix(const std::vector<Sound>& sounds, float seconds,
117 std::vector<float> left, std::vector<float> right,
118 const std::string& path) {
119 const size_t length = static_cast<size_t>(seconds * nanommo::kRate);
120 left.resize(length, 0.0f);
121 right.resize(length, 0.0f);
122 for (const Sound& sound : sounds) {
123 const float rate = Rate(sound.speed);
124 const float gain = sound.level * sound.heard.volume;
125 const float to_left = gain * std::min(1.0f, 1.0f - sound.heard.pan);
126 const float to_right = gain * std::min(1.0f, 1.0f + sound.heard.pan);
127 const size_t start = static_cast<size_t>(sound.at * nanommo::kRate);
128 for (size_t i = 0; start + i < length; ++i) {
129 const float from = static_cast<float>(i) * rate;
130 const size_t a = static_cast<size_t>(from);
131 if (a + 1 >= sound.samples.size()) {
132 break;
133 }
134 const float s = Lerp(sound.samples[a], sound.samples[a + 1],
135 from - static_cast<float>(a));
136 left[start + i] += s * to_left;
137 right[start + i] += s * to_right;
138 }
139 }
140 // Sounds at once can add up past one: rounded off, as a skill's own are.
141 nanommo::Limit(left);
142 nanommo::Limit(right);
143 WriteWave(path, left, right);
144}
145
146// The game's own music, as loud as the shot says, from where in the track it
147// says, fading in and, at the end of the shot, out.
148void AddMusic(const Shot& shot, std::vector<float>& left,
149 std::vector<float>& right) {
150 Wave wave = LoadWave((nanommo::MusicFolder() + "/background.mp3").c_str());
151 if (!IsWaveValid(wave)) {
152 std::cerr << "nanommo_cinema: no music in " << nanommo::MusicFolder()
153 << '\n';
154 return;
155 }
156 WaveFormat(&wave, nanommo::kRate, 32, 2);
157 float* samples = LoadWaveSamples(wave);
158 const size_t length = static_cast<size_t>(shot.seconds() * nanommo::kRate);
159 left.resize(length, 0.0f);
160 right.resize(length, 0.0f);
161 const size_t start = static_cast<size_t>(shot.music_from() * nanommo::kRate);
162 const float in = 2.0f * nanommo::kRate;
163 const float out = 3.0f * nanommo::kRate;
164 for (size_t i = 0; i < length && start + i < wave.frameCount; ++i) {
165 const float fade = std::min({1.0f, static_cast<float>(i) / in,
166 static_cast<float>(length - i) / out});
167 const float gain = shot.music() * fade;
168 left[i] += gain * samples[2 * (start + i)];
169 right[i] += gain * samples[2 * (start + i) + 1];
170 }
171 UnloadWaveSamples(samples);
172 UnloadWave(wave);
173}
174
175int Shoot(const Shot& shot, const nanommo::Content& content,
176 const Options& options) {
177 const auto started = std::chrono::steady_clock::now();
178 const int land = nanommo::cinema::LandOf(shot);
179 const nanommo::Terrain terrain = nanommo::cinema::TerrainOf(land);
180 // main() settles it from the film, where cel= didn't.
181 const bool cel = options.cel.value_or(false);
182 nanommo::Renderer renderer(content);
183 renderer.set_cel_shading(cel);
184 renderer.set_terrain(terrain, land);
185 renderer.set_cubes(nanommo::GateCubes(terrain, land));
186 // The shot's own fog, sun, light and clouds, over the time of day and the
187 // weather, each frame.
188 renderer.set_adjust([&shot](nanommo::Atmosphere& sky) {
189 if (shot.sky().fog_near() > 0.0f) {
190 sky.fog_near = shot.sky().fog_near();
191 }
192 if (shot.sky().fog_far() > 0.0f) {
193 sky.fog_far = shot.sky().fog_far();
194 }
195 if (shot.sky().has_sun()) {
196 const auto& sun = shot.sky().sun();
197 sky.sun = {sun.x(), sun.y(), sun.z()};
198 }
199 if (shot.sky().light() > 0.0f) {
200 for (float& c : sky.sunlight) {
201 c *= shot.sky().light();
202 }
203 for (float& c : sky.ambient) {
204 c *= shot.sky().light();
205 }
206 }
207 if (shot.sky().has_cloudiness()) {
208 sky.cloudiness = shot.sky().cloudiness();
209 }
210 });
211 // The time of day and the weather, as the server would send them, if the
212 // shot has either: the day goes on as fast as the shot says, and the
213 // weather comes or goes.
214 const bool skied = shot.sky().has_day() || !shot.sky().weather().empty();
215 nanommo::protocol::Weather weather = nanommo::protocol::WEATHER_CLEAR;
216 if (!shot.sky().weather().empty() &&
217 !nanommo::protocol::Weather_Parse("WEATHER_" + shot.sky().weather(),
218 &weather)) {
219 std::cerr << "nanommo_cinema: no weather called " << shot.sky().weather()
220 << '\n';
221 return 1;
222 }
223 const auto sky_at = [&](float now) {
224 nanommo::protocol::Sky sky;
225 const float day = shot.sky().has_day() ? shot.sky().day() : 0.5f;
226 sky.set_day(std::fmod(day + shot.sky().days() * now, 1.0f));
227 sky.set_weather(weather);
228 const float share = std::clamp(now / shot.seconds(), 0.0f, 1.0f);
229 sky.set_strength(
230 shot.sky().has_strength_to()
231 ? Lerp(shot.sky().strength(), shot.sky().strength_to(), share)
232 : shot.sky().strength());
233 const bool gale = weather == nanommo::protocol::WEATHER_STORM ||
234 weather == nanommo::protocol::WEATHER_FIRE;
235 sky.set_wind_x(shot.sky().has_wind_x() ? shot.sky().wind_x()
236 : gale ? 5.0f
237 : 1.2f);
238 sky.set_wind_z(shot.sky().has_wind_z() ? shot.sky().wind_z()
239 : gale ? 2.0f
240 : 0.5f);
241 return sky;
242 };
243 const nanommo::Showing showing = {.day_night = shot.sky().has_day(),
244 .weather = true};
245 // Its lightning strikes where it did the last time the shot was filmed.
246 const uint32_t shot_seed =
247 static_cast<uint32_t>(std::hash<std::string>()(shot.id()));
248 renderer.weather().set_seed(shot_seed);
249 if (shot.sky().has_wetness()) {
250 renderer.weather().set_wetness(shot.sky().wetness());
251 }
252 nanommo::Ambience ambience(shot_seed);
253 nanommo::UseRecordings(ambience);
254 std::vector<float> bed_left, bed_right;
255 nanommo::Animator animator(content);
257 const nanommo::GraphicsSettings graphics{.cel_shading = cel};
258 const RenderTexture2D picture =
259 LoadRenderTexture(options.width, options.height);
260
261 const std::string name =
262 absl::StrCat(options.out, "/", shot.id(), options.tall ? "-tall" : "");
263 FILE* video = nullptr;
264 if (options.still < 0.0f) {
265 const std::string encode = absl::StrCat(
266 "ffmpeg -loglevel error -y -f rawvideo -pix_fmt rgba -s ",
267 options.width, "x", options.height, " -r ", options.fps,
268 " -i - -vf vflip -c:v libx264 -preset fast -crf 14 -pix_fmt yuv420p ",
269 name, ".video.mp4");
270#if defined(_WIN32)
271 // In text mode, Windows would turn each 10 in the frames into 13 10.
272 video = _popen(encode.c_str(), "wb");
273#else
274 video = popen(encode.c_str(), "w");
275#endif
276 if (video == nullptr) {
277 std::cerr << "nanommo_cinema: couldn't start ffmpeg\n";
278 return 1;
279 }
280 }
281
282 nanommo::cinema::Clock clock(shot);
283 nanommo::cinema::Stage stage(shot, content);
284 nanommo::Footsteps footsteps;
285 nanommo::Casts casts;
286 std::vector<Sound> sounds;
287 std::vector<Pending> pending;
288 uint32_t seed = 1;
289 const int frames =
290 static_cast<int>(std::lround(shot.seconds() * options.fps));
291 const int still =
292 options.still < 0.0f
293 ? -1
294 : static_cast<int>(std::lround(options.still * options.fps));
295 float moved = 0.0f;
296 for (int frame = 0; frame < frames && (still < 0 || frame <= still);
297 ++frame) {
298 const float now = clock.film();
299 const float game = clock.game();
300 std::vector<nanommo::Figure> figures =
301 animator.Update(stage.At(game), moved);
302 for (nanommo::Figure& figure : figures) {
303 figure.position.y = terrain.Height(figure.position.x, figure.position.z);
304 }
305 renderer.set_figures(std::move(figures));
306 const Camera3D camera =
307 nanommo::cinema::CameraAt(shot, now, options.tall, terrain);
308 renderer.set_camera(camera);
309 if (skied) {
310 renderer.set_sky(sky_at(now), showing);
311 }
312 renderer.Animate(moved);
313
314 // What the game would play now, heard where the camera looks, with the
315 // camera's right to the right.
316 const Vector3 right = Vector3Normalize(Vector3CrossProduct(
317 Vector3Subtract(camera.target, camera.position), camera.up));
318 const float speed = nanommo::cinema::SpeedAt(shot, now);
319 std::map<uint64_t, nanommo::Gait> gaits;
320 std::map<uint64_t, Vector3> where;
321 for (const nanommo::Figure& figure : renderer.figures()) {
322 if (const auto gait = renderer.GaitOf(figure)) {
323 gaits[nanommo::Who(figure)] = *gait;
324 where[nanommo::Who(figure)] = figure.position;
325 }
326 }
327 for (const uint64_t who : footsteps.Update(gaits)) {
328 const Vector3 at = where.at(who);
329 sounds.push_back(
330 {.samples = nanommo::Step(
331 nanommo::GroundAt(terrain, land, at.x, at.z), seed++),
332 .at = now,
333 .speed = speed,
334 .level = 0.5f,
335 .heard = nanommo::Hear(at, camera.target, right)});
336 }
337 for (const nanommo::Figure& figure : casts.Update(renderer.figures())) {
338 const auto skill = content.skills.by_id.find(figure.to_skill);
339 if (skill == content.skills.by_id.end()) {
340 continue;
341 }
342 // Each of its fx's sounds at the fx's own moment of the game, as the
343 // fx is drawn then, however slowly the game runs by then.
344 for (const nanommo::skills::Fx& fx : skill->second.look().fx()) {
345 if (fx.at() == nanommo::skills::Fx::TARGET && figure.target == 0) {
346 continue;
347 }
348 pending.push_back({.game = game + fx.from_ms() / 1000.0f,
349 .samples = nanommo::FxSound(fx, seed++),
350 .at = figure.position});
351 }
352 }
353 // Those whose moment has come.
354 for (auto it = pending.begin(); it != pending.end();) {
355 if (it->game > game) {
356 ++it;
357 continue;
358 }
359 sounds.push_back({.samples = std::move(it->samples),
360 .at = now,
361 .speed = speed,
362 .level = 1.0f,
363 .heard = nanommo::Hear(it->at, camera.target, right)});
364 it = pending.erase(it);
365 }
366
367 if (still < 0 || frame == still) {
368 post.Begin(graphics, options.width, options.height);
369 renderer.Draw();
370 post.End();
371 post.DrawOnto(picture);
372 Image image = LoadImageFromTexture(picture.texture);
373 if (video != nullptr) {
374 fwrite(image.data, 4,
375 static_cast<size_t>(options.width) * options.height, video);
376 } else {
377 ImageFlipVertical(&image);
378 ExportImage(image, absl::StrCat(name, ".png").c_str());
379 }
380 UnloadImage(image);
381 }
382 // The weather's sound, and the thunder of each bolt, heard where the
383 // camera looks, up to the end of this frame.
384 if (video != nullptr && skied) {
385 const Vector3 ears = camera.target;
386 for (const nanommo::Bolt& bolt : renderer.weather().TakeBolts()) {
387 ambience.Thunder(Vector3Distance(bolt.at, ears),
388 nanommo::Hear(bolt.at, ears, right).pan);
389 }
390 bool by_water = false;
391 for (const auto& [dx, dz] : {std::pair{0.0f, 0.0f},
392 {8.0f, 0.0f},
393 {-8.0f, 0.0f},
394 {0.0f, 8.0f},
395 {0.0f, -8.0f}}) {
396 by_water = by_water || terrain.Height(ears.x + dx, ears.z + dz) <
398 }
399 const size_t from = bed_left.size();
400 const size_t to = static_cast<size_t>(
401 std::lround((frame + 1) / options.fps * nanommo::kRate));
402 bed_left.resize(to, 0.0f);
403 bed_right.resize(to, 0.0f);
404 ambience.Fill(std::span(bed_left).subspan(from),
405 std::span(bed_right).subspan(from),
406 nanommo::HearingOf(land, sky_at(now), by_water, true));
407 }
408 moved = clock.Advance(1.0f / options.fps);
409 }
410 UnloadRenderTexture(picture);
411 if (video != nullptr) {
412#if defined(_WIN32)
413 _pclose(video);
414#else
415 pclose(video);
416#endif
417 if (shot.music() > 0.0f) {
418 AddMusic(shot, bed_left, bed_right);
419 }
420 Mix(sounds, shot.seconds(), std::move(bed_left), std::move(bed_right),
421 name + ".wav");
422 const std::string mux =
423 absl::StrCat("ffmpeg -loglevel error -y -i ", name, ".video.mp4 -i ",
424 name, ".wav -c:v copy -c:a aac -b:a 256k -shortest ", name,
425 ".mp4 && rm ", name, ".video.mp4");
426 if (std::system(mux.c_str()) != 0) {
427 std::cerr << "nanommo_cinema: couldn't add the sound to " << name << '\n';
428 return 1;
429 }
430 }
431 const float took =
432 std::chrono::duration<float>(std::chrono::steady_clock::now() - started)
433 .count();
434 std::cout << shot.id() << ": " << frames << " frames, " << shot.seconds()
435 << " s of film, " << clock.game() - shot.from()
436 << " s of game, drawn in " << took << " s\n";
437 return 0;
438}
439
440// The highest places in a land, or the shore's, a dozen of them apart, for
441// someone to stand and look out from.
442int Heights(const std::string& name, bool shore) {
443 if (!nanommo::IsLand(name)) {
444 std::cerr << "nanommo_cinema: no land called " << name << '\n';
445 return 2;
446 }
447 const int land = nanommo::LandNamed(name);
448 const nanommo::Terrain terrain = nanommo::cinema::TerrainOf(land);
449 struct Place {
450 float x, z, height;
451 };
452 std::vector<Place> places;
453 const float edge = terrain.half_size() - 4.0f;
454 for (float x = -edge; x <= edge; x += 2.0f) {
455 for (float z = -edge; z <= edge; z += 2.0f) {
456 const float height = terrain.Height(x, z);
457 if (!terrain.Walkable(x, z)) {
458 continue;
459 }
460 // On the shore: dry, with the sea a few steps out on some side.
461 const bool by_sea =
462 height > 0.4f && height < 2.5f &&
463 std::ranges::any_of(
464 std::array<std::pair<float, float>, 4>{
465 {{6.0f, 0.0f}, {-6.0f, 0.0f}, {0.0f, 6.0f}, {0.0f, -6.0f}}},
466 [&](const auto& d) {
467 return terrain.Height(x + d.first, z + d.second) < -0.3f;
468 });
469 if (!shore || by_sea) {
470 places.push_back({x, z, height});
471 }
472 }
473 }
474 std::ranges::sort(places, [](const Place& a, const Place& b) {
475 return a.height > b.height;
476 });
477 std::vector<Place> kept;
478 for (const Place& place : places) {
479 if (std::ranges::none_of(kept, [&](const Place& k) {
480 return std::hypot(k.x - place.x, k.z - place.z) < 25.0f;
481 })) {
482 kept.push_back(place);
483 }
484 if (kept.size() == 12) {
485 break;
486 }
487 }
488 for (const Place& place : kept) {
489 std::cout << name << " x " << place.x << " z " << place.z << " height "
490 << place.height << '\n';
491 }
492 return 0;
493}
494
495// The flattest open places in a land, with no tree and no water within the
496// radius, for a fight to be staged on, best first.
497int Scout(const std::string& name, float radius) {
498 if (!nanommo::IsLand(name)) {
499 std::cerr << "nanommo_cinema: no land called " << name << '\n';
500 return 2;
501 }
502 const int land = nanommo::LandNamed(name);
503 const nanommo::Terrain terrain = nanommo::cinema::TerrainOf(land);
504 struct Place {
505 float x, z, rise;
506 };
507 std::vector<Place> places;
508 const float edge = terrain.half_size() - radius - 4.0f;
509 for (float x = -edge; x <= edge; x += 2.0f) {
510 for (float z = -edge; z <= edge; z += 2.0f) {
511 float low = 1e9f, high = -1e9f;
512 bool open = true;
513 for (float dx = -radius; dx <= radius && open; dx += 1.0f) {
514 for (float dz = -radius; dz <= radius && open; dz += 1.0f) {
515 if (dx * dx + dz * dz > radius * radius) {
516 continue;
517 }
518 open = terrain.Walkable(x + dx, z + dz) &&
519 terrain.Height(x + dx, z + dz) > 0.3f;
520 low = std::min(low, terrain.Height(x + dx, z + dz));
521 high = std::max(high, terrain.Height(x + dx, z + dz));
522 }
523 }
524 if (open) {
525 places.push_back({x, z, high - low});
526 }
527 }
528 }
529 std::ranges::sort(places, {}, &Place::rise);
530 // Not two places on top of each other.
531 std::vector<Place> kept;
532 for (const Place& place : places) {
533 if (std::ranges::none_of(kept, [&](const Place& k) {
534 return std::hypot(k.x - place.x, k.z - place.z) < 2.0f * radius;
535 })) {
536 kept.push_back(place);
537 }
538 if (kept.size() == 12) {
539 break;
540 }
541 }
542 for (const Place& place : kept) {
543 std::cout << name << " x " << place.x << " z " << place.z << " rise "
544 << place.rise << " height " << terrain.Height(place.x, place.z)
545 << '\n';
546 }
547 return 0;
548}
549
550} // namespace
551
552int main(int argc, char** argv) {
553 if (argc == 4 && std::string(argv[1]) == "scout") {
554 return Scout(argv[2], std::strtof(argv[3], nullptr));
555 }
556 if (argc == 3 &&
557 (std::string(argv[1]) == "peaks" || std::string(argv[1]) == "shores")) {
558 return Heights(argv[2], std::string(argv[1]) == "shores");
559 }
560 if (argc < 3) {
561 std::cerr
562 << "usage: nanommo_cinema <film.txtpb> <out dir> [key=value ...]\n"
563 " nanommo_cinema scout <land> <radius>\n";
564 return 2;
565 }
566 Options options;
567 options.out = argv[2];
568 std::set<std::string> wanted;
569 bool sized = false;
570 for (int i = 3; i < argc; ++i) {
571 const std::vector<std::string> pair = absl::StrSplit(argv[i], '=');
572 if (pair.size() != 2) {
573 std::cerr << "nanommo_cinema: not key=value: " << argv[i] << '\n';
574 return 2;
575 }
576 const std::string& key = pair[0];
577 const std::string& value = pair[1];
578 if (key == "shots") {
579 for (const auto& id : absl::StrSplit(value, ',')) {
580 wanted.emplace(id);
581 }
582 } else if (key == "size") {
583 sized = std::sscanf(value.c_str(), "%dx%d", &options.width,
584 &options.height) == 2;
585 } else if (key == "fps") {
586 options.fps = std::strtof(value.c_str(), nullptr);
587 } else if (key == "tall") {
588 options.tall = value == "1";
589 } else if (key == "cel") {
590 options.cel = value == "1";
591 } else if (key == "still") {
592 options.still = std::strtof(value.c_str(), nullptr);
593 } else {
594 std::cerr << "nanommo_cinema: unknown key " << key << '\n';
595 return 2;
596 }
597 }
598 if (options.tall && !sized) {
599 options.width = 1080;
600 options.height = 1920;
601 }
602
603 const absl::StatusOr<nanommo::cinema::Film> film =
605 if (!film.ok()) {
606 std::cerr << "nanommo_cinema: " << film.status().message() << '\n';
607 return 1;
608 }
609 if (!options.cel) {
610 options.cel = film->cel_shading();
611 }
612 // The window only gives us a GL context: the frames are drawn into render
613 // textures of the film's size, whatever the screen's.
614 SetTraceLogLevel(LOG_WARNING);
615 SetConfigFlags(FLAG_WINDOW_HIDDEN);
616 InitWindow(320, 180, "nanoMMO cinema");
617 if (!IsWindowReady()) {
618 return 1;
619 }
620 SetTargetFPS(0);
621 const auto content = nanommo::ReadContent(nanommo::ContentFolder());
622 if (!content.ok()) {
623 std::cerr << "nanommo_cinema: " << content.status().message() << '\n';
624 return 1;
625 }
626 int failed = 0;
627 for (const Shot& shot : film->shots()) {
628 if (wanted.empty() || wanted.contains(shot.id())) {
629 failed += Shoot(shot, *content, options);
630 }
631 }
632 CloseWindow();
633 return failed == 0 ? 0 : 1;
634}
std::vector< Figure > Update(const std::vector< Figure > &figures)
std::vector< uint64_t > Update(const std::map< uint64_t, Gait > &gaits)
Definition soundscape.cc:92
void DrawOnto(const RenderTexture2D &into)
void Begin(const GraphicsSettings &graphics)
float half_size() const
From the middle to each side of the grid.
Definition terrain.h:88
static constexpr float kSeaLevel
Definition terrain.h:50
float Height(float x, float z) const
On the triangles between the grid's corners, as the client draws them.
Definition terrain.cc:102
bool Walkable(float x, float z) const
Definition terrain.cc:123
int main()
Definition login_main.cc:28
Camera3D CameraAt(const Shot &shot, float seconds, bool tall, const Terrain &terrain)
Definition film.cc:253
Vector3 Place(const Point &point, const Terrain &terrain)
Definition film.cc:212
float SpeedAt(const Shot &shot, float seconds)
How fast the game runs at that second of the shot.
Definition film.cc:180
int LandOf(const Shot &shot)
The land a shot is in, by its place in kLands.
Definition film.cc:174
Terrain TerrainOf(int land)
The land's terrain, as the server builds it for the first world.
Definition film.cc:176
absl::StatusOr< Film > ReadFilm(const std::string &path)
The shots in a text file, as the content files are written.
Definition film.cc:143
std::vector< float > Samples
One channel of sound, at kRate.
Definition synth.h:14
Samples FxSound(const skills::Fx &fx, uint32_t seed)
The sound of one of a skill's fx, from when it starts.
Definition foley.cc:308
Ground GroundAt(const Terrain &terrain, int land, float x, float z)
What's underfoot there: the water we wade in, or the land's surface.
Definition foley.cc:97
int LandNamed(std::string_view name)
Its place in the list, or the first land's for a name that isn't there.
Definition lands.cc:10
std::vector< Cube > GateCubes(const Terrain &terrain, int land)
Definition gate.cc:35
void UseRecordings(Ambience &ambience)
Definition audio.cc:37
uint64_t Who(const Figure &figure)
Definition animator.cc:124
void Mix(Samples &mix, const Samples &sound, float at, float gain)
Definition synth.cc:69
Samples Step(Ground ground, uint32_t seed)
Definition foley.cc:122
std::string ContentFolder()
void Limit(Samples &samples)
Definition synth.cc:105
Heard Hear(Vector3 source, Vector3 ears, Vector3 right)
Definition soundscape.cc:21
Hearing HearingOf(int land, const protocol::Sky &sky, bool by_water, bool weather)
Definition ambience.cc:340
constexpr int kRate
Definition synth.h:11
std::string MusicFolder()
Definition audio.cc:21
absl::StatusOr< Content > ReadContent(const std::string &folder)
Reads each file in the folder, or says which file is wrong, and where.
Definition content.cc:64
bool IsLand(std::string_view name)
Definition lands.cc:19
The sky and the light, which the shaders read each frame.
Definition atmosphere.h:13
std::array< float, 3 > ambient
What a face gets even when it's turned away from the sun.
Definition atmosphere.h:25
std::array< float, 3 > sunlight
What the sun adds to a face that's turned to it.
Definition atmosphere.h:23
std::array< float, 3 > sky
The background, which the fog fades into.
Definition atmosphere.h:15
std::array< float, 3 > sun
Towards the sun.
Definition atmosphere.h:21
Where a bolt of lightning struck, for its thunder to come from.
Definition weather.h:17
SkillTable skills
Definition content.h:36
What turns on and off: the time of day, and the weather.
Definition daylight.h:18
std::map< uint32_t, skills::Skill > by_id
Definition skills.h:17