Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

115 righe
3.5 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
  5. // (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
  6. // (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
  7. // This program is free software; you can redistribute it and/or
  8. // modify it under the terms of the Do What The Fuck You Want To
  9. // Public License, Version 2, as published by Sam Hocevar. See
  10. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  11. //
  12. //
  13. // The EasyMesh class
  14. // ------------------
  15. //
  16. #if !defined __EASYMESH_EASYMESH_H__
  17. #define __EASYMESH_EASYMESH_H__
  18. namespace lol
  19. {
  20. class EasyMesh
  21. {
  22. friend class EasyMeshParser;
  23. public:
  24. EasyMesh();
  25. bool Compile(char const *command);
  26. void MeshConvert();
  27. void Render(mat4 const &model, float damage = 0.f);
  28. void OpenBrace();
  29. void CloseBrace();
  30. void SetCurColor(vec4 const &color);
  31. void SetCurColor2(vec4 const &color);
  32. private:
  33. void AddVertex(vec3 const &coord);
  34. void AddDuplicateVertex(int i);
  35. void AppendQuad(int i1, int i2, int i3, int i4, int base);
  36. void AppendQuadDuplicateVerts(int i1, int i2, int i3, int i4, int base);
  37. void AppendTriangle(int i1, int i2, int i3, int base);
  38. void AppendTriangleDuplicateVerts(int i1, int i2, int i3, int base);
  39. void ComputeNormals(int start, int vcount);
  40. void SetVertColor(vec4 const &color);
  41. public:
  42. void SetCurVertNormal(vec3 const &normal);
  43. void SetCurVertColor(vec4 const &color);
  44. void RadialJitter(float r);
  45. void Translate(vec3 const &v);
  46. void RotateX(float t);
  47. void RotateY(float t);
  48. void RotateZ(float t);
  49. void Rotate(float t, vec3 const &axis);
  50. void TaperX(float y, float z, float xoff);
  51. void TaperY(float x, float z, float yoff);
  52. void TaperZ(float x, float y, float zoff);
  53. void Scale(vec3 const &s);
  54. void MirrorX();
  55. void MirrorY();
  56. void MirrorZ();
  57. void DupAndScale(vec3 const &s);
  58. void Chamfer(float f);
  59. void AppendCylinder(int nsides, float h, float r1, float r2,
  60. int dualside, int smooth);
  61. void AppendCapsule(int ndivisions, float h, float r);
  62. void AppendSphere(int ndivisions, vec3 const &size);
  63. void AppendTorus(int ndivisions, float r1, float r2);
  64. void AppendBox(vec3 const &size, float chamf = 0.f);
  65. void AppendSmoothChamfBox(vec3 const &size, float chamf);
  66. void AppendFlatChamfBox(vec3 const &size, float chamf);
  67. void AppendBox(vec3 const &size, float chamf, bool smooth);
  68. void AppendStar(int nbranches, float r1, float r2,
  69. int fade = 0, int fade2 = 0);
  70. void AppendExpandedStar(int nbranches, float r1, float r2, float extrar);
  71. void AppendDisc(int nsides, float r, int fade = 0);
  72. void AppendSimpleTriangle(float size, int fade = 0);
  73. void AppendSimpleQuad(float size, int fade = 0);
  74. void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0);
  75. void AppendCog(int nbsides, float h, float r1, float r2,
  76. float r12, float r22, float sidemul, int offset);
  77. private:
  78. vec4 m_color, m_color2;
  79. Array<uint16_t> m_indices;
  80. Array<vec3, vec3, vec4> m_vert;
  81. Array<int, int> m_cursors;
  82. /* FIXME: put this in a separate class so that we can copy meshes. */
  83. struct
  84. {
  85. Shader *shader;
  86. ShaderAttrib coord, norm, color;
  87. ShaderUniform modelview, proj, normalmat, damage;
  88. VertexDeclaration *vdecl;
  89. VertexBuffer *vbo;
  90. IndexBuffer *ibo;
  91. int vertexcount, indexcount;
  92. }
  93. m_gpu;
  94. };
  95. } /* namespace lol */
  96. #endif /* __EASYMESH_EASYMESH_H__ */