Added mesh generator functions
Added Mesh::Build Former-commit-id: dcfc6587b67ab4ec350ab7ca04ae7f45475f6b1b
This commit is contained in:
34
include/Nazara/Utility/Algorithm.hpp
Normal file
34
include/Nazara/Utility/Algorithm.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2013 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_ALGORITHM_UTILITY_HPP
|
||||
#define NAZARA_ALGORITHM_UTILITY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
|
||||
NAZARA_API void NzComputeCubeIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputeCubicSphereIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputePlaneIndexVertexCount(const NzVector2ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
|
||||
///TODO: Itérateur sur les indices
|
||||
NAZARA_API void NzGenerateCube(const NzCubef& cube, const NzVector3ui& subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateIcoSphere(float size, unsigned int recursionLevel, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGeneratePlane(const NzVector2ui& subdivision, const NzVector3f& position, const NzVector3f& normal, const NzVector2f& size, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
|
||||
inline void NzTransformVertex(NzMeshVertex* vertex, const NzMatrix4f& matrix);
|
||||
inline void NzTransformVertices(NzMeshVertex* vertices, unsigned int vertexCount, const NzMatrix4f& matrix);
|
||||
|
||||
#include <Nazara/Utility/Algorithm.inl>
|
||||
|
||||
#endif // NAZARA_ALGORITHM_UTILITY_HPP
|
||||
24
include/Nazara/Utility/Algorithm.inl
Normal file
24
include/Nazara/Utility/Algorithm.inl
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2013 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
|
||||
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
void NzTransformVertex(NzMeshVertex* vertex, const NzMatrix4f& matrix)
|
||||
{
|
||||
vertex->normal = matrix.Transform(vertex->normal, 0.f);
|
||||
vertex->position = matrix.Transform(vertex->position);
|
||||
vertex->tangent = matrix.Transform(vertex->tangent, 0.f);
|
||||
vertex++;
|
||||
}
|
||||
|
||||
void NzTransformVertices(NzMeshVertex* vertices, unsigned int vertexCount, const NzMatrix4f& matrix)
|
||||
{
|
||||
if (matrix.IsIdentity())
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
NzTransformVertex(vertices++, matrix);
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -33,6 +33,7 @@ struct NAZARA_API NzMeshParams
|
||||
};
|
||||
|
||||
class NzAnimation;
|
||||
class NzPrimitiveList;
|
||||
class NzMesh;
|
||||
|
||||
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
|
||||
@@ -54,6 +55,8 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
bool AddSubMesh(NzSubMesh* subMesh);
|
||||
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||
|
||||
void Build(const NzPrimitiveList& list, const NzMeshParams& params = NzMeshParams());
|
||||
|
||||
bool CreateSkeletal(unsigned int jointCount);
|
||||
bool CreateStatic();
|
||||
void Destroy();
|
||||
|
||||
Reference in New Issue
Block a user