Former-commit-id: 834097e149f393c278e47ff31c8c4d12b0628d2b [formerly 5eb47a1c307a874555e07106b0d484ecc0958345] [formerly fab49feb40dbc3bfdc959659ff74a6d3a2b59606 [formerly a2be53055f8fb8123035e145ea2edb0043d780e2]] Former-commit-id: d44f84cccad74434dc02a97a2a9b7a72dca49f5c [formerly d21b193e02096275d145af82ca4468f67ce1f74c] Former-commit-id: 618d73318ca6c9ad86b091312858b38024b3a5e0
113 lines
3.5 KiB
C++
113 lines
3.5 KiB
C++
// Copyright (C) 2015 Jérôme Leclercq
|
|
// This file is part of the "Nazara Engine - Utility module"
|
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
|
|
|
#pragma once
|
|
|
|
#ifndef NAZARA_ANIMATION_HPP
|
|
#define NAZARA_ANIMATION_HPP
|
|
|
|
#include <Nazara/Prerequesites.hpp>
|
|
#include <Nazara/Core/ObjectLibrary.hpp>
|
|
#include <Nazara/Core/ObjectRef.hpp>
|
|
#include <Nazara/Core/RefCounted.hpp>
|
|
#include <Nazara/Core/Resource.hpp>
|
|
#include <Nazara/Core/ResourceLoader.hpp>
|
|
#include <Nazara/Core/ResourceManager.hpp>
|
|
#include <Nazara/Core/ResourceParameters.hpp>
|
|
#include <Nazara/Core/Signal.hpp>
|
|
#include <Nazara/Core/String.hpp>
|
|
#include <Nazara/Utility/Config.hpp>
|
|
#include <Nazara/Utility/Enums.hpp>
|
|
#include <Nazara/Utility/Sequence.hpp>
|
|
|
|
namespace Nz
|
|
{
|
|
struct NAZARA_UTILITY_API AnimationParams : ResourceParameters
|
|
{
|
|
// La frame de fin à charger
|
|
UInt32 endFrame = 0xFFFFFFFF;
|
|
// La frame de début à charger
|
|
UInt32 startFrame = 0;
|
|
|
|
bool IsValid() const;
|
|
};
|
|
|
|
class Animation;
|
|
class Skeleton;
|
|
|
|
using AnimationConstRef = ObjectRef<const Animation>;
|
|
using AnimationLibrary = ObjectLibrary<Animation>;
|
|
using AnimationLoader = ResourceLoader<Animation, AnimationParams>;
|
|
using AnimationManager = ResourceManager<Animation, AnimationParams>;
|
|
using AnimationRef = ObjectRef<Animation>;
|
|
|
|
struct AnimationImpl;
|
|
|
|
class NAZARA_UTILITY_API Animation : public RefCounted, public Resource
|
|
{
|
|
friend AnimationLibrary;
|
|
friend AnimationLoader;
|
|
friend AnimationManager;
|
|
friend class Utility;
|
|
|
|
public:
|
|
Animation() = default;
|
|
~Animation();
|
|
|
|
bool AddSequence(const Sequence& sequence);
|
|
void AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const;
|
|
|
|
bool CreateSkeletal(UInt32 frameCount, UInt32 jointCount);
|
|
void Destroy();
|
|
|
|
void EnableLoopPointInterpolation(bool loopPointInterpolation);
|
|
|
|
UInt32 GetFrameCount() const;
|
|
UInt32 GetJointCount() const;
|
|
Sequence* GetSequence(const String& sequenceName);
|
|
Sequence* GetSequence(UInt32 index);
|
|
const Sequence* GetSequence(const String& sequenceName) const;
|
|
const Sequence* GetSequence(UInt32 index) const;
|
|
UInt32 GetSequenceCount() const;
|
|
UInt32 GetSequenceIndex(const String& sequenceName) const;
|
|
SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0);
|
|
const SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0) const;
|
|
AnimationType GetType() const;
|
|
|
|
bool HasSequence(const String& sequenceName) const;
|
|
bool HasSequence(UInt32 index = 0) const;
|
|
|
|
bool IsLoopPointInterpolationEnabled() const;
|
|
bool IsValid() const;
|
|
|
|
bool LoadFromFile(const String& filePath, const AnimationParams& params = AnimationParams());
|
|
bool LoadFromMemory(const void* data, std::size_t size, const AnimationParams& params = AnimationParams());
|
|
bool LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams());
|
|
|
|
void RemoveSequence(const String& sequenceName);
|
|
void RemoveSequence(UInt32 index);
|
|
|
|
template<typename... Args> static AnimationRef New(Args&&... args);
|
|
|
|
// Signals:
|
|
NazaraSignal(OnAnimationDestroy, const Animation* /*animation*/);
|
|
NazaraSignal(OnAnimationRelease, const Animation* /*animation*/);
|
|
|
|
private:
|
|
static bool Initialize();
|
|
static void Uninitialize();
|
|
|
|
AnimationImpl* m_impl = nullptr;
|
|
|
|
static AnimationLibrary::LibraryMap s_library;
|
|
static AnimationLoader::LoaderList s_loaders;
|
|
static AnimationManager::ManagerMap s_managerMap;
|
|
static AnimationManager::ManagerParams s_managerParameters;
|
|
};
|
|
}
|
|
|
|
#include <Nazara/Utility/Animation.inl>
|
|
|
|
#endif // NAZARA_ANIMATION_HPP
|