Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
ModelComponent.h
1/*
2Copyright (C) 2018,2019,2021,2022,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGAMES_MODELCOMPONENT_H
17#define AEONGAMES_MODELCOMPONENT_H
18#include <array>
19#include "aeongames/Component.hpp"
20#include "aeongames/ResourceId.hpp"
21#include "aeongames/BufferAccessor.hpp"
22
23namespace AeonGames
24{
25 class Node;
26 class Window;
27 class Buffer;
29 class ModelComponent final : public Component
30 {
31 public:
36 ~ModelComponent() final;
37 const StringId& GetId() const final;
38 size_t GetPropertyCount () const final;
39 const StringId* GetPropertyInfoArray () const final;
40 Property GetProperty ( const StringId& aId ) const final;
41 void SetProperty ( uint32_t, const Property& aProperty ) final;
42 void Update ( Node& aNode, double aDelta ) final;
43 void Render ( const Node& aNode, Renderer& aRenderer, void* aWindowId ) final;
44 void ProcessMessage ( Node& aNode, uint32_t aMessageType, const void* aMessageData ) final;
46
49
51 void SetModel ( const ResourceId& aModel );
53 const ResourceId& GetModel() const noexcept;
56 void SetActiveAnimation ( size_t aActiveAnimation ) noexcept;
58 const size_t& GetActiveAnimation() const noexcept;
61 void SetStartingFrame ( double aAnimationDelta ) noexcept;
63 const double& GetStartingFrame() const noexcept;
65
66 static const StringId& GetClassId();
67 private:
68 // Properties
69 ResourceId mModel{};
70 size_t mActiveAnimation{};
71 double mStartingFrame{};
72 // Private Data
73 double mCurrentSample{};
74 // 128 is the maximum number of bones per model
75 std::array<uint8_t, 16 * 128 * sizeof ( float ) > mSkeleton{};
76 };
77}
78#endif
Abstract interface for GPU/memory buffer operations.
Definition Buffer.hpp:24
Abstract base class for node components.
Definition Component.hpp:39
void Update(Node &aNode, double aDelta) final
Update the component state.
void SetModel(const ResourceId &aModel)
Sets the model resource.
size_t GetPropertyCount() const final
Get the number of properties exposed by this component.
void ProcessMessage(Node &aNode, uint32_t aMessageType, const void *aMessageData) final
Process an incoming message.
void SetProperty(uint32_t, const Property &aProperty) final
Set the value aProperty for the property identified by aId.
void SetActiveAnimation(size_t aActiveAnimation) noexcept
Sets the active animation index.
ModelComponent()
Default constructor.
void Render(const Node &aNode, Renderer &aRenderer, void *aWindowId) final
Render the component.
const ResourceId & GetModel() const noexcept
Returns the current model resource identifier.
void SetStartingFrame(double aAnimationDelta) noexcept
Sets the starting frame for the active animation.
Property GetProperty(const StringId &aId) const final
Get the value of a property.
static const StringId & GetClassId()
Returns the class identifier for the ModelComponent.
const double & GetStartingFrame() const noexcept
Returns the starting frame for the active animation.
const StringId * GetPropertyInfoArray() const final
Get the array of property identifiers.
const size_t & GetActiveAnimation() const noexcept
Returns the active animation index.
const StringId & GetId() const final
Get the unique identifier for this component type.
Scene graph node representing an entity in the game world.
Definition Node.hpp:54
Abstract base class for rendering backends.
Definition Renderer.hpp:44
Identifies a resource by its type and path CRC32 hashes.
CRC-based compile-time string identifier.
Definition StringId.hpp:31
<- This is here just for the literals
Definition AABB.hpp:31
std::variant< int, long, long long, unsigned, unsigned long, unsigned long long, float, double, std::string, std::filesystem::path > Property
A variant type that can hold any commonly used property value.
Definition Property.hpp:31