PolyScreenMesh.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. Copyright (C) 2011 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #pragma once
  20. #include "PolyGlobals.h"
  21. #include "PolyScreenEntity.h"
  22. #include "PolyMesh.h"
  23. namespace Polycode {
  24. class Image;
  25. class Texture;
  26. /**
  27. * 2D Mesh. ScreenMesh is the base for most geometry-based screen entities. It's based aroudn a Mesh instance, like its 3D counterpart (SceneMesh), but currently has fewer options.
  28. * @see Mesh
  29. */
  30. class _PolyExport ScreenMesh : public ScreenEntity {
  31. public:
  32. /**
  33. * Creates the screen mesh and loads a mesh from a file name.
  34. */
  35. ScreenMesh(const String& fileName);
  36. /**
  37. * Creates the screen mesh from existing Mesh.
  38. */
  39. ScreenMesh(Mesh *mesh);
  40. /**
  41. * Create an empty screen mesh of specified type. See Mesh for available mesh types.
  42. */
  43. ScreenMesh(int meshType);
  44. // Static constructor wrappers for bindings
  45. static ScreenMesh *ScreenMeshWithType(int meshType);
  46. static ScreenMesh *ScreenMeshWithMesh(Mesh *mesh);
  47. virtual ~ScreenMesh();
  48. void Render();
  49. /**
  50. * Returns the mesh for this screen mesh.
  51. * @return The mesh.
  52. */
  53. Mesh *getMesh() const;
  54. /**
  55. * Returns the texture associated with the mesh.
  56. */
  57. Texture *getTexture() const;
  58. /**
  59. * Loads a texture from an image file.
  60. * @param fileName Path to the image file.
  61. */
  62. void loadTexture(const String& fileName);
  63. /**
  64. * Loads a texture from an image instance.
  65. * @param image Image instance.
  66. */
  67. void loadTexture(Image *image);
  68. /**
  69. * Applies a texture
  70. * @param texture to apply.
  71. */
  72. void setTexture(Texture *texture);
  73. /**
  74. * If this is set to true, the lines in wireframe meshes will be anti-aliased if the support is available in the renderer.
  75. */
  76. bool lineSmooth;
  77. Number lineWidth;
  78. /**
  79. * If true, will delete its Mesh upon destruction. (defaults to true)
  80. */
  81. bool ownsMesh;
  82. /**
  83. * Updates hit.width, hit.height to coordinates of mesh.
  84. */
  85. void updateHitBox();
  86. protected:
  87. Mesh *mesh;
  88. Texture *texture;
  89. };
  90. }