Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

113 wiersze
2.5 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Lol Engine is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #pragma once
  13. //
  14. // The Mesh class
  15. // --------------
  16. //
  17. #include <lol/gpu/vertexbuffer.h>
  18. #include <lol/gpu/indexbuffer.h>
  19. //Assimp supports http://assimp.sourceforge.net/main_features_formats.html
  20. #if LOL_USE_ASSIMP
  21. //Cause build has a problem with function choice.
  22. #if _WIN32 || _WIN64
  23. #define sin lol::sin
  24. #define asin lol::asin
  25. #define cos lol::cos
  26. #define acos lol::acos
  27. #endif //_WIN32 || _WIN64
  28. #include <assimp/Importer.hpp> // C++ importer interface
  29. #include <assimp/scene.h> // Output data structure
  30. #include <assimp/postprocess.h> // Post processing flags
  31. #if _WIN32 || _WIN64
  32. #undef sin
  33. #undef asin
  34. #undef cos
  35. #undef acos
  36. #endif // _WIN32 || _WIN64
  37. #endif // LOL_USE_ASSIMP
  38. namespace lol
  39. {
  40. /*
  41. * A mesh contains a list of submeshes. This is a convenient way to
  42. * handle different materials or mesh types (static, skeletal, morph targets, etc.)
  43. * within the same container object.
  44. */
  45. class Mesh
  46. {
  47. friend class Scene;
  48. public:
  49. Mesh();
  50. ~Mesh();
  51. /* FIXME: this should eventually take a “material” as argument, which
  52. * may behave differently between submeshes. */
  53. void SetMaterial(Shader *shader);
  54. //TODO: Not sure about the name
  55. void Render(Scene& scene, mat4 const &matrix);
  56. protected:
  57. void Render();
  58. public:
  59. array<class SubMesh *> m_submeshes;
  60. };
  61. /*
  62. * A submesh contains:
  63. * - a vertex declaration
  64. * - a list of VBOs
  65. * - a list of textures
  66. * - a shader
  67. */
  68. class SubMesh
  69. {
  70. friend class PrimitiveMesh;
  71. friend class Mesh;
  72. public:
  73. SubMesh(Shader *shader, VertexDeclaration* vdecl);
  74. ~SubMesh();
  75. void SetMeshPrimitive(MeshPrimitive mesh_primitive);
  76. void SetShader(Shader *shader);
  77. Shader *GetShader();
  78. void SetVertexDeclaration(VertexDeclaration *vdecl);
  79. void SetVertexBuffer(int index, VertexBuffer* vbo);
  80. void SetIndexBuffer(IndexBuffer* ibo);
  81. void AddTexture(const char* name, Texture* texture);
  82. protected:
  83. void Render();
  84. MeshPrimitive m_mesh_prim;
  85. Shader *m_shader;
  86. VertexDeclaration* m_vdecl;
  87. array<VertexBuffer *> m_vbos;
  88. IndexBuffer *m_ibo;
  89. array<String, Texture*> m_textures;
  90. };
  91. } /* namespace lol */