Added center mesh parameter
Former-commit-id: e010a81e3f00ca6091e438d405e3e6ca14938b8f
This commit is contained in:
parent
a560a16ef3
commit
69479de643
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 13 Mar 2013 at 23:20:31
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Audio module
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 09 Jun 2013 at 11:23:10
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/Format.hpp>
|
||||
#include <Nazara/Core/Functor.hpp>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 21 Aug 2013 at 19:43:23
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Graphics module
|
||||
|
|
@ -36,6 +36,15 @@
|
|||
#include <Nazara/Graphics/Camera.hpp>
|
||||
#include <Nazara/Graphics/ColorBackground.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/DeferredBloomPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredFogPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredForwardPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredFXAAPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredGeometryPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredPhongLightingPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/Drawable.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
|
|
@ -44,6 +53,7 @@
|
|||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Graphics/LightManager.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Graphics/RenderTechniques.hpp>
|
||||
#include <Nazara/Graphics/Scene.hpp>
|
||||
#include <Nazara/Graphics/SceneLayer.hpp>
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 24 Apr 2013 at 11:49:37
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Lua scripting module
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 09 Jun 2013 at 11:23:10
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Mathematics module
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 13 Mar 2013 at 23:20:31
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Noise module
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 21 May 2013 at 13:57:27
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Physics module
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 21 Aug 2013 at 19:43:23
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Renderer module
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
#include <Nazara/Renderer/GpuQuery.hpp>
|
||||
#include <Nazara/Renderer/Material.hpp>
|
||||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 09 Jun 2013 at 11:23:10
|
||||
// This file was automatically generated on 20 Dec 2013 at 20:02:16
|
||||
|
||||
/*
|
||||
Nazara Engine - Window module
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ struct NAZARA_API NzMeshParams
|
|||
// Charger une version animée du mesh si possible ?
|
||||
bool animated = true;
|
||||
|
||||
// Faut-il centrer le mesh autour de l'origine ?
|
||||
bool center = false;
|
||||
|
||||
// Faut-il optimiser les index buffers ? (Rendu plus rapide, mais le chargement dure plus longtemps)
|
||||
bool optimizeIndexBuffers = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
|||
NzStaticMesh(const NzMesh* parent);
|
||||
virtual ~NzStaticMesh();
|
||||
|
||||
void Center();
|
||||
|
||||
bool Create(NzVertexBuffer* vertexBuffer);
|
||||
void Destroy();
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace
|
|||
unsigned int faceCount = meshes[i].faces.size();
|
||||
|
||||
std::vector<unsigned int> indices;
|
||||
indices.reserve(faceCount*3); // Pire cas (si les faces sont des triangles)
|
||||
indices.reserve(faceCount*3); // Pire cas si les faces sont des triangles
|
||||
|
||||
// Bien plus rapide qu'un vector (pour la recherche)
|
||||
std::unordered_map<int, std::unordered_map<int, std::unordered_map<int, unsigned int>>> vertices;
|
||||
|
|
@ -167,6 +167,9 @@ namespace
|
|||
subMesh->SetMaterialIndex(meshes[i].material);
|
||||
subMesh->SetPrimitiveMode(nzPrimitiveMode_TriangleList);
|
||||
|
||||
if (parameters.mesh.center)
|
||||
subMesh->Center();
|
||||
|
||||
if (hasNormals && hasTexCoords)
|
||||
subMesh->GenerateTangents();
|
||||
else if (hasTexCoords)
|
||||
|
|
|
|||
|
|
@ -227,6 +227,10 @@ namespace
|
|||
subMesh->GenerateAABB();
|
||||
subMesh->GenerateTangents();
|
||||
subMesh->SetMaterialIndex(0);
|
||||
|
||||
if (parameters.center)
|
||||
subMesh->Center();
|
||||
|
||||
mesh->AddSubMesh(subMesh.release());
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -351,10 +351,14 @@ bool NzMD5MeshParser::Parse(NzMesh* mesh)
|
|||
|
||||
// Material
|
||||
mesh->SetMaterial(i, baseDir + md5Mesh.shader);
|
||||
|
||||
subMesh->GenerateAABB();
|
||||
subMesh->GenerateNormalsAndTangents();
|
||||
subMesh->SetMaterialIndex(i);
|
||||
|
||||
if (m_parameters.center)
|
||||
subMesh->Center();
|
||||
|
||||
mesh->AddSubMesh(subMesh.get());
|
||||
subMesh.release();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <Nazara/Utility/Algorithm.hpp>
|
||||
#include <Nazara/Utility/BufferMapper.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/VertexMapper.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
|
|
@ -20,6 +21,20 @@ NzStaticMesh::~NzStaticMesh()
|
|||
Destroy();
|
||||
}
|
||||
|
||||
void NzStaticMesh::Center()
|
||||
{
|
||||
NzVector3f offset(m_aabb.x + m_aabb.width/2.f, m_aabb.y + m_aabb.height/2.f, m_aabb.z + m_aabb.depth/2.f);
|
||||
|
||||
NzVertexMapper mapper(this);
|
||||
unsigned int vertexCount = mapper.GetVertexCount();
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
mapper.SetPosition(i, mapper.GetPosition(i) - offset);
|
||||
|
||||
m_aabb.x -= offset.x;
|
||||
m_aabb.y -= offset.y;
|
||||
m_aabb.z -= offset.z;
|
||||
}
|
||||
|
||||
bool NzStaticMesh::Create(NzVertexBuffer* vertexBuffer)
|
||||
{
|
||||
Destroy();
|
||||
|
|
|
|||
Loading…
Reference in New Issue