PolyScenePrimitive.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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=0.0f,Number v5=0.0f);
  39. virtual ~ScenePrimitive();
  40. void setPrimitiveOptions(int type, Number v1=1.0f, Number v2=1.0f, Number v3=1.0f,Number v4=0.0f,Number v5=0.0f);
  41. void recreatePrimitive();
  42. /**
  43. * A cube.
  44. * v1 - X size
  45. * v2 - Y size
  46. * v3 - Z size
  47. */
  48. static const int TYPE_BOX = 0;
  49. /**
  50. * A horizontal plane.
  51. * v1 - X size
  52. * v2 - Z size
  53. */
  54. static const int TYPE_PLANE = 1;
  55. /**
  56. * A vertical plane.
  57. * v1 - X size
  58. * v2 - Y size
  59. */
  60. static const int TYPE_VPLANE = 2;
  61. /**
  62. * A cylinder.
  63. * v1 - Cylinder length
  64. * v2 - Cylinder radius
  65. * v3 - Number of segments.
  66. */
  67. static const int TYPE_CYLINDER = 3;
  68. /**
  69. * A cylinder.
  70. * v1 - Cylinder length
  71. * v2 - Cylinder radius
  72. * v3 - Number of segments.
  73. */
  74. static const int TYPE_UNCAPPED_CYLINDER = 4;
  75. /**
  76. * A sphere.
  77. * v1 - Sphere radius
  78. * v2 - Lat segments
  79. * v3 - Long segments
  80. */
  81. static const int TYPE_SPHERE = 5;
  82. /**
  83. * A torus.
  84. * v1 - Torus radius.
  85. * v2 - Pipe radius.
  86. * v3 - Number of ring segments.
  87. * v4- Number of pipe segments.
  88. */
  89. static const int TYPE_TORUS = 6;
  90. /**
  91. * A cone.
  92. * v1 - Cone length.
  93. * v2 - Cone raidus.
  94. * v3 - Number of segments.
  95. */
  96. static const int TYPE_CONE = 7;
  97. /**
  98. * A 2D circle.
  99. * v1 - X size
  100. * v2 - Y size
  101. * v3 - Number of segments
  102. */
  103. static const int TYPE_CIRCLE = 8;
  104. /**
  105. * An ico sphere.
  106. * v1 - Sphere radius
  107. * v2 - number of subdivisions
  108. */
  109. static const int TYPE_ICOSPHERE = 9;
  110. /**
  111. * An ico sphere.
  112. * v1 - Sphere radius
  113. * v2 - number of subdivisions
  114. */
  115. static const int TYPE_OCTOSPHERE = 10;
  116. /**
  117. * A 2D line circle.
  118. * v1 - X size
  119. * v2 - Y size
  120. * v3 - Number of segments
  121. */
  122. static const int TYPE_LINE_CIRCLE = 11;
  123. int getPrimitiveType() const;
  124. Number getPrimitiveParameter1() const;
  125. Number getPrimitiveParameter2() const;
  126. Number getPrimitiveParameter3() const;
  127. Number getPrimitiveParameter4() const;
  128. Number getPrimitiveParameter5() const;
  129. virtual Entity *Clone(bool deepClone, bool ignoreEditorOnly) const;
  130. virtual void applyClone(Entity *clone, bool deepClone, bool ignoreEditorOnly) const;
  131. protected:
  132. int type;
  133. Number v1;
  134. Number v2;
  135. Number v3;
  136. Number v4;
  137. Number v5;
  138. };
  139. }