Big skeletal animation update

Added MeshInfos demo
Added MD5Mesh/MD5Anim loader support
Added Node class
Fixed ResourceParams not being exported
Added support for skeletal animation
(Animation/Mesh/Joint/SkeletalMesh/Skeleton)
Meshes are now only stored with VertexStruct_XYZ_Normal_UV_Tangent type
Moved Sequence declaration to Sequence.hpp

-Animation:
Renamed Create to Create[Keyframe|Skeletal]

-AxisAlignedBox:
Added Contains method
Added GetCorner method
Added GetCube method
Added Transform method

-Cube/Rect:
Added GetPosition method
Added GetSize method
(Almost) Fixed ExtendTo method
Fixed GetCenter method

-File:
Added GetDirectory static function
Added GetPath method
Renamed GetDirectoryPath method to GetDirectory

-Math module:
Fixed constructor/methods taking a non-const array
GetNormal/Normalize methods now takes an optionnal integer pointer
(returning length)
Made all classes default constructor trivial
Inverse, MakeIdentity, MakeZero, Normalize, Set methods now returns
reference to object

-Matrix4:
Modified methods to avoid copies
Removed COW (Too much overhead)
Removed Concatenate[Affine] static function

-Mesh:
Renamed Create to Create[Keyframe|Skeletal|Static]
Renamed Skin to Material

-MeshParams:
No longer takes declaration argument
Renamed loadAnimations to animated
Storage default to BufferStorage_Hardware if supported and
BufferStorage_Software otherwise

-OpenGL:
Added glGetBooleanv function
Added glIsEnabled function

-Quaternion:
Added ComputeW method
Added Conjugate method

-Renderer:
Added IsEnabled static function
Fixed GetLineWidth function not being static
Removed SetVertexDeclaration

-RenderWindow:
Made CopyTo[Image|Texture] method constant

-Resource
Fixed RemoveResourceListener crash

-ResourceLoader:
Loaders are now used in a LIFO context

-Stream:
Renamed GetLine method to ReadLine

-String:
Fixed Simplified

-Utility module
Added configuration define for strict resource parsing

-VertexBuffer
Now takes a VertexDeclaration pointer

-VertexDeclaration
No longer throw an error when getting a non-existing element


Former-commit-id: f7358c1231d6af48b799d2f24f077a001e16785b
This commit is contained in:
Lynix
2012-11-21 17:23:50 +01:00
parent 84f73f2b6a
commit 70ef422950
99 changed files with 6270 additions and 1983 deletions

View File

@@ -12,8 +12,9 @@
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/Sequence.hpp>
struct NzAnimationParams
struct NAZARA_API NzAnimationParams
{
unsigned int endFrame = static_cast<unsigned int>(-1);
unsigned int startFrame = 0;
@@ -21,15 +22,8 @@ struct NzAnimationParams
bool IsValid() const;
};
struct NzSequence
{
NzString name;
unsigned int firstFrame;
unsigned int lastFrame;
unsigned int framePerSecond;
};
class NzAnimation;
class NzSkeleton;
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
@@ -44,8 +38,10 @@ class NAZARA_API NzAnimation : public NzResource
~NzAnimation();
bool AddSequence(const NzSequence& sequence);
void AnimateSkeleton(NzSkeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const;
bool Create(nzAnimationType type, unsigned int frameCount);
bool CreateKeyframe(unsigned int frameCount);
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
void Destroy();
unsigned int GetFrameCount() const;
@@ -55,6 +51,8 @@ class NAZARA_API NzAnimation : public NzResource
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;

View File

@@ -8,6 +8,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Cube.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/Enums.hpp>
@@ -20,10 +21,13 @@ class NAZARA_API NzAxisAlignedBox
NzAxisAlignedBox(nzExtend extend);
bool Contains(const NzAxisAlignedBox& box);
bool Contains(const NzVector3f& vector);
void ExtendTo(const NzAxisAlignedBox& box);
void ExtendTo(const NzVector3f& vector);
NzVector3f GetCorner(nzCorner corner) const;
NzCubef GetCube() const;
nzExtend GetExtend() const;
NzVector3f GetMaximum() const;
NzVector3f GetMinimum() const;
@@ -38,6 +42,8 @@ class NAZARA_API NzAxisAlignedBox
NzString ToString() const;
void Transform(const NzMatrix4f& matrix);
operator NzString() const;
static NzAxisAlignedBox Lerp(const NzAxisAlignedBox& from, const NzAxisAlignedBox& to, float interpolation);

View File

@@ -38,8 +38,11 @@
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_UTILITY_SAFE 1
// Lors du parsage d'une ressource, déclenche un avertissement si une erreur non-critique est repérée dans une ressource (Plus lent)
#define NAZARA_UTILITY_STRICT_RESOURCE_PARSING 1
// Fait tourner chaque fenêtre dans un thread séparé si le système le supporte
#define NAZARA_UTILITY_THREADED_WINDOW 0 ///FIXME: Buggé depuis GCC 4.7
#define NAZARA_UTILITY_THREADED_WINDOW 0 ///FIXME: Buggé depuis GCC 4.7 avec certains ordinateurs
// Protège les classes des accès concurrentiels
#define NAZARA_UTILITY_THREADSAFE 1

View File

@@ -51,6 +51,28 @@ enum nzBufferUsage
nzBufferUsage_Max = nzBufferUsage_Static
};
enum nzCoordSys
{
nzCoordSys_Global,
nzCoordSys_Local,
nzCoordSys_Max = nzCoordSys_Local
};
enum nzCorner
{
nzCorner_FarLeftBottom,
nzCorner_FarLeftTop,
nzCorner_FarRightBottom,
nzCorner_FarRightTop,
nzCorner_NearLeftBottom,
nzCorner_NearLeftTop,
nzCorner_NearRightBottom,
nzCorner_NearRightTop,
nzCorner_Max = nzCorner_FarRightTop
};
enum nzCubemapFace
{
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap

View File

@@ -26,7 +26,7 @@
///TODO: Filtres
struct NzImageParams
struct NAZARA_API NzImageParams
{
nzPixelFormat loadFormat = nzPixelFormat_Undefined;
nzUInt8 levelCount = 0;

View File

@@ -0,0 +1,38 @@
// Copyright (C) 2012 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_JOINT_HPP
#define NAZARA_JOINT_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Utility/Node.hpp>
class NzSkeleton;
class NAZARA_API NzJoint : public NzNode
{
public:
NzJoint(NzSkeleton* skeleton);
NzJoint(const NzJoint& joint);
~NzJoint() = default;
NzMatrix4f GetInverseBindMatrix() const;
NzString GetName() const;
NzSkeleton* GetSkeleton();
const NzSkeleton* GetSkeleton() const;
void SetInverseBindMatrix(const NzMatrix4f& matrix);
void SetName(const NzString& name);
private:
NzMatrix4f m_inverseBindMatrix;
NzString m_name;
NzSkeleton* m_skeleton;
};
#endif // NAZARA_JOINT_HPP

View File

@@ -8,15 +8,48 @@
#define NAZARA_KEYFRAMEMESH_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Mesh.hpp>
#include <Nazara/Utility/SubMesh.hpp>
class NzMesh;
struct NzKeyframeMeshImpl;
class NAZARA_API NzKeyframeMesh : public NzSubMesh
class NAZARA_API NzKeyframeMesh final : public NzSubMesh
{
friend NzMesh;
public:
NzKeyframeMesh(const NzMesh* parent);
virtual ~NzKeyframeMesh();
bool Create(NzVertexBuffer* vertexBuffer, unsigned int frameCount, bool lock = true);
void Destroy();
void Finish();
const NzAxisAlignedBox& GetAABB() const override;
nzAnimationType GetAnimationType() const override;
unsigned int GetFrameCount() const;
const NzIndexBuffer* GetIndexBuffer() const override;
bool GetVertex(NzMeshVertex* dest, unsigned int frameIndex, unsigned int vertexIndex, bool queryUV = true) const;
const NzVertexBuffer* GetVertexBuffer() const override;
void Interpolate(unsigned int frameA, unsigned int frameB, float interpolation);
bool IsAnimated() const override;
bool IsValid();
bool Lock(nzBufferAccess access) const;
void SetAABB(unsigned int frameIndex, const NzAxisAlignedBox& aabb);
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
bool SetVertex(const NzMeshVertex& source, unsigned int frameIndex, unsigned int vertexIndex, bool setUV = true);
void Unlock() const;
private:
void InterpolateImpl(unsigned int frameA, unsigned int frameB, float interpolation);
NzKeyframeMeshImpl* m_impl = nullptr;
};
#endif // NAZARA_KEYFRAMEMESH_HPP

View File

@@ -15,22 +15,27 @@
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Animation.hpp>
#include <Nazara/Utility/AxisAlignedBox.hpp>
#include <Nazara/Utility/Skeleton.hpp>
#include <Nazara/Utility/SubMesh.hpp>
#include <Nazara/Utility/VertexStruct.hpp>
class NzVertexDeclaration;
struct NzMeshParams
struct NAZARA_API NzMeshParams
{
NzMeshParams(); // Vérifie que le storage indiqué un peu plus bas est supporté
NzAnimationParams animation;
//const NzVertexDeclaration* declaration = nullptr;
nzBufferStorage storage = nzBufferStorage_Hardware;
bool loadAnimations = true;
bool animated = true;
bool IsValid() const;
};
class NzMesh;
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
struct NzMeshImpl;
@@ -43,21 +48,26 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
NzMesh() = default;
~NzMesh();
bool AddSkin(const NzString& skin, bool setDefault = false);
bool AddMaterial(const NzString& matPath, unsigned int* matIndex = nullptr);
bool AddSubMesh(NzSubMesh* subMesh);
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
bool Create(nzAnimationType type);
bool CreateKeyframe();
bool CreateSkeletal(unsigned int jointCount);
bool CreateStatic();
void Destroy();
const NzAxisAlignedBox& GetAABB() const;
const NzAnimation* GetAnimation() const;
nzAnimationType GetAnimationType() const;
unsigned int GetFrameCount() const;
NzString GetSkin(unsigned int index = 0) const;
unsigned int GetSkinCount() const;
unsigned int GetJointCount() const;
NzString GetMaterial(unsigned int index) const;
unsigned int GetMaterialCount() const;
NzSkeleton* GetSkeleton();
const NzSkeleton* GetSkeleton() const;
NzSubMesh* GetSubMesh(const NzString& identifier);
NzSubMesh* GetSubMesh(unsigned int index);
const NzSubMesh* GetSubMesh(const NzString& identifier) const;
@@ -67,7 +77,7 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
unsigned int GetVertexCount() const;
bool HasAnimation() const;
bool HasSkin(unsigned int index = 0) const;
bool HasMaterial(unsigned int index) const;
bool HasSubMesh(const NzString& identifier) const;
bool HasSubMesh(unsigned int index = 0) const;
@@ -80,11 +90,14 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
bool LoadFromMemory(const void* data, std::size_t size, const NzMeshParams& params = NzMeshParams());
bool LoadFromStream(NzInputStream& stream, const NzMeshParams& params = NzMeshParams());
void RemoveSkin(unsigned int index = 0);
void RemoveMaterial(unsigned int index);
void RemoveSubMesh(const NzString& identifier);
void RemoveSubMesh(unsigned int index = 0);
void RemoveSubMesh(unsigned int index);
bool SetAnimation(const NzAnimation* animation);
void Skin(const NzSkeleton* skeleton);
static const NzVertexDeclaration* GetDeclaration();
private:
void OnResourceCreated(const NzResource* resource, int index) override;

View File

@@ -0,0 +1,85 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_NODE_HPP
#define NAZARA_NODE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <set>
class NAZARA_API NzNode
{
public:
NzNode();
NzNode(const NzNode& node);
virtual ~NzNode();
NzQuaternionf GetDerivedRotation() const;
NzVector3f GetDerivedScale() const;
NzVector3f GetDerivedTranslation() const;
bool GetInheritRotation() const;
bool GetInheritScale() const;
bool GetInheritTranslation() const;
const NzNode* GetParent() const;
NzQuaternionf GetRotation() const;
NzVector3f GetScale() const;
NzVector3f GetTranslation() const;
NzMatrix4f GetTransformMatrix() const;
NzNode& Interpolate(const NzNode& nodeA, const NzNode& nodeB, float interpolation);
NzNode& Rotate(const NzQuaternionf& rotation, nzCoordSys coordSys = nzCoordSys_Local);
NzNode& Scale(const NzVector3f& scale);
NzNode& Scale(float scale);
NzNode& Scale(float scaleX, float scaleY, float scaleZ);
NzNode& Translate(const NzVector3f& movement, nzCoordSys coordSys = nzCoordSys_Local);
NzNode& Translate(float movementX, float movementY, float movementZ, nzCoordSys coordSys = nzCoordSys_Local);
void SetInheritRotation(bool inheritRotation);
void SetInheritScale(bool inheritScale);
void SetInheritTranslation(bool inheritTranslation);
void SetParent(const NzNode* node = nullptr);
void SetParent(const NzNode& node);
void SetRotation(const NzQuaternionf& quat, nzCoordSys coordSys = nzCoordSys_Local);
void SetScale(const NzVector3f& scale, nzCoordSys coordSys = nzCoordSys_Local);
void SetScale(float scale, nzCoordSys coordSys = nzCoordSys_Local);
void SetScale(float scaleX, float scaleY, float scaleZ, nzCoordSys coordSys = nzCoordSys_Local);
void SetTranslation(const NzVector3f& translation, nzCoordSys coordSys = nzCoordSys_Local);
void SetTranslation(float translationX, float translationXY, float translationZ, nzCoordSys coordSys = nzCoordSys_Local);
NzNode& operator=(const NzNode& node);
protected:
void AddChild(NzNode* node) const;
void Invalidate();
void RemoveChild(NzNode* node) const;
void UpdateDerived() const;
virtual void UpdateMatrix() const;
mutable std::set<NzNode*> m_childs;
mutable NzMatrix4f m_transformMatrix;
mutable NzQuaternionf m_derivedRotation;
NzQuaternionf m_rotation;
NzString m_name;
mutable NzVector3f m_derivedTranslation;
mutable NzVector3f m_derivedScale;
NzVector3f m_scale;
NzVector3f m_translation;
const NzNode* m_parent;
mutable bool m_derivedUpdated;
bool m_inheritRotation;
bool m_inheritScale;
bool m_inheritTranslation;
mutable bool m_matrixUpdated;
};
#endif // NAZARA_NODE_HPP

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2012 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_SEQUENCE_HPP
#define NAZARA_SEQUENCE_HPP
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
struct NzSequence
{
NzString name;
unsigned int firstFrame;
unsigned int frameCount;
unsigned int frameRate;
};
struct NzSequenceJoint
{
NzQuaternionf rotation;
NzVector3f scale;
NzVector3f translation;
};
#endif // NAZARA_SEQUENCE_HPP

View File

@@ -0,0 +1,62 @@
// Copyright (C) 2012 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_SKELETALMESH_HPP
#define NAZARA_SKELETALMESH_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Mesh.hpp>
#include <Nazara/Utility/SubMesh.hpp>
class NzSkeleton;
struct NzVertexWeight
{
std::vector<unsigned int> weights;
};
struct NzWeight
{
float weight;
unsigned int jointIndex;
};
struct NzSkeletalMeshImpl;
class NAZARA_API NzSkeletalMesh final : public NzSubMesh
{
public:
NzSkeletalMesh(const NzMesh* parent);
virtual ~NzSkeletalMesh();
bool Create(NzVertexBuffer* vertexBuffer, unsigned int weightCount);
void Destroy();
const NzAxisAlignedBox& GetAABB() const;
nzAnimationType GetAnimationType() const final;
void* GetBindPoseBuffer();
const void* GetBindPoseBuffer() const;
const NzIndexBuffer* GetIndexBuffer() const override;
const NzVertexBuffer* GetVertexBuffer() const override;
NzVertexWeight* GetVertexWeight(unsigned int vertexIndex = 0);
const NzVertexWeight* GetVertexWeight(unsigned int vertexIndex = 0) const;
NzWeight* GetWeight(unsigned int weightIndex = 0);
const NzWeight* GetWeight(unsigned int weightIndex = 0) const;
unsigned int GetWeightCount() const;
bool IsAnimated() const final;
bool IsValid() const;
void Skin();
void Skin(const NzSkeleton* skeleton);
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
private:
NzSkeletalMeshImpl* m_impl = nullptr;
};
#endif // NAZARA_SKELETALMESH_HPP

View File

@@ -0,0 +1,53 @@
// Copyright (C) 2012 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_SKELETON_HPP
#define NAZARA_SKELETON_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/AxisAlignedBox.hpp>
#include <Nazara/Utility/Joint.hpp>
#include <vector>
struct NzSkeletonImpl;
class NAZARA_API NzSkeleton
{
friend NzJoint;
public:
NzSkeleton() = default;
NzSkeleton(const NzSkeleton& skeleton);
~NzSkeleton();
bool Create(unsigned int jointCount);
void Destroy();
const NzAxisAlignedBox& GetAABB() const;
NzJoint* GetJoint(const NzString& jointName);
NzJoint* GetJoint(unsigned int index);
const NzJoint* GetJoint(const NzString& jointName) const;
const NzJoint* GetJoint(unsigned int index) const;
NzJoint* GetJoints();
const NzJoint* GetJoints() const;
unsigned int GetJointCount() const;
int GetJointIndex(const NzString& jointName) const;
void Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skeletonB, float interpolation);
void Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount);
bool IsValid() const;
NzSkeleton& operator=(const NzSkeleton& skeleton);
private:
void InvalidateJointMap();
void UpdateJointMap() const;
NzSkeletonImpl* m_impl = nullptr;
};
#endif // NAZARA_SKELETON_HPP

View File

@@ -15,37 +15,30 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
{
public:
NzStaticMesh(const NzMesh* parent);
NzStaticMesh(const NzMesh* parent, const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
virtual ~NzStaticMesh();
bool Create(const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
bool Create(NzVertexBuffer* vertexBuffer);
void Destroy();
bool GenerateAABB();
const NzAxisAlignedBox& GetAABB() const;
nzAnimationType GetAnimationType() const;
unsigned int GetFrameCount() const;
const NzIndexBuffer* GetIndexBuffer() const;
nzPrimitiveType GetPrimitiveType() const;
const NzVertexBuffer* GetVertexBuffer() const;
const NzVertexDeclaration* GetVertexDeclaration() const;
const NzAxisAlignedBox& GetAABB() const override;
nzAnimationType GetAnimationType() const final;
const NzIndexBuffer* GetIndexBuffer() const override;
const NzVertexBuffer* GetVertexBuffer() const override;
bool IsAnimated() const;
bool IsAnimated() const final;
bool IsValid() const;
void SetAABB(const NzAxisAlignedBox& aabb);
void SetPrimitiveType(nzPrimitiveType primitiveType);
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
private:
void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation);
void OnResourceReleased(const NzResource* resource, int index) override;
nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList;
NzAxisAlignedBox m_aabb;
NzIndexBuffer* m_indexBuffer = nullptr;
const NzIndexBuffer* m_indexBuffer = nullptr;
NzVertexBuffer* m_vertexBuffer = nullptr;
const NzVertexDeclaration* m_vertexDeclaration = nullptr;
};
#endif // NAZARA_STATICMESH_HPP

View File

@@ -19,26 +19,30 @@ class NzMesh;
class NAZARA_API NzSubMesh : public NzResource
{
friend class NzMesh;
friend NzMesh;
public:
NzSubMesh(const NzMesh* parent);
virtual ~NzSubMesh();
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
virtual const NzAxisAlignedBox& GetAABB() const = 0;
virtual nzAnimationType GetAnimationType() const = 0;
virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
const NzMesh* GetParent() const;
virtual nzPrimitiveType GetPrimitiveType() const = 0;
nzPrimitiveType GetPrimitiveType() const;
unsigned int GetSkinIndex() const;
virtual const NzVertexBuffer* GetVertexBuffer() const = 0;
virtual const NzVertexDeclaration* GetVertexDeclaration() const = 0;
unsigned int GetVertexCount() const;
virtual unsigned int GetVertexCount() const;
virtual bool IsAnimated() const = 0;
void SetMaterialIndex(unsigned int matIndex);
void SetPrimitiveType(nzPrimitiveType primitiveType);
protected:
virtual void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation) = 0;
nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList;
const NzMesh* m_parent;
unsigned int m_matIndex;
};
#endif // NAZARA_SUBMESH_HPP

View File

@@ -10,12 +10,13 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Utility/Buffer.hpp>
#include <Nazara/Utility/VertexDeclaration.hpp>
class NAZARA_API NzVertexBuffer : public NzResource
{
public:
NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
~NzVertexBuffer();
@@ -27,6 +28,7 @@ class NAZARA_API NzVertexBuffer : public NzResource
unsigned int GetStartVertex() const;
nzUInt8 GetTypeSize() const;
unsigned int GetVertexCount() const;
const NzVertexDeclaration* GetVertexDeclaration() const;
bool IsHardware() const;
@@ -38,6 +40,7 @@ class NAZARA_API NzVertexBuffer : public NzResource
private:
NzBuffer* m_buffer;
const NzVertexDeclaration* m_vertexDeclaration;
bool m_ownsBuffer;
unsigned int m_startVertex;
unsigned int m_vertexCount;

View File

@@ -0,0 +1,113 @@
// Copyright (C) 2012 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_VERTEXSTRUCT_HPP
#define NAZARA_VERTEXSTRUCT_HPP
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Math/Vector3.hpp>
struct NzVertexStruct_XY
{
NzVector2f position;
};
struct NzVertexStruct_XY_Color : public NzVertexStruct_XY
{
NzVector3f color;
};
/////////////////////////////////////////
struct NzVertexStruct_XYZ
{
NzVector3f position;
};
struct NzVertexStruct_XYZ_Color : public NzVertexStruct_XYZ
{
NzVector3f color;
};
struct NzVertexStruct_XYZ_Normal : public NzVertexStruct_XYZ
{
NzVector3f normal;
};
struct NzVertexStruct_XYZ_Normal_Color : public NzVertexStruct_XYZ_Normal
{
NzVector3f color;
};
/////////////////////////////////////////
struct NzVertexStruct_XYZ_UV : public NzVertexStruct_XYZ
{
NzVector2f uv;
};
struct NzVertexStruct_XYZ_UV_Color : public NzVertexStruct_XYZ_UV
{
NzVector3f color;
};
struct NzVertexStruct_XYZ_Normal_UV : public NzVertexStruct_XYZ_Normal
{
NzVector2f uv;
};
struct NzVertexStruct_XYZ_Normal_UV_Color : public NzVertexStruct_XYZ_Normal_UV
{
NzVector3f color;
};
struct NzVertexStruct_XYZ_Normal_UV_Tangent : public NzVertexStruct_XYZ_Normal_UV
{
NzVector3f tangent;
};
struct NzVertexStruct_XYZ_Normal_UV_Tangent_Color : public NzVertexStruct_XYZ_Normal_UV_Tangent
{
NzVector3f color;
};
/////////////////////////////////////////
struct NzVertexStruct_XYZ_UV_UV2 : public NzVertexStruct_XYZ_UV
{
NzVector2f uv2;
};
struct NzVertexStruct_XYZ_UV_UV2_Color : public NzVertexStruct_XYZ_UV_UV2
{
NzVector3f color;
};
/////////////////////////////////////////
struct NzVertexStruct_XYZ_Normal_UV_UV2 : public NzVertexStruct_XYZ_Normal_UV
{
NzVector2f uv2;
};
struct NzVertexStruct_XYZ_Normal_UV_UV2_Color : public NzVertexStruct_XYZ_Normal_UV_UV2
{
NzVector3f color;
};
struct NzVertexStruct_XYZ_Normal_UV_UV2_Tangent : public NzVertexStruct_XYZ_Normal_UV_UV2
{
NzVector3f tangent;
};
/////////////////////////////////////////
struct NzVertexStruct_XYZ_Normal_UV_UV2_Tangent_Color : public NzVertexStruct_XYZ_Normal_UV_UV2_Tangent
{
NzVector3f color;
};
#endif // NAZARA_VERTEXSTRUCT_HPP