PolyScenePrimitive.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 "PolySceneMesh.h"
  22. #include "PolyMesh.h"
  23. namespace Polycode {
  24. /**
  25. * 3D primitive mesh.
  26. */
  27. class _PolyExport ScenePrimitive : public SceneMesh {
  28. public:
  29. /**
  30. * Create a primitive mesh of specified type and size.
  31. * @param type Type of primitive to create. Current types are ScenePrimitive::TYPE_BOX, ScenePrimitive::TYPE_PLANE, ScenePrimitive::TYPE_VPLANE, ScenePrimitive::TYPE_SPHERE, ScenePrimitive::TYPE_CYLINDER, ScenePrimitive::TYPE_CONE and ScenePrimitive::TYPE_TORUS
  32. * @param v1 See the constant primitive types for values for these parameters
  33. * @param v2 See the constant primitive types for values for these parameters
  34. * @param v3 See the constant primitive types for values for these parameters
  35. * @param v4 See the constant primitive types for values for these parameters
  36. * @param v5 See the constant primitive types for values for these parameters
  37. */
  38. ScenePrimitive(int type, Number v1=1.0f, Number v2=1.0f, Number v3=1.0f,Number v4=1.0f,Number v5=1.0f);
  39. virtual ~ScenePrimitive();
  40. void setPrimitiveOptions(int type, Number v1=1.0f, Number v2=1.0f, Number v3=1.0f,Number v4=1.0f,Number v5=1.0f);
  41. void recreatePrimitive();
  42. /**
  43. * A cube.
  44. * v1 - X size
  45. * v2 - Y size
  46. * v3 - Z size
  47. * v4 - # of tiles
  48. */
  49. static const int TYPE_BOX = 0;
  50. /**
  51. * A horizontal plane.
  52. * v1 - X size
  53. * v2 - Z size
  54. * v3 - # of tiles
  55. */
  56. static const int TYPE_PLANE = 1;
  57. /**
  58. * A vertical plane.
  59. * v1 - X size
  60. * v2 - Y size
  61. * v3 - # of tiles
  62. */
  63. static const int TYPE_VPLANE = 2;
  64. /**
  65. * A cylinder.
  66. * v1 - Cylinder length
  67. * v2 - Cylinder radius
  68. * v3 - Number of segments.
  69. * v4 - # of tiles
  70. */
  71. static const int TYPE_CYLINDER = 3;
  72. /**
  73. * A cylinder.
  74. * v1 - Cylinder length
  75. * v2 - Cylinder radius
  76. * v3 - Number of segments.
  77. * v4 - # of tiles
  78. */
  79. static const int TYPE_UNCAPPED_CYLINDER = 4;
  80. /**
  81. * A sphere.
  82. * v1 - Sphere radius
  83. * v2 - Lat segments
  84. * v3 - Long segments
  85. * v4 - # of tiles
  86. */
  87. static const int TYPE_SPHERE = 5;
  88. /**
  89. * A torus.
  90. * v1 - Torus radius.
  91. * v2 - Pipe radius.
  92. * v3 - Number of ring segments.
  93. * v4 - Number of pipe segments.
  94. * v5 - # of tiles
  95. */
  96. static const int TYPE_TORUS = 6;
  97. /**
  98. * A cone.
  99. * v1 - Cone length.
  100. * v2 - Cone raidus.
  101. * v3 - Number of segments.
  102. * v4 - # of tiles
  103. */
  104. static const int TYPE_CONE = 7;
  105. /**
  106. * A 2D circle.
  107. * v1 - X size
  108. * v2 - Y size
  109. * v3 - Number of segments
  110. * v4 - # of tiles
  111. */
  112. static const int TYPE_CIRCLE = 8;
  113. /**
  114. * An ico sphere.
  115. * v1 - Sphere radius
  116. * v2 - number of subdivisions
  117. */
  118. static const int TYPE_ICOSPHERE = 9;
  119. /**
  120. * An ico sphere.
  121. * v1 - Sphere radius
  122. * v2 - number of subdivisions
  123. */
  124. static const int TYPE_OCTOSPHERE = 10;
  125. /**
  126. * A 2D line circle.
  127. * v1 - X size
  128. * v2 - Y size
  129. * v3 - Number of segments
  130. * v4 - # of tiles
  131. */
  132. static const int TYPE_LINE_CIRCLE = 11;
  133. int getPrimitiveType() const;
  134. Number getPrimitiveParameter1() const;
  135. Number getPrimitiveParameter2() const;
  136. Number getPrimitiveParameter3() const;
  137. Number getPrimitiveParameter4() const;
  138. Number getPrimitiveParameter5() const;
  139. virtual Entity *Clone(bool deepClone, bool ignoreEditorOnly) const;
  140. virtual void applyClone(Entity *clone, bool deepClone, bool ignoreEditorOnly) const;
  141. protected:
  142. int type;
  143. Number v1;
  144. Number v2;
  145. Number v3;
  146. Number v4;
  147. Number v5;
  148. };
  149. }