vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
asset_cook.h
1#pragma once
2
3#include <cstdint>
4#include <filesystem>
5
6#include "resource/asset_type.h"
7
8namespace Vkm::Engine {
9
11struct AudioClipAsset;
12struct MeshAsset;
13struct SkeletonAsset;
14struct TerrainAsset;
15struct TextureAsset;
16
17namespace TerrainFile {
18 struct Names;
19}
20
29namespace AssetCook {
30
39constexpr uint16_t COOKER_VERSION = 13;
40
52uint64_t cacheKey(uint64_t recipeHash, AssetType type);
53
59constexpr uint32_t MAX_SKELETON_BONES = 1024;
60
66constexpr uint32_t MAX_AUDIO_CHANNELS = 8;
67
74constexpr uint32_t MAX_AUDIO_SAMPLE_RATE = 384000;
75
84[[nodiscard]] bool writeMesh (const std::filesystem::path& path, const MeshAsset& mesh);
85[[nodiscard]] bool writeTexture (const std::filesystem::path& path, const TextureAsset& texture);
86[[nodiscard]] bool writeSkeleton (const std::filesystem::path& path, const SkeletonAsset& skeleton);
87[[nodiscard]] bool writeAnimationClip(const std::filesystem::path& path, const AnimationClipAsset& clip);
88[[nodiscard]] bool writeAudioClip (const std::filesystem::path& path, const AudioClipAsset& audio);
89
100[[nodiscard]] bool writeTerrain(const std::filesystem::path& path, const TerrainAsset& terrain);
101
113[[nodiscard]] bool isCookedCurrent(AssetType type, const std::filesystem::path& path);
114
122[[nodiscard]] bool readMesh (const std::filesystem::path& path, MeshAsset& out);
123[[nodiscard]] bool readTexture (const std::filesystem::path& path, TextureAsset& out);
124[[nodiscard]] bool readSkeleton (const std::filesystem::path& path, SkeletonAsset& out);
125[[nodiscard]] bool readAnimationClip(const std::filesystem::path& path, AnimationClipAsset& out);
126[[nodiscard]] bool readAudioClip (const std::filesystem::path& path, AudioClipAsset& out);
127
136[[nodiscard]] bool readTerrain(
137 const std::filesystem::path& path,
138 TerrainAsset& out,
139 TerrainFile::Names& names
140);
141
142} // namespace AssetCook
143
144} // namespace Vkm::Engine
Cooked binary asset format (derived cache).
Definition asset_cook.h:29
bool readMesh(const std::filesystem::path &path, MeshAsset &out)
Read one cooked file of each kind.
constexpr uint32_t MAX_SKELETON_BONES
Bone count past which a rig is refused as corrupt rather than read.
Definition asset_cook.h:59
bool writeTerrain(const std::filesystem::path &path, const TerrainAsset &terrain)
Cook terrain from its .terrain file (TerrainFile), the body copied once it reads soundly.
uint64_t cacheKey(uint64_t recipeHash, AssetType type)
The complete cache key for one cooked artifact.
constexpr uint32_t MAX_AUDIO_CHANNELS
Channel count past which a sound is refused as corrupt rather than read.
Definition asset_cook.h:66
bool writeMesh(const std::filesystem::path &path, const MeshAsset &mesh)
Write one cooked file of each kind.
constexpr uint32_t MAX_AUDIO_SAMPLE_RATE
Sample rate past which a clip is refused as corrupt rather than read.
Definition asset_cook.h:74
bool readTerrain(const std::filesystem::path &path, TerrainAsset &out, TerrainFile::Names &names)
Read a cooked terrain: its handles empty, what they name in names (TerrainFile::resolve).
bool isCookedCurrent(AssetType type, const std::filesystem::path &path)
Whether the cooked file at path can still serve type.
constexpr uint16_t COOKER_VERSION
Bump when anything the cooker writes changes: a kind's byte layout, an importer flag,...
Definition asset_cook.h:39
A terrain as bytes: the .terrain file the editor writes into a project, and the body of its cooked fi...
Definition asset_cook.h:17
A baked animation: every bone's keys, in six flat arrays.
Definition animation_clip_asset.h:50
A sound: fully decoded interleaved PCM, plus the rate and layout it was written at.
Definition audio_clip_asset.h:58
CPU-side geometry: indexed triangle mesh plus a cached local-space AABB.
Definition mesh_asset.h:51
A rig: a flat, parent-before-child bone array plus its bind pose.
Definition skeleton_asset.h:33
A terrain: a square grid of heights, the share of each of four materials painted at each grid vertex,...
Definition terrain_asset.h:54
What a body names, in the order resolve() reads it back.
Definition terrain_file.h:37
Texture asset combining Resource tracking with engine-level texture parameters.
Definition texture_asset.h:15