From 4a6d092a740b9b61ee9d85e505851601f57fcd73 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 7 Nov 2012 17:27:53 +0000 Subject: [PATCH] mesh: start working on mesh and submesh stuff. --- src/Makefile.am | 2 ++ src/core.h | 1 + src/easymesh/easymesh.cpp | 2 +- src/lolcore.vcxproj | 2 ++ src/lolcore.vcxproj.filters | 9 +++++++ src/mesh/mesh.cpp | 50 ++++++++++++++++++++++++++++++++++++ src/mesh/mesh.h | 51 +++++++++++++++++++++++++++++++++++++ 7 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/mesh/mesh.cpp create mode 100644 src/mesh/mesh.h diff --git a/src/Makefile.am b/src/Makefile.am index dceb4ce0..99f724cc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,6 +63,8 @@ liblol_a_SOURCES = \ generated/lolfx-parser.cpp generated/lolfx-parser.h \ generated/lolfx-scanner.cpp \ \ + mesh/mesh.cpp mesh/mesh.h \ + \ image/image.cpp image/image.h image/image-private.h \ image/codec/gdiplus-image.cpp \ image/codec/ios-image.cpp \ diff --git a/src/core.h b/src/core.h index 7492c2d7..dab3bb9b 100644 --- a/src/core.h +++ b/src/core.h @@ -120,6 +120,7 @@ static inline int isnan(float f) #include "gpu/indexbuffer.h" #include "gpu/vertexbuffer.h" #include "gpu/framebuffer.h" +#include "mesh/mesh.h" #include "image/image.h" #include "application/application.h" #include "easymesh/easymesh.h" diff --git a/src/easymesh/easymesh.cpp b/src/easymesh/easymesh.cpp index ac0ee4d0..faea6fef 100644 --- a/src/easymesh/easymesh.cpp +++ b/src/easymesh/easymesh.cpp @@ -120,8 +120,8 @@ void EasyMesh::Render(mat4 const &model, float damage) m_gpu.shader->SetUniform(m_gpu.proj, Scene::GetDefault()->GetProjMatrix()); m_gpu.shader->SetUniform(m_gpu.normalmat, normalmat); m_gpu.shader->SetUniform(m_gpu.damage, damage); - m_gpu.vdecl->SetStream(m_gpu.vbo, m_gpu.coord, m_gpu.norm, m_gpu.color); m_gpu.vdecl->Bind(); + m_gpu.vdecl->SetStream(m_gpu.vbo, m_gpu.coord, m_gpu.norm, m_gpu.color); m_gpu.ibo->Bind(); m_gpu.vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, m_gpu.vertexcount, diff --git a/src/lolcore.vcxproj b/src/lolcore.vcxproj index 57e1488b..5ddfb4ff 100644 --- a/src/lolcore.vcxproj +++ b/src/lolcore.vcxproj @@ -275,6 +275,7 @@ + @@ -589,6 +590,7 @@ + diff --git a/src/lolcore.vcxproj.filters b/src/lolcore.vcxproj.filters index bb2f3b4b..394a43ab 100644 --- a/src/lolcore.vcxproj.filters +++ b/src/lolcore.vcxproj.filters @@ -26,6 +26,9 @@ {2caadbda-b9f1-446d-bbd2-55c959db342c} + + {1eaa8df5-7a31-4358-a1e9-0e265de6ed49} + {ec9b94fc-c716-4ef2-9c3b-c7f3447574b0} @@ -94,6 +97,9 @@ src\math + + src\mesh + src\gpu @@ -672,6 +678,9 @@ src\lol + + src\mesh + src\gpu diff --git a/src/mesh/mesh.cpp b/src/mesh/mesh.cpp new file mode 100644 index 00000000..758f5ffd --- /dev/null +++ b/src/mesh/mesh.cpp @@ -0,0 +1,50 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2012 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://sam.zoy.org/projects/COPYING.WTFPL for more details. +// + +#if defined HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "core.h" + +namespace lol +{ + +Mesh::Mesh() +{ +} + +Mesh::~Mesh() +{ +} + +void Mesh::Render(mat4 const &model) +{ + for (int i = 0; i < m_submeshes.Count(); ++i) + m_submeshes[i]->Render(model); +} + +SubMesh::SubMesh() +{ +} + +SubMesh::~SubMesh() +{ +} + +void SubMesh::Render(mat4 const &model) +{ +} + +} /* namespace lol */ + diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h new file mode 100644 index 00000000..d28a05c0 --- /dev/null +++ b/src/mesh/mesh.h @@ -0,0 +1,51 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2012 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://sam.zoy.org/projects/COPYING.WTFPL for more details. +// + +// +// The Mesh class +// -------------- +// + +#if !defined __MESH_MESH_H__ +#define __MESH_MESH_H__ + +namespace lol +{ + +class SubMesh +{ +public: + SubMesh(); + ~SubMesh(); + + void Render(mat4 const &model); + +private: + Array m_vertices; + Array m_uvs; + Array m_normals; +}; + +class Mesh +{ +public: + Mesh(); + ~Mesh(); + + void Render(mat4 const &model); + +private: + Array m_submeshes; +}; + +} /* namespace lol */ + +#endif /* __MESH_MESH_H__ */ +