Browse Source

mesh: start working on mesh and submesh stuff.

legacy
Sam Hocevar sam 12 years ago
parent
commit
4a6d092a74
7 changed files with 116 additions and 1 deletions
  1. +2
    -0
      src/Makefile.am
  2. +1
    -0
      src/core.h
  3. +1
    -1
      src/easymesh/easymesh.cpp
  4. +2
    -0
      src/lolcore.vcxproj
  5. +9
    -0
      src/lolcore.vcxproj.filters
  6. +50
    -0
      src/mesh/mesh.cpp
  7. +51
    -0
      src/mesh/mesh.h

+ 2
- 0
src/Makefile.am View File

@@ -63,6 +63,8 @@ liblol_a_SOURCES = \
generated/lolfx-parser.cpp generated/lolfx-parser.h \ generated/lolfx-parser.cpp generated/lolfx-parser.h \
generated/lolfx-scanner.cpp \ generated/lolfx-scanner.cpp \
\ \
mesh/mesh.cpp mesh/mesh.h \
\
image/image.cpp image/image.h image/image-private.h \ image/image.cpp image/image.h image/image-private.h \
image/codec/gdiplus-image.cpp \ image/codec/gdiplus-image.cpp \
image/codec/ios-image.cpp \ image/codec/ios-image.cpp \


+ 1
- 0
src/core.h View File

@@ -120,6 +120,7 @@ static inline int isnan(float f)
#include "gpu/indexbuffer.h" #include "gpu/indexbuffer.h"
#include "gpu/vertexbuffer.h" #include "gpu/vertexbuffer.h"
#include "gpu/framebuffer.h" #include "gpu/framebuffer.h"
#include "mesh/mesh.h"
#include "image/image.h" #include "image/image.h"
#include "application/application.h" #include "application/application.h"
#include "easymesh/easymesh.h" #include "easymesh/easymesh.h"


+ 1
- 1
src/easymesh/easymesh.cpp View File

@@ -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.proj, Scene::GetDefault()->GetProjMatrix());
m_gpu.shader->SetUniform(m_gpu.normalmat, normalmat); m_gpu.shader->SetUniform(m_gpu.normalmat, normalmat);
m_gpu.shader->SetUniform(m_gpu.damage, damage); 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->Bind();
m_gpu.vdecl->SetStream(m_gpu.vbo, m_gpu.coord, m_gpu.norm, m_gpu.color);
m_gpu.ibo->Bind(); m_gpu.ibo->Bind();
m_gpu.vdecl->DrawIndexedElements(MeshPrimitive::Triangles, m_gpu.vdecl->DrawIndexedElements(MeshPrimitive::Triangles,
0, 0, m_gpu.vertexcount, 0, 0, m_gpu.vertexcount,


+ 2
- 0
src/lolcore.vcxproj View File

@@ -275,6 +275,7 @@
<ClCompile Include="math\real.cpp" /> <ClCompile Include="math\real.cpp" />
<ClCompile Include="math\trig.cpp" /> <ClCompile Include="math\trig.cpp" />
<ClCompile Include="math\vector.cpp" /> <ClCompile Include="math\vector.cpp" />
<ClCompile Include="mesh\mesh.cpp" />
<ClCompile Include="platform.cpp" /> <ClCompile Include="platform.cpp" />
<ClCompile Include="platform\d3d9\d3d9input.cpp" /> <ClCompile Include="platform\d3d9\d3d9input.cpp" />
<ClCompile Include="platform\ps3\ps3app.cpp" /> <ClCompile Include="platform\ps3\ps3app.cpp" />
@@ -589,6 +590,7 @@
<ClInclude Include="lol\math\remez.h" /> <ClInclude Include="lol\math\remez.h" />
<ClInclude Include="lol\math\vector.h" /> <ClInclude Include="lol\math\vector.h" />
<ClInclude Include="lol\unit.h" /> <ClInclude Include="lol\unit.h" />
<ClInclude Include="mesh\mesh.h" />
<ClInclude Include="map.h" /> <ClInclude Include="map.h" />
<ClInclude Include="numeric.h" /> <ClInclude Include="numeric.h" />
<ClInclude Include="platform.h" /> <ClInclude Include="platform.h" />


+ 9
- 0
src/lolcore.vcxproj.filters View File

@@ -26,6 +26,9 @@
<Filter Include="src\math"> <Filter Include="src\math">
<UniqueIdentifier>{2caadbda-b9f1-446d-bbd2-55c959db342c}</UniqueIdentifier> <UniqueIdentifier>{2caadbda-b9f1-446d-bbd2-55c959db342c}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="src\mesh">
<UniqueIdentifier>{1eaa8df5-7a31-4358-a1e9-0e265de6ed49}</UniqueIdentifier>
</Filter>
<Filter Include="src\gpu"> <Filter Include="src\gpu">
<UniqueIdentifier>{ec9b94fc-c716-4ef2-9c3b-c7f3447574b0}</UniqueIdentifier> <UniqueIdentifier>{ec9b94fc-c716-4ef2-9c3b-c7f3447574b0}</UniqueIdentifier>
</Filter> </Filter>
@@ -94,6 +97,9 @@
<ClCompile Include="math\vector.cpp"> <ClCompile Include="math\vector.cpp">
<Filter>src\math</Filter> <Filter>src\math</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="mesh\mesh.cpp">
<Filter>src\mesh</Filter>
</ClCompile>
<ClCompile Include="gpu\shader.cpp"> <ClCompile Include="gpu\shader.cpp">
<Filter>src\gpu</Filter> <Filter>src\gpu</Filter>
</ClCompile> </ClCompile>
@@ -672,6 +678,9 @@
<ClInclude Include="lol\unit.h"> <ClInclude Include="lol\unit.h">
<Filter>src\lol</Filter> <Filter>src\lol</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="mesh\mesh.h">
<Filter>src\mesh</Filter>
</ClInclude>
<ClInclude Include="gpu\shader.h"> <ClInclude Include="gpu\shader.h">
<Filter>src\gpu</Filter> <Filter>src\gpu</Filter>
</ClInclude> </ClInclude>


+ 50
- 0
src/mesh/mesh.cpp View File

@@ -0,0 +1,50 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// 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 <cstring>
#include <cstdlib>

#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 */


+ 51
- 0
src/mesh/mesh.h View File

@@ -0,0 +1,51 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// 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<vec3> m_vertices;
Array<vec2> m_uvs;
Array<vec3> m_normals;
};

class Mesh
{
public:
Mesh();
~Mesh();

void Render(mat4 const &model);

private:
Array<SubMesh *> m_submeshes;
};

} /* namespace lol */

#endif /* __MESH_MESH_H__ */


Loading…
Cancel
Save