Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

114 строки
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 AppendBox(vec3 const &size, float chamf = 0.f);
  64. void AppendSmoothChamfBox(vec3 const &size, float chamf);
  65. void AppendFlatChamfBox(vec3 const &size, float chamf);
  66. void AppendBox(vec3 const &size, float chamf, bool smooth);
  67. void AppendStar(int nbranches, float r1, float r2,
  68. int fade = 0, int fade2 = 0);
  69. void AppendExpandedStar(int nbranches, float r1, float r2, float extrar);
  70. void AppendDisc(int nsides, float r, int fade = 0);
  71. void AppendSimpleTriangle(float size, int fade = 0);
  72. void AppendSimpleQuad(float size, int fade = 0);
  73. void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0);
  74. void AppendCog(int nbsides, float h, float r1, float r2,
  75. float r12, float r22, float sidemul, int offset);
  76. private:
  77. vec4 m_color, m_color2;
  78. Array<uint16_t> m_indices;
  79. Array<vec3, vec3, vec4> m_vert;
  80. Array<int, int> m_cursors;
  81. /* FIXME: put this in a separate class so that we can copy meshes. */
  82. struct
  83. {
  84. Shader *shader;
  85. ShaderAttrib coord, norm, color;
  86. ShaderUniform modelview, proj, normalmat, damage;
  87. VertexDeclaration *vdecl;
  88. VertexBuffer *vbo;
  89. IndexBuffer *ibo;
  90. int vertexcount, indexcount;
  91. }
  92. m_gpu;
  93. };
  94. } /* namespace lol */
  95. #endif /* __EASYMESH_EASYMESH_H__ */