Files
NazaraEngine/include/Nazara/Utility/Animation.hpp
Lynix 8f9ea9db17 Added ResourceListenerWrapper
This class wraps the call to
Resource::AddResourceListener/RemoveResourceListener using RAII and help
a lot with some of the dependencies.
Thanks to this, the render queues now handle their resources listening
properly.

Former-commit-id: 7f215ffa4ccadcc4f44f777656970e92ce01087a
2015-01-18 23:59:01 +01:00

89 lines
2.9 KiB
C++

// Copyright (C) 2014 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/Resource.hpp>
#include <Nazara/Core/ResourceListenerWrapper.hpp>
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceRef.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/Sequence.hpp>
#include <limits>
struct NAZARA_API NzAnimationParams
{
// La frame de fin à charger
unsigned int endFrame = std::numeric_limits<unsigned int>::max();
// La frame de début à charger
unsigned int startFrame = 0;
bool IsValid() const;
};
class NzAnimation;
class NzSkeleton;
using NzAnimationConstListener = NzResourceListenerWrapper<const NzAnimation>;
using NzAnimationConstRef = NzResourceRef<const NzAnimation>;
using NzAnimationListener = NzResourceListenerWrapper<NzAnimation>;
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
using NzAnimationRef = NzResourceRef<NzAnimation>;
struct NzAnimationImpl;
class NAZARA_API NzAnimation : public NzResource
{
friend NzAnimationLoader;
public:
NzAnimation() = default;
~NzAnimation();
bool AddSequence(const NzSequence& sequence);
void AnimateSkeleton(NzSkeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const;
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
void Destroy();
void EnableLoopPointInterpolation(bool loopPointInterpolation);
unsigned int GetFrameCount() const;
unsigned int GetJointCount() const;
NzSequence* GetSequence(const NzString& sequenceName);
NzSequence* GetSequence(unsigned int index);
const NzSequence* GetSequence(const NzString& sequenceName) const;
const NzSequence* GetSequence(unsigned int index) const;
unsigned int GetSequenceCount() const;
int GetSequenceIndex(const NzString& sequenceName) const;
NzSequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0);
const NzSequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const;
nzAnimationType GetType() const;
bool HasSequence(const NzString& sequenceName) const;
bool HasSequence(unsigned int index = 0) const;
bool IsLoopPointInterpolationEnabled() const;
bool IsValid() const;
bool LoadFromFile(const NzString& filePath, const NzAnimationParams& params = NzAnimationParams());
bool LoadFromMemory(const void* data, std::size_t size, const NzAnimationParams& params = NzAnimationParams());
bool LoadFromStream(NzInputStream& stream, const NzAnimationParams& params = NzAnimationParams());
void RemoveSequence(const NzString& sequenceName);
void RemoveSequence(unsigned int index);
private:
NzAnimationImpl* m_impl = nullptr;
static NzAnimationLoader::LoaderList s_loaders;
};
#endif // NAZARA_ANIMATION_HPP