resonance 1.0.1
Loading...
Searching...
No Matches
movie.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "os/hxstr.h"
6#include "rnd/amovieset.h"
7#include "rnd/animatable.h"
8#include "rnd/filepath.h"
9#include "rnd/manager.h"
10#include "rndartt/apalette.h"
11
12namespace Rnd {
13class Dbg;
14class Stream;
15class Tex;
16} // namespace Rnd
17
18namespace Rnd {
19
46class Movie : public Animatable {
47public:
55 struct TrackTexture {
58 };
59
71 explicit Movie(const HxStr &name);
72
79 virtual ~Movie();
80
94 virtual void Load(Stream &stream);
95
107 virtual void DumpText(Dbg &sink);
108
119 virtual void Save(Stream &stream);
120
132 virtual void Replace(Object *pFrom, Object *pTo);
133
141 virtual const HxStr &ClassName() const;
142
155 virtual void Copy(const Object *pSource, unsigned nFlags);
156
165 static void *operator new(size_t nSize);
166
174 static void operator delete(void *pBlock);
175
186 Tex *FindTrackTexture(int nTrackId) const;
187
198
208 virtual void SetFrameSelf(float flFrame);
209
220 virtual void Reopen();
221
233 void SetFilename(const HxStr &name);
234
250
258
269 void AttachTrack(int nTrackId);
270
278 void DetachTrack(int nTrackId);
279
293 void SetTrackTexture(int nTrackId, Tex *pTex);
294
303 void RemoveTrackTexture(int nTrackId);
304
317 void OnChunk(AMovieChunkHdr *pHeader, void *pPayload);
318
330 static void MasterTrackCallback(AMovieChunkHdr *pHeader, void *pPayload, void *pData);
331
348 static void ReadTrackTextures(Stream &stream, std::list<TrackTexture> &textures);
349
355
356private:
357 AMovieSet *mStream; // +0x20 The open file, or null.
358 // +0x24 Set by a successful open. The next SetFrameSelf() starts the stream's loop ticks at
359 // the current tick and clears it.
360 int mStartPending;
361 // +0x28 Set once SetFrameSelf() has matched every track texture to its frame, and cleared by a
362 // successful open.
363 int mTexturesMatched;
364 int mZone; // +0x2c The zone current when the file was opened, -1 before.
365
366public:
372 std::list<TrackTexture> mTrackTextures;
373
374private:
375 // +0x34 Palette the PALL chunks fill and every frame chunk's bitmap draws through. The
376 // constructor also clears it with memset() after constructing it.
377 APalette mPalette;
378};
379
392
405inline Movie *NewMovie(const HxStr &name) {
406 try {
407 return new Movie(name);
408 } catch (...) {
409 return nullptr;
410 }
411}
412
420
430inline void RegisterMovieClass() {
432}
433
434} // namespace Rnd
A 256 entry colour table an ABitmap points at.
Definition apalette.h:31
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Reader that plays a chunked movie file into per-track handlers.
Definition amovieset.h:24
Animatable()
Construct an animatable with no children, no filters, and a zero frame.
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
File name that the renderer resolves against a shared root directory.
Definition filepath.h:24
Animation that streams a compressed video file into a set of textures.
Definition movie.h:46
void SetFilename(const HxStr &name)
Set the file this movie plays, under FilePath::sRoot.
virtual const HxStr & ClassName() const
Report the class key a .rnd file writes for a movie.
static void ReadTrackTextures(Stream &stream, std::list< TrackTexture > &textures)
Read a track texture list from stream.
void SetTrackTexture(int nTrackId, Tex *pTex)
Play a track into a texture, replacing any texture the track played into before.
const HxStr & GetRelativeFilename() const
Return mFilename relative to FilePath::sRoot.
virtual void Save(Stream &stream)
Serialise the movie.
static void MasterTrackCallback(AMovieChunkHdr *pHeader, void *pPayload, void *pData)
The AMovieSet handler AttachTrack() installs, which passes the chunk to pData's OnChunk().
void RemoveTrackTexture(int nTrackId)
Drop the first entry of mTrackTextures that plays nTrackId, releasing its texture,...
Movie(const HxStr &name)
Construct a movie with no file, no track textures, and a cleared stream buffer.
virtual void Replace(Object *pFrom, Object *pTo)
Replace one object reference with another.
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy another movie over this one.
void CloseMovieFile()
Release every track texture and destroy the stream reader.
virtual void SetFrameSelf(float flFrame)
Advance the movie to a frame.
void AttachTrack(int nTrackId)
Route one track's chunks to this movie.
void DetachTrack(int nTrackId)
Stop routing one track's chunks anywhere.
virtual void DumpText(Dbg &sink)
Write a description of this movie to sink.
virtual void Load(Stream &stream)
Read the movie record from stream.
virtual void Reopen()
Reopen the file this movie already names.
std::list< TrackTexture > mTrackTextures
Textures the file's tracks play into.
Definition movie.h:372
FilePath mFilename
File this movie plays, resolved against FilePath::sRoot.
Definition movie.h:354
Tex * FindTrackTexture(int nTrackId) const
Return the texture of the first entry of mTrackTextures that plays nTrackId.
void OpenMovieFile()
Open the file mFilename names and take a reference on every track texture.
void OnChunk(AMovieChunkHdr *pHeader, void *pPayload)
Draw one video chunk into the texture its track plays into.
virtual ~Movie()
Close the file and release every track texture.
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
Byte stream that every renderer object serialises itself through.
Definition stream.h:31
Texture, as a bitmap path plus the load state of its mip levels.
Definition tex.h:43
The rendering engine.
Definition animhelper.h:3
HxStr g_movieClassName
Registered class name of Rnd::Movie, the string "Movie".
Object * CreateRegisteredMovie(const HxStr &name)
Allocate and construct a movie.
Manager TheManager
The renderer's object registry.
void RegisterMovieClass()
Register the "Movie" class with Rnd::Manager.
Definition movie.h:430
Movie * NewMovie(const HxStr &name)
Allocate and construct a movie, returning the Movie pointer itself.
Definition movie.h:405
Header of every chunk in a movie file, followed by mSize payload bytes.
Definition amoviechunkhdr.h:10
One video track of the file and the texture it plays into.
Definition movie.h:55
int mTrackId
Definition movie.h:56
Tex * mTex
Definition movie.h:57