Implmented GLTF Compile and Load Overhaul #404
|
@ -20,11 +20,10 @@ namespace SHADE
|
|||
/* Constructors */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
SHAnimationClip::SHAnimationClip(const SHAnimAsset& asset)
|
||||
: ticksPerSecond { static_cast<int>(asset.ticksPerSecond) }
|
||||
, totalTime { static_cast<float>(asset.duration) / static_cast<int>(asset.ticksPerSecond) }
|
||||
{
|
||||
// Populate keyframes
|
||||
int channelIdx = 0;
|
||||
int maxFrames = 0;
|
||||
totalTime = 0.0f;
|
||||
for (const auto& channel : asset.nodeChannels)
|
||||
{
|
||||
// Create a channel
|
||||
|
@ -49,12 +48,18 @@ namespace SHADE
|
|||
|
||||
newChannel.MaxFrames = std::max({ newChannel.PositionKeyFrames.size(), newChannel.RotationKeyFrames.size(), newChannel.ScaleKeyFrames.size() });
|
||||
|
||||
// Compute max frames
|
||||
maxFrames = std::max(maxFrames, newChannel.MaxFrames);
|
||||
|
||||
// Compute total time
|
||||
totalTime = std::max({ totalTime, newChannel.PositionKeyFrames.back().TimeStamp, newChannel.RotationKeyFrames.back().TimeStamp, newChannel.ScaleKeyFrames.back().TimeStamp });
|
||||
|
||||
// Insert the channel
|
||||
channels.emplace_back(std::move(newChannel));
|
||||
|
||||
// Go to next channel
|
||||
++channelIdx;
|
||||
}
|
||||
|
||||
// Compute fps
|
||||
ticksPerSecond = static_cast<int>(maxFrames / totalTime);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in New Issue