OrbitEngine::Graphics::Atlas class

Generic 2D atlas class.

For examples see BitmapAtlas and TextureAtlas

Metadata format:

{
    "frames": [
        {
            "i": 1, // frame index
            "x": 0,
            "y": 0,
            "w": 64,
            "h": 64,
            "f": false // flipped?
        },
        ...
    ],
    "animations": [
        // TODO...
    ]
}

Derived classes

template<typename T, unsigned int N = 1>
class BitmapAtlas
A 2D bitmap atlas.
class TextureAtlas
A 2D texture atlas.

Public types

struct Frame
Holds the information to locate a frame.
struct FrameMetadata
Holds additional information of a frame.

Constructors, destructors, conversion operators

Atlas() protected
~Atlas() protected virtual

Public functions

auto getTexelSize() const -> Math::Vec2f pure virtual
Returns texel sizes in both dimensions (1.0f / size)
auto hasFrame(FrameIndex index) const -> bool
Returns whether the provided index already exists.
auto getFrame(FrameIndex index) const -> const Frame&
Get a constant reference of a frame.

Protected functions

void writeMetadata(Misc::JSONWriter& writer) const
Generates JSON metadata.
void loadMetadata(const rapidjson::Value& data)
Load JSON metadata.
auto exportToFile(const std::string& metadata) const -> bool
Exports the metadata to the disk.
auto addFrame(FrameIndex index, int x, int y, int w, int h, bool flipped, FrameMetadata meta) -> bool
Add a frame's metadata to the atlas.

Function documentation

const Frame& OrbitEngine::Graphics::Atlas::getFrame(FrameIndex index) const

Get a constant reference of a frame.

Parameters
index in requested frame index

bool OrbitEngine::Graphics::Atlas::addFrame(FrameIndex index, int x, int y, int w, int h, bool flipped, FrameMetadata meta) protected

Add a frame's metadata to the atlas.

Parameters
index in identifier within the atlas, must be unique
in location of the frame
in location of the frame
in sizes of the frame
in sizes of the frame
flipped in if the provided frame is rotated 90 degrees clockwise
meta in additional metadata
Returns Whether the operation was successful