coastline 0.0.4
Loading...
Searching...
No Matches
coastline::DecalCar Class Reference

Editable console body materials or numbered image layers for an imported car. More...

#include <decalcar.h>

Public Member Functions

DecalTexture Texture (int material) const
bool HasMaterial (int material) const
std::string DecalNote () const
bool ImagePanels () const
int PanelCount () const
std::vector< u8 > PanelPixels (int panel) const
 Composite a numbered panel over its imported RGBA pixels.
std::vector< u8 > NoteHeader () const
bool ValidNote (std::span< const u8 > note) const
 Validate the save header, complete panel payloads, and palette before loading.
std::size_t PixelOffset (int x, int y, int width) const
 Locate a packed pixel in linear image layers or console body-panel rows.
u8 * Texels (int material)
const u8 * End () const
std::vector< u8 > CopyEditableData () const
bool RestoreEditableData (std::span< const u8 > data)
 Restore editable texels and palettes without invalidating texture pointers.
const u8 * Mask (int slot) const
u16 PaletteColor (int material, int entry) const
void SetPaletteColor (int material, int entry, u16 color)
 Replace one material palette entry without changing its indexed texels.
std::optional< std::filesystem::path > WriteImages (const std::filesystem::path &directory) const
 Write painted images and an image-override glTF document in imported image order.
std::optional< GltfDocument > ImageDocument () const
 Build the image-override document of WriteImages() in memory, with each image in a buffer view.
const std::filesystem::path & Directory () const

Static Public Member Functions

static std::optional< DecalCar > Load (const std::filesystem::path &directory)
 Reconstruct editable textures from an imported car document and its images.

Detailed Description

Editable console body materials or numbered image layers for an imported car.

Member Function Documentation

◆ Load()

std::optional< DecalCar > coastline::DecalCar::Load ( const std::filesystem::path & directory)
static

Reconstruct editable textures from an imported car document and its images.

Parameters
directoryThe directory of the car, with model.gltf or model.glb.
Returns
The car, or std::nullopt for reported loading or validation failures.
Exceptions
nlohmann::json::exceptionIf editable image metadata has invalid fields or types.

◆ Texture()

DecalTexture coastline::DecalCar::Texture ( int material) const
Parameters
materialThe console material or zero-based numbered image-panel index.
Returns
Texture offsets and dimensions, or an empty texture for an invalid index.

◆ HasMaterial()

bool coastline::DecalCar::HasMaterial ( int material) const
Parameters
materialThe body material or numbered image-panel index.
Returns
Whether the material has non-empty indexed texels and a palette.

◆ DecalNote()

std::string coastline::DecalCar::DecalNote ( ) const
Returns
The Controller Pak note identifier associated with this car's decal format.

◆ ImagePanels()

bool coastline::DecalCar::ImagePanels ( ) const
Returns
Whether numbered image layers replace the original body-panel layout.

◆ PanelCount()

int coastline::DecalCar::PanelCount ( ) const
Returns
The number of editable panels, including absent console body materials.

◆ PanelPixels()

std::vector< u8 > coastline::DecalCar::PanelPixels ( int panel) const

Composite a numbered panel over its imported RGBA pixels.

Parameters
panelThe zero-based numbered image-panel index.
Returns
Top-down RGBA8 pixels, or an empty vector for a non-image or invalid panel.

◆ NoteHeader()

std::vector< u8 > coastline::DecalCar::NoteHeader ( ) const
Returns
The versioned image-layout fingerprint, or an empty header for console decals.

◆ ValidNote()

bool coastline::DecalCar::ValidNote ( std::span< const u8 > note) const

Validate the save header, complete panel payloads, and palette before loading.

Parameters
noteThe saved note bytes.
Returns
Whether saved data matches this model and includes every editable panel and palette.

◆ PixelOffset()

std::size_t coastline::DecalCar::PixelOffset ( int x,
int y,
int width ) const

Locate a packed pixel in linear image layers or console body-panel rows.

Parameters
xThe pixel column within the texture.
yThe pixel row within the texture.
widthThe texture width, in pixels.
Returns
The byte offset from the start of the panel's packed 4-bit texels.

◆ Texels()

u8 * coastline::DecalCar::Texels ( int material)
Parameters
materialThe console material or zero-based numbered image-panel index.
Returns
Mutable packed 4-bit texels, or null for an absent or invalid material. Console rows use TexelOffset(); numbered panels use linear rows through PixelOffset().

◆ End()

const u8 * coastline::DecalCar::End ( ) const
Returns
One byte past the editable storage, valid until the car is destroyed.

◆ CopyEditableData()

std::vector< u8 > coastline::DecalCar::CopyEditableData ( ) const
Returns
A copy of all editable texels and palettes for paint history.

◆ RestoreEditableData()

bool coastline::DecalCar::RestoreEditableData ( std::span< const u8 > data)

Restore editable texels and palettes without invalidating texture pointers.

Parameters
dataA snapshot from CopyEditableData() for this car.
Returns
Whether the snapshot has the expected size and was restored.

◆ Mask()

const u8 * coastline::DecalCar::Mask ( int slot) const
Parameters
slotThe console decal, from 0 to DECAL_SLOTS - 1.
Returns
The mask of the decal, a bit a texel with a set bit protecting it, or null where every texel can be painted. Numbered image panels always return null.

◆ PaletteColor()

u16 coastline::DecalCar::PaletteColor ( int material,
int entry ) const
Parameters
materialThe console material or zero-based numbered image-panel index.
entryThe colour, from 0 to 15.
Returns
The RGBA5551 colour, or zero for an absent material or invalid entry.

◆ SetPaletteColor()

void coastline::DecalCar::SetPaletteColor ( int material,
int entry,
u16 color )

Replace one material palette entry without changing its indexed texels.

Absent materials and invalid entries are ignored. Numbered panels share one palette.

Parameters
materialThe console material or zero-based numbered image-panel index.
entryThe colour, from 0 to 15.
colorThe RGBA5551 colour.

◆ WriteImages()

std::optional< std::filesystem::path > coastline::DecalCar::WriteImages ( const std::filesystem::path & directory) const

Write painted images and an image-override glTF document in imported image order.

Unpainted console images retain their original encoded bytes. Errors from the final document write are not checked.

Parameters
directoryThe directory to write the document and the images to.
Returns
The document path, or std::nullopt when writing or decoding an image fails.

◆ ImageDocument()

std::optional< GltfDocument > coastline::DecalCar::ImageDocument ( ) const

Build the image-override document of WriteImages() in memory, with each image in a buffer view.

Returns
The document, or std::nullopt when encoding or decoding an image fails.

◆ Directory()

const std::filesystem::path & coastline::DecalCar::Directory ( ) const
Returns
The directory of the car in the import.

The documentation for this class was generated from the following file: