VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
skeleton.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3#pragma once
4
5#include <string>
6#include <unordered_map>
7#include <vector>
8
9#include "animation.h"
10#include "scene/graphNode.h"
11
12namespace visutwin::canvas
13{
15 {
16 public:
17 bool written = false;
18 std::string name;
22
23 GraphNode* getTarget() const { return _targetNode; }
24 void setTarget(GraphNode* node) { _targetNode = node; }
25
26 private:
27 GraphNode* _targetNode = nullptr;
28 };
29
31 {
32 public:
33 explicit Skeleton(GraphNode* graph);
34
35 void setAnimation(Animation* value);
36 Animation* animation() const { return _animation; }
37
38 void setCurrentTime(float value);
39 float currentTime() const { return _time; }
40
41 int numNodes() const { return static_cast<int>(_interpolatedKeys.size()); }
42
43 void addTime(float delta);
44 void blend(const Skeleton* skel1, const Skeleton* skel2, float alpha);
45 void setGraph(GraphNode* graph);
46 void updateGraph();
47
48 void setLooping(bool value) { _looping = value; }
49 bool looping() const { return _looping; }
50
51 private:
52 bool _looping = true;
53
54 Animation* _animation = nullptr;
55 float _time = 0.0f;
56
57 std::vector<InterpolatedKey> _interpolatedKeys;
58 std::unordered_map<std::string, size_t> _interpolatedKeyDict;
59 std::unordered_map<std::string, int> _currKeyIndices;
60
61 GraphNode* _graph = nullptr;
62
63 static Vector3 lerpVec3(const Vector3& a, const Vector3& b, float alpha);
64 static Quaternion slerpQuat(const Quaternion& a, const Quaternion& b, float alpha);
65 };
66}
Hierarchical scene graph node with local/world transforms and parent-child relationships.
Definition graphNode.h:28
void setTarget(GraphNode *node)
Definition skeleton.h:24
GraphNode * getTarget() const
Definition skeleton.h:23
float currentTime() const
Definition skeleton.h:39
void blend(const Skeleton *skel1, const Skeleton *skel2, float alpha)
Definition skeleton.cpp:176
void setGraph(GraphNode *graph)
Definition skeleton.cpp:207
void setLooping(bool value)
Definition skeleton.h:48
Animation * animation() const
Definition skeleton.h:36
Skeleton(GraphNode *graph)
Definition skeleton.cpp:33
void addTime(float delta)
Definition skeleton.cpp:103
void setAnimation(Animation *value)
Definition skeleton.cpp:38
void setCurrentTime(float value)
Definition skeleton.cpp:44
Unit quaternion for rotation representation with SIMD-accelerated slerp and multiply.
Definition quaternion.h:20
3D vector for positions, directions, and normals with multi-backend SIMD acceleration.
Definition vector3.h:29