QtCraft API C++ classes QML types Handbook

QcTextureAnimation Struct

How a texture animates (decision E-878): frames pictures shown for frameTicks game ticks (50 ms) each, in a loop; with interpolate the picture blends smoothly into the next one. More...

Header: #include <common/content/blocks/QcTextureAnimation.h>

Public Types

struct Frame

Public Functions

bool animated() const
int cycleTicks() const
QcTextureAnimation::Frame frameAt(double ticks) const

Public Variables

int frameTicks
int frames
bool interpolate

Static Public Members

const int defaultFrameTicks
const int maxFrameTicks
const int maxFrames
bool patternMoves(const QString &pattern)
QcResult<QcTextureAnimation> read(const QJsonObject &definition)

Detailed Description

A texture definition declares it with "frames", "frameTime" (ticks) and "interpolate"; one frame is a still texture. The frames sit in the texture atlas and the block shader picks them by time (QcTextureAtlas::animationMap), so an animation costs no mesh rebuild and no upload per frame.

Member Function Documentation

bool QcTextureAnimation::animated() const

Returns whether the texture has more than one frame.

int QcTextureAnimation::cycleTicks() const

Returns the ticks of one loop.

QcTextureAnimation::Frame QcTextureAnimation::frameAt(double ticks) const

Returns the frame at ticks since any start that is a multiple of cycleTicks(), the same as the block shader picks (block.vert): deterministic, a still texture always shows frame 0.

[static] bool QcTextureAnimation::patternMoves(const QString &pattern)

Returns whether the procedural pattern pattern paints its frames differently (fire, lava, water; QcTextureSynthesizer reads the phase only there): other patterns with "frames" show the same picture in every frame, which the content loader warns about.

[static] QcResult<QcTextureAnimation> QcTextureAnimation::read(const QJsonObject &definition)

Returns the fields "frames" (1 to maxFrames), "frameTime" (1 to maxFrameTicks) and "interpolate" of the texture definition definition; the error names the field that is wrong. Without "frames" a still texture, "frameTime" and "interpolate" then are errors too.

Member Variable Documentation

const int QcTextureAnimation::defaultFrameTicks

Frame time of an animation whose source gives none (a texture pack's strip over a still texture, a mod's PNG strip).

int QcTextureAnimation::frameTicks

Game ticks each frame is shown ("frameTime").

int QcTextureAnimation::frames

Number of frames ("frames"); 1 for a still texture.

bool QcTextureAnimation::interpolate

Whether each frame blends into the next ("interpolate").