Merge branch 'master' of https://github.com/DigitalPulseSoftware/NazaraEngine
Former-commit-id: 05911276c1658a2c52589da7890e22c4d188dca3 [formerly d247d95d9c5fa89babb1eaabf1e67de5ad2752dd] Former-commit-id: 8fcf7fe42b04b7c0f0059fc41a1dea79d24ff1ba
This commit is contained in:
commit
dce978aa51
|
|
@ -33,6 +33,10 @@ namespace Ndk
|
|||
|
||||
bool Run();
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
inline void MakeExitOnLastWindowClosed(bool exitOnClosedWindows);
|
||||
#endif
|
||||
|
||||
inline void Quit();
|
||||
|
||||
Application& operator=(const Application&) = delete;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,13 @@ namespace Ndk
|
|||
return m_updateTime;
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows)
|
||||
{
|
||||
m_exitOnClosedWindows = exitOnClosedWindows;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void Application::Quit()
|
||||
{
|
||||
m_shouldQuit = true;
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ namespace Nz
|
|||
params->animated = instance.CheckField<bool>("Animated", params->animated);
|
||||
params->center = instance.CheckField<bool>("Center", params->center);
|
||||
params->flipUVs = instance.CheckField<bool>("FlipUVs", params->flipUVs);
|
||||
//params->matrix = instance.CheckField<Matrix4f>("Matrix", params->matrix);
|
||||
params->optimizeIndexBuffers = instance.CheckField<bool>("OptimizeIndexBuffers", params->optimizeIndexBuffers);
|
||||
params->scale = instance.CheckField<Vector3f>("Scale", params->scale);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -586,7 +586,10 @@ namespace Nz
|
|||
{
|
||||
texture = TextureManager::Get(textureName);
|
||||
if (!texture)
|
||||
{
|
||||
NazaraError("Failed to get alpha map \"" + textureName + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SetAlphaMap(std::move(texture));
|
||||
|
|
@ -679,7 +682,10 @@ namespace Nz
|
|||
{
|
||||
texture = TextureManager::Get(textureName);
|
||||
if (!texture)
|
||||
{
|
||||
NazaraError("Failed to get diffuse map \"" + textureName + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SetDiffuseMap(std::move(texture));
|
||||
|
|
@ -738,7 +744,10 @@ namespace Nz
|
|||
{
|
||||
texture = TextureManager::Get(textureName);
|
||||
if (!texture)
|
||||
{
|
||||
NazaraError("Failed to get emissive map \"" + textureName + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SetEmissiveMap(std::move(texture));
|
||||
|
|
@ -797,7 +806,10 @@ namespace Nz
|
|||
{
|
||||
texture = TextureManager::Get(textureName);
|
||||
if (!texture)
|
||||
{
|
||||
NazaraError("Failed to get height map \"" + textureName + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SetHeightMap(std::move(texture));
|
||||
|
|
@ -834,7 +846,10 @@ namespace Nz
|
|||
{
|
||||
texture = TextureManager::Get(textureName);
|
||||
if (!texture)
|
||||
{
|
||||
NazaraError("Failed to get normal map \"" + textureName + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SetNormalMap(std::move(texture));
|
||||
|
|
@ -936,7 +951,10 @@ namespace Nz
|
|||
{
|
||||
texture = TextureManager::Get(textureName);
|
||||
if (!texture)
|
||||
{
|
||||
NazaraError("Failed to get specular map \"" + textureName + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SetSpecularMap(std::move(texture));
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace Nz
|
|||
static constexpr const char* HeightTexturePath = "MatHeightTexturePath";
|
||||
static constexpr const char* Lighting = "MatLighting";
|
||||
static constexpr const char* LineWidth = "MatLineWidth";
|
||||
static constexpr const char* Name = "MatName";
|
||||
static constexpr const char* NormalTexturePath = "MatNormalTexturePath";
|
||||
static constexpr const char* PointSize = "MatPointSize";
|
||||
static constexpr const char* ScissorTest = "MatScissorTest";
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ namespace Nz
|
|||
{
|
||||
MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
|
||||
|
||||
// La mise à l'échelle éventuelle que subira le mesh
|
||||
Vector3f scale = Vector3f::Unit();
|
||||
// La transformation appliquée à tous les sommets du mesh
|
||||
Matrix4f matrix = Matrix4f::Identity();
|
||||
|
||||
// Si ceci sera le stockage utilisé par les buffers
|
||||
UInt32 storage = DataStorage_Hardware;
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
|||
aiVector3D tangent = (iMesh->HasTangentsAndBitangents()) ? iMesh->mTangents[j] : aiVector3D(0.f, 1.f, 0.f);
|
||||
aiVector3D uv = (iMesh->HasTextureCoords(0)) ? iMesh->mTextureCoords[0][j] : aiVector3D(0.f);
|
||||
|
||||
vertex->position = parameters.scale * Vector3f(position.x, position.y, position.z);
|
||||
vertex->position = parameters.matrix * Vector3f(position.x, position.y, position.z);
|
||||
vertex->normal.Set(normal.x, normal.y, normal.z);
|
||||
vertex->tangent.Set(tangent.x, tangent.y, tangent.z);
|
||||
vertex->uv.Set(uv.x, uv.y);
|
||||
|
|
@ -291,8 +291,12 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
|||
ConvertTexture(aiTextureType_OPACITY, MaterialData::AlphaTexturePath);
|
||||
ConvertTexture(aiTextureType_SPECULAR, MaterialData::SpecularTexturePath, MaterialData::SpecularWrap);
|
||||
|
||||
aiString name;
|
||||
if (aiGetMaterialString(aiMat, AI_MATKEY_NAME, &name) == aiReturn_SUCCESS)
|
||||
matData.SetParameter(MaterialData::Name, String(name.data, name.length));
|
||||
|
||||
int iValue;
|
||||
if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue))
|
||||
if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue) == aiReturn_SUCCESS)
|
||||
matData.SetParameter(MaterialData::FaceCulling, !iValue);
|
||||
|
||||
matIt = materials.insert(std::make_pair(iMesh->mMaterialIndex, std::make_pair(materials.size(), std::move(matData)))).first;
|
||||
|
|
|
|||
|
|
@ -492,22 +492,22 @@ namespace Nz
|
|||
s_defaultMaterial->SetFaceFilling(FaceFilling_Line);
|
||||
MaterialLibrary::Register("Default", s_defaultMaterial);
|
||||
|
||||
MaterialRef mat;
|
||||
MaterialRef mat;
|
||||
|
||||
mat = New();
|
||||
mat->Enable(RendererParameter_DepthWrite, false);
|
||||
mat->Enable(RendererParameter_FaceCulling, false);
|
||||
mat->EnableLighting(false);
|
||||
MaterialLibrary::Register("Basic2D", std::move(mat));
|
||||
mat = New();
|
||||
mat->Enable(RendererParameter_DepthWrite, false);
|
||||
mat->Enable(RendererParameter_FaceCulling, false);
|
||||
mat->EnableLighting(false);
|
||||
MaterialLibrary::Register("Basic2D", std::move(mat));
|
||||
|
||||
mat = New();
|
||||
mat->Enable(RendererParameter_Blend, true);
|
||||
mat->Enable(RendererParameter_DepthWrite, false);
|
||||
mat->Enable(RendererParameter_FaceCulling, false);
|
||||
mat->EnableLighting(false);
|
||||
mat->SetDstBlend(BlendFunc_InvSrcAlpha);
|
||||
mat->SetSrcBlend(BlendFunc_SrcAlpha);
|
||||
MaterialLibrary::Register("Translucent2D", std::move(mat));
|
||||
mat = New();
|
||||
mat->Enable(RendererParameter_Blend, true);
|
||||
mat->Enable(RendererParameter_DepthWrite, false);
|
||||
mat->Enable(RendererParameter_FaceCulling, false);
|
||||
mat->EnableLighting(false);
|
||||
mat->SetDstBlend(BlendFunc_InvSrcAlpha);
|
||||
mat->SetSrcBlend(BlendFunc_SrcAlpha);
|
||||
MaterialLibrary::Register("Translucent2D", std::move(mat));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,11 +188,10 @@ namespace Nz
|
|||
SwapBytes(&translate.z, sizeof(float));
|
||||
#endif
|
||||
|
||||
// Un personnage de taille moyenne fait ~50 unités de haut dans Quake 2
|
||||
// Avec Nazara, 1 unité = 1 mètre, nous devons donc adapter l'échelle
|
||||
Vector3f s(parameters.scale/29.f); // 50/29 = 1.72 (Soit 1.72 mètre, proche de la taille moyenne d'un individu)
|
||||
scale *= s;
|
||||
translate *= s;
|
||||
constexpr float ScaleAdjust = 1.f / 27.8f; // Make a 50 Quake 2 units character a 1.8 unit long
|
||||
|
||||
scale *= ScaleAdjust;
|
||||
translate *= ScaleAdjust;
|
||||
|
||||
BufferMapper<VertexBuffer> vertexMapper(vertexBuffer, BufferAccess_DiscardAndWrite);
|
||||
MeshVertex* vertex = static_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||
|
|
@ -215,11 +214,13 @@ namespace Nz
|
|||
/// Chargement des positions
|
||||
// Pour que le modèle soit correctement aligné, on génère un quaternion que nous appliquerons à chacune des vertices
|
||||
Quaternionf rotationQuat = EulerAnglesf(-90.f, 90.f, 0.f);
|
||||
Nz::Matrix4f matrix = Matrix4f::Transform(translate, rotationQuat, scale);
|
||||
matrix *= parameters.matrix;
|
||||
|
||||
for (unsigned int v = 0; v < header.num_vertices; ++v)
|
||||
{
|
||||
const MD2_Vertex& vert = vertices[v];
|
||||
Vector3f position = rotationQuat * Vector3f(vert.x*scale.x + translate.x, vert.y*scale.y + translate.y, vert.z*scale.z + translate.z);
|
||||
Vector3f position = matrix * Vector3f(vert.x, vert.y, vert.z);
|
||||
|
||||
vertex->position = position;
|
||||
vertex->normal = rotationQuat * md2Normals[vert.n];
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ namespace Nz
|
|||
|
||||
// Le hellknight de Doom 3 fait ~120 unités, et il est dit qu'il fait trois mètres
|
||||
// Nous réduisons donc la taille générale des fichiers MD5 de 1/40
|
||||
Vector3f scale(parameters.scale/40.f);
|
||||
Matrix4f matrix = Matrix4f::Transform(Nz::Vector3f::Zero(), rotationQuat, Vector3f(1.f / 40.f));
|
||||
matrix *= parameters.matrix;
|
||||
|
||||
const MD5MeshParser::Joint* joints = parser.GetJoints();
|
||||
const MD5MeshParser::Mesh* meshes = parser.GetMeshes();
|
||||
|
|
@ -267,7 +268,7 @@ namespace Nz
|
|||
}
|
||||
|
||||
// On retourne le modèle dans le bon sens
|
||||
vertex->position = scale * (rotationQuat * finalPos);
|
||||
vertex->position = matrix * finalPos;
|
||||
vertex->uv.Set(md5Vertex.uv.x, (parameters.flipUVs) ? 1.f - md5Vertex.uv.y : md5Vertex.uv.y); // Inversion des UV si demandé
|
||||
vertex++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,8 +234,7 @@ namespace Nz
|
|||
MeshVertex& vertex = meshVertices[index];
|
||||
|
||||
const Vector4f& vec = positions[vertexIndices.position];
|
||||
vertex.position.Set(vec.x, vec.y, vec.z);
|
||||
vertex.position *= parameters.scale/vec.w;
|
||||
vertex.position = Vector3f(parameters.matrix * vec);
|
||||
|
||||
if (vertexIndices.normal >= 0)
|
||||
vertex.normal = normals[vertexIndices.normal];
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ namespace Nz
|
|||
return false;
|
||||
}
|
||||
|
||||
if (scale == Vector3f::Zero())
|
||||
if (matrix == Matrix4f::Zero())
|
||||
{
|
||||
NazaraError("Invalid scale");
|
||||
NazaraError("Invalid matrix");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ namespace Nz
|
|||
VertexBufferRef vertexBuffer;
|
||||
|
||||
Matrix4f matrix(primitive.matrix);
|
||||
matrix.ApplyScale(params.scale);
|
||||
matrix *= params.matrix;
|
||||
|
||||
VertexDeclaration* declaration = VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue