Cogs.Core
AssetComponent.h
1#pragma once
2
3#include "Resources/Resources.h"
4
5#include "Foundation/ComponentModel/Component.h"
6
7namespace Cogs::Core
8{
9
11 enum class AssetFlags
12 {
13 None = 0,
14 InstantiateOnDemand = 1 << 0,
15 RelativePaths = 1 << 1,
16 OverrideMaterial = 1 << 2,
17 CloneMaterial = 1 << 4
18 };
19
20 ENABLE_ENUM_FLAGS(AssetFlags);
21
30 {
32 static void registerType();
33
35
36 AssetFlags flags = AssetFlags::None;
37
38 std::vector<uint32_t> idRanges;// = { 0, 0, 0, 0 };
39
40 float tolerance = 1.0f;
41 float minDistance = 1.f;
42 float priority = 0.0f;
43
44 bool freezeLod = false;
45 bool forceTolerance = false;
46
48 };
49
52 enum struct AssetResourceType : uint32_t
53 {
54 Asset,
55 Model
56 };
57
58 [[nodiscard]] COGSCORE_DLL_API std::string createAssetResourcePathFromIndex(uint32_t resourceIndex, AssetResourceType assetResourceType);
59
60}
61
62template<> inline Cogs::StringView getName<Cogs::Core::AssetFlags>() { return "AssetFlags"; }
63template<> inline Cogs::StringView getName<Cogs::Core::AssetComponent>() { return "AssetComponent"; }
Base class for Component instances.
Definition: Component.h:143
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
AssetResourceType
Utility function to format a resource index as a filename.
AssetFlags
Controls asset system's model instance behaviour.
@ InstantiateOnDemand
Dynamically calculate lod levels and only instantiate what is visible.
@ RelativePaths
Paths in asset file is relative to file's path.
@ OverrideMaterial
Override any model's material with material member of asset component.
@ CloneMaterial
Clone the assetComponent material over any loaded models's material and copy over properties and vari...
Instantiates an asset model into the scene.
AssetHandle asset
Asset resource that should be instantiated.
static void registerType()
Register the type in the type system.
bool freezeLod
Temporarily disable adjustment of target lod-level, debug tool to allow moving the camera without aff...
float minDistance
Minimum distance to use when scaling the tolerance.
bool forceTolerance
Disable adjustment of tolerance due to quality system or resource usage.
MaterialInstanceHandle material
Material to use for models if the OverrideMaterial flag is set.
float priority
Used to sort requests, higher number gets processed before lower number.
AssetFlags flags
Flags to control behaviour of asset instantiation.
float tolerance
Tolerance scale factor to use when determining lod levels, see AssetComponent's documentation.
Model resources define a template for a set of connected entities, with resources such as meshes,...
Definition: Model.h:56
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.