Merge remote-tracking branch 'upstream/master'
Former-commit-id: 578dd5a3b02eb5363a248c437b528a743be983ca
This commit is contained in:
36
include/Nazara/Graphics/SkinningManager.hpp
Normal file
36
include/Nazara/Graphics/SkinningManager.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SKINNINGMANAGER_HPP
|
||||
#define NAZARA_SKINNINGMANAGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzSkeleton;
|
||||
class NzSkeletalMesh;
|
||||
class NzVertexBuffer;
|
||||
|
||||
class NAZARA_API NzSkinningManager
|
||||
{
|
||||
friend class NzGraphics;
|
||||
|
||||
public:
|
||||
using SkinFunction = void (*)(const NzSkeletalMesh* mesh, const NzSkeleton* skeleton, NzVertexBuffer* buffer);
|
||||
|
||||
NzSkinningManager() = delete;
|
||||
~NzSkinningManager() = delete;
|
||||
|
||||
static NzVertexBuffer* GetBuffer(const NzSkeletalMesh* mesh, const NzSkeleton* skeleton);
|
||||
static void Skin();
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
static SkinFunction s_skinFunc;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SKINNINGMANAGER_HPP
|
||||
@@ -14,6 +14,16 @@
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/IndexIterator.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/SkeletalMesh.hpp>
|
||||
|
||||
struct NzSkinningData
|
||||
{
|
||||
const NzJoint* joints;
|
||||
const NzMeshVertex* inputVertex;
|
||||
NzMeshVertex* outputVertex;
|
||||
const NzVertexWeight* vertexWeights;
|
||||
const NzWeight* weights;
|
||||
};
|
||||
|
||||
NAZARA_API void NzComputeBoxIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API unsigned int NzComputeCacheMissCount(NzIndexIterator indices, unsigned int indexCount);
|
||||
@@ -33,6 +43,10 @@ NAZARA_API void NzGenerateUvSphere(float size, unsigned int sliceCount, unsigned
|
||||
|
||||
NAZARA_API void NzOptimizeIndices(NzIndexIterator indices, unsigned int indexCount);
|
||||
|
||||
NAZARA_API void NzSkinPosition(const NzSkinningData& data, unsigned int startVertex, unsigned int vertexCount);
|
||||
NAZARA_API void NzSkinPositionNormal(const NzSkinningData& data, unsigned int startVertex, unsigned int vertexCount);
|
||||
NAZARA_API void NzSkinPositionNormalTangent(const NzSkinningData& data, unsigned int startVertex, unsigned int vertexCount);
|
||||
|
||||
template<typename T> void NzTransformVertices(T* vertices, unsigned int vertexCount, const NzMatrix4f& matrix);
|
||||
|
||||
#include <Nazara/Utility/Algorithm.inl>
|
||||
|
||||
@@ -21,18 +21,26 @@ class NAZARA_API NzJoint : public NzNode
|
||||
NzJoint(const NzJoint& joint);
|
||||
~NzJoint() = default;
|
||||
|
||||
NzMatrix4f GetInverseBindMatrix() const;
|
||||
void EnsureSkinningMatrixUpdate() const;
|
||||
|
||||
const NzMatrix4f& GetInverseBindMatrix() const;
|
||||
NzString GetName() const;
|
||||
NzSkeleton* GetSkeleton();
|
||||
const NzSkeleton* GetSkeleton() const;
|
||||
const NzMatrix4f& GetSkinningMatrix() const;
|
||||
|
||||
void SetInverseBindMatrix(const NzMatrix4f& matrix);
|
||||
void SetName(const NzString& name);
|
||||
|
||||
private:
|
||||
void InvalidateNode();
|
||||
void UpdateSkinningMatrix() const;
|
||||
|
||||
NzMatrix4f m_inverseBindMatrix;
|
||||
mutable NzMatrix4f m_skinningMatrix;
|
||||
NzString m_name;
|
||||
NzSkeleton* m_skeleton;
|
||||
mutable bool m_skinningMatrixUpdated;
|
||||
};
|
||||
|
||||
#endif // NAZARA_JOINT_HPP
|
||||
|
||||
@@ -55,9 +55,6 @@ class NAZARA_API NzSkeletalMesh final : public NzSubMesh
|
||||
bool IsAnimated() const final;
|
||||
bool IsValid() const;
|
||||
|
||||
void Skin(NzMeshVertex* outputBuffer) const;
|
||||
void Skin(NzMeshVertex* outputBuffer, const NzSkeleton* skeleton) const;
|
||||
|
||||
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user