Added Meshes and Animations (And many more)

Added NzTexture::IsMipmappingSupported
Color::(FromTo)HSV now takes hue and saturation in degrees
Fixed Context::EnsureContext
Fixed COW thread-safety (String, Image, Matrix4)
Fixed Quatenion<T>::operator*(const Vector3<T>&)
Fixed ResourceLoader
Fixed String::Resize with a size of 0
Fixed Texture mipmapping crash
Fixed per-class thread-safety
IndexBuffer and VertexBuffer are now resources
It is now possible to use more than 8 texcoords per shader
Moved all enumerations into separate files (Core/Enums.hpp,
Utility/Enums.hpp, ..)
Removed NzContextParameters::defaultWindow
VertexDeclaration has been rewritten (New interface/COW)
This commit is contained in:
Lynix
2012-07-13 15:22:14 +02:00
parent 5f95f0b677
commit 06eda4eba9
75 changed files with 3385 additions and 861 deletions

View File

@@ -0,0 +1,141 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/StaticMesh.hpp>
#include <Nazara/Core/Error.hpp>
#include <stdexcept>
#include <Nazara/Utility/Debug.hpp>
NzStaticMesh::NzStaticMesh(const NzMesh* parent) :
NzSubMesh(parent)
{
}
NzStaticMesh::NzStaticMesh(const NzMesh* parent, const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer) :
NzSubMesh(parent)
{
#ifdef NAZARA_DEBUG
if (!Create(vertexBuffer, vertexDeclaration, indexBuffer))
{
NazaraError("Failed to create mesh");
throw std::runtime_error("Constructor failed");
}
#else
Create(vertexBuffer, vertexDeclaration, indexBuffer);
#endif
}
NzStaticMesh::~NzStaticMesh()
{
Destroy();
}
bool NzStaticMesh::Create(const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer)
{
Destroy();
#if NAZARA_UTILITY_SAFE
if (!vertexBuffer)
{
NazaraError("Vertex buffer is null");
return false;
}
if (!vertexDeclaration)
{
NazaraError("Vertex declaration is null");
return false;
}
#endif
if (indexBuffer)
{
m_indexBuffer = indexBuffer;
m_indexBuffer->AddResourceReference();
}
m_vertexBuffer = vertexBuffer;
m_vertexBuffer->AddResourceReference();
m_vertexDeclaration = vertexDeclaration;
m_vertexDeclaration->AddResourceReference();
return true;
}
void NzStaticMesh::Destroy()
{
if (m_indexBuffer)
{
m_indexBuffer->RemoveResourceReference();
m_indexBuffer = nullptr;
}
if (m_vertexBuffer)
{
m_vertexBuffer->RemoveResourceReference();
m_vertexBuffer = nullptr;
}
if (m_vertexDeclaration)
{
m_vertexDeclaration->RemoveResourceReference();
m_vertexDeclaration = nullptr;
}
}
nzAnimationType NzStaticMesh::GetAnimationType() const
{
return nzAnimationType_Static;
}
unsigned int NzStaticMesh::GetFrameCount() const
{
return 1;
}
const NzIndexBuffer* NzStaticMesh::GetIndexBuffer() const
{
return m_indexBuffer;
}
nzPrimitiveType NzStaticMesh::GetPrimitiveType() const
{
return m_primitiveType;
}
const NzVertexBuffer* NzStaticMesh::GetVertexBuffer() const
{
return m_vertexBuffer;
}
const NzVertexDeclaration* NzStaticMesh::GetVertexDeclaration() const
{
return m_vertexDeclaration;
}
bool NzStaticMesh::IsAnimated() const
{
return false;
}
bool NzStaticMesh::IsValid() const
{
return m_vertexBuffer != nullptr && m_vertexDeclaration != nullptr;
}
void NzStaticMesh::SetPrimitiveType(nzPrimitiveType primitiveType)
{
m_primitiveType = primitiveType;
}
void NzStaticMesh::AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation)
{
NazaraUnused(frameA);
NazaraUnused(frameB);
NazaraUnused(interpolation);
// Le safe mode est censé nous protéger de cet appel
NazaraError("Static mesh have no animation, please enable safe mode");
}