diff --git a/.gitignore b/.gitignore index e6f9b897..4d7d5340 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ test/xolotl/xolotl tools/make-font tutorial/01_triangle tutorial/02_cube +tutorial/05_easymesh tutorial/08_fbo tutorial/11_fractal # Our data diff --git a/build/vs2010/Lol.sln b/build/vs2010/Lol.sln index f124d1ae..0545d482 100644 --- a/build/vs2010/Lol.sln +++ b/build/vs2010/Lol.sln @@ -51,6 +51,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "02_cube", "..\..\tutorial\0 {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "05_easymesh", "..\..\tutorial\05_easymesh.vcxproj", "{1C5B8702-290C-42DA-AA9E-671348F5B747}" + ProjectSection(ProjectDependencies) = postProject + {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "11_fractal", "..\..\tutorial\11_fractal.vcxproj", "{6BF81B39-EDC2-4227-9992-C2D8ABEA95AF}" ProjectSection(ProjectDependencies) = postProject {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} diff --git a/tutorial/05_easymesh.cpp b/tutorial/05_easymesh.cpp new file mode 100644 index 00000000..041f1067 --- /dev/null +++ b/tutorial/05_easymesh.cpp @@ -0,0 +1,87 @@ +// +// Lol Engine - EasyMesh tutorial +// +// Copyright: (c) 2011-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 "core.h" + +using namespace std; +using namespace lol; + +#if USE_SDL && defined __APPLE__ +# include +#endif + +class EasyMeshTutorial : public WorldEntity +{ +public: + EasyMeshTutorial() + { + m_angle = 0; + m_mesh.Compile("sc#e94 scb#964 [acg10 5 8 8 2 2 0.1 0]"); + + m_camera = new Camera(vec3(0.f, 600.f, 0.f), + vec3(0.f, 0.f, 0.f), + vec3(0, 1, 0)); + m_camera->SetPerspective(70.f, 640.f, 480.f, .1f, 1000.f); + m_camera->SetTarget(vec3(0.f)); + m_camera->SetPosition(vec3(-20.f, 20.f, 0.f)); + Ticker::Ref(m_camera); + + m_ready = false; + } + + virtual void TickGame(float seconds) + { + WorldEntity::TickGame(seconds); + + m_angle += seconds * 45.0f; + + mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0)); + mat4 model = mat4::translate(vec3(0, 0, 0)); + + m_matrix = model * anim; + } + + virtual void TickDraw(float seconds) + { + WorldEntity::TickDraw(seconds); + + if (!m_ready) + { + m_mesh.MeshConvert(); + m_ready = true; + } + + Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f)); + + m_mesh.Render(m_matrix); + } + +private: + float m_angle; + mat4 m_matrix; + EasyMesh m_mesh; + Camera *m_camera; + + bool m_ready; +}; + +int main(int argc, char **argv) +{ + Application app("Tutorial 5: EasyMesh", ivec2(640, 480), 60.0f); + new EasyMeshTutorial(); + app.Run(); + + return EXIT_SUCCESS; +} + diff --git a/tutorial/05_easymesh.vcxproj b/tutorial/05_easymesh.vcxproj new file mode 100644 index 00000000..1eaf6776 --- /dev/null +++ b/tutorial/05_easymesh.vcxproj @@ -0,0 +1,65 @@ + + + + + Debug + PS3 + + + Debug + Win32 + + + Debug + x64 + + + Debug + Xbox 360 + + + Release + PS3 + + + Release + Win32 + + + Release + x64 + + + Release + Xbox 360 + + + + + + + + {9e62f2fe-3408-4eae-8238-fd84238ceeda} + + + + {1c5b8702-290c-42da-aa9e-671348f5b747} + Application + Win32Proj + + + + + + + + + + + + + + + + + diff --git a/tutorial/Makefile.am b/tutorial/Makefile.am index 13d3fc27..804a8b76 100644 --- a/tutorial/Makefile.am +++ b/tutorial/Makefile.am @@ -14,7 +14,7 @@ SUFFIXES = .lolfx .lolfx.o: $(LOLFX_BUILD) -noinst_PROGRAMS = 01_triangle 02_cube 08_fbo 11_fractal +noinst_PROGRAMS = 01_triangle 02_cube 05_easymesh 08_fbo 11_fractal 01_triangle_SOURCES = 01_triangle.cpp 01_triangle.lolfx 01_triangle_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ @@ -26,6 +26,11 @@ noinst_PROGRAMS = 01_triangle 02_cube 08_fbo 11_fractal 02_cube_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ 02_cube_DEPENDENCIES = $(top_builddir)/src/liblol.a +05_easymesh_SOURCES = 05_easymesh.cpp +05_easymesh_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ +05_easymesh_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ +05_easymesh_DEPENDENCIES = $(top_builddir)/src/liblol.a + 08_fbo_SOURCES = 08_fbo.cpp 08_fbo.lolfx 08_fbo_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ 08_fbo_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@