Skylicht Engine
Loading...
Searching...
No Matches
CGradientBandInterpolation.h
1/*
2!@
3MIT License
4
5Copyright (c) 2024 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25// Reference:
26// https://github.com/runevision/LocomotionSystem/blob/master/Assets/Locomotion%20System%20Files/Locomotion%20System/PolarGradientBandInterpolator.cs
27// https://www.shadertoy.com/view/XlKXWR
28
29
30#pragma once
31
32namespace Skylicht
33{
58 class SKYLICHT_API CGradientBandInterpolation
59 {
60 public:
64 struct SSample
65 {
67 int Id;
68
70 core::vector3df Vector;
71
73 float Weight;
74
75 SSample()
76 {
77 Id = 0;
78 Weight = 0.0f;
79 }
80 };
81
82 protected:
84 core::array<SSample*> m_samples;
85
86 public:
87 CGradientBandInterpolation();
88
89 virtual ~CGradientBandInterpolation();
90
95 inline core::array<SSample*>& getSamples()
96 {
97 return m_samples;
98 }
99
106 SSample* addSample(int id, const core::vector3df& vector);
107
112 void removeSample(SSample* sample);
113
117 void clear();
118
125 void sampleWeightsPolar(const core::vector3df& vector);
126
133 void sampleWeightsCartesian(const core::vector3df& vector);
134 };
135}
void removeSample(SSample *sample)
Removes a specific animation sample.
void sampleWeightsPolar(const core::vector3df &vector)
Calculates blending weights using polar gradient band interpolation.
core::array< SSample * > & getSamples()
Gets the list of animation samples.
Definition CGradientBandInterpolation.h:95
void sampleWeightsCartesian(const core::vector3df &vector)
Calculates blending weights using Cartesian gradient band interpolation.
SSample * addSample(int id, const core::vector3df &vector)
Adds a new animation sample point.
void clear()
Removes all animation samples.
core::array< SSample * > m_samples
List of all animation samples.
Definition CGradientBandInterpolation.h:84
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
Represents an animation sample point with its associated weight.
Definition CGradientBandInterpolation.h:65
core::vector3df Vector
Position vector in parameter space.
Definition CGradientBandInterpolation.h:70
int Id
User-defined ID for the animation sample.
Definition CGradientBandInterpolation.h:67
float Weight
Calculated blending weight (0 to 1).
Definition CGradientBandInterpolation.h:73