You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
6.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file 3d_draw_basic_functions.h
  26. */
  27. #ifndef _3D_DRAW_BASIC_FUNCTIONS_H_
  28. #define _3D_DRAW_BASIC_FUNCTIONS_H_
  29. // angle increment to draw a circle, approximated by segments
  30. #define ANGLE_INC( x ) ( 3600 / (x) )
  31. /** draw all solid polygons found in aPolysList
  32. * @param aPolysList = the poligon list to draw
  33. * @param aZpos = z position in board internal units
  34. * @param aThickness = thickness in board internal units
  35. * @param aBiuTo3DUnits = board internal units to 3D units scaling value
  36. * @param aUseTextures = true to use textxures for the polygons
  37. * @param aNormal_Z_Orientation = the normal Z orientation to apply
  38. * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
  39. * If aThickness > 0, a solid object is drawn.
  40. * The top side is located at aZpos + aThickness / 2
  41. * The bottom side is located at aZpos - aThickness / 2
  42. */
  43. void Draw3D_SolidHorizontalPolyPolygons( const SHAPE_POLY_SET& aPolysList,
  44. int aZpos, int aThickness, double aBiuTo3DUnits,
  45. bool aUseTextures,
  46. float aNormal_Z_Orientation );
  47. /** draw a thick segment using 3D primitives, in a XY plane
  48. * @param aStart = YX position of start point in board units
  49. * @param aEnd = YX position of end point in board units
  50. * @param aWidth = width of segment in board units
  51. * @param aThickness = thickness of segment in board units
  52. * @param aZpos = z position of segment in board units
  53. * @param aBiuTo3DUnits = board internal units to 3D units scaling value
  54. * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
  55. * If aThickness > 0, a solid object is drawn.
  56. * The top side is located at aZpos + aThickness / 2
  57. * The bottom side is located at aZpos - aThickness / 2
  58. */
  59. void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd,
  60. int aWidth, int aThickness, int aZpos,
  61. double aBiuTo3DUnits );
  62. /** draw an arc using 3D primitives, in a XY plane
  63. * @param aCenterPos = XY position of the center in board units
  64. * @param aStartPoint = start point coordinate of arc in board units
  65. * @param aWidth = width of the circle in board units
  66. * @param aArcAngle = arc angle in 1/10 degrees
  67. * @param aWidth = thickness of arc
  68. * @param aThickness = thickness of segment in board units
  69. * @param aZpos = z position of segment in board units
  70. * @param aBiuTo3DUnits = board internal units to 3D units scaling value
  71. */
  72. void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint,
  73. double aArcAngle, int aWidth, int aThickness,
  74. int aZpos, double aBiuTo3DUnits );
  75. /** draw a thick cylinder (a tube) using 3D primitives.
  76. * the cylinder axis is parallel to the Z axis
  77. * @param aCenterPos = XY position of the axis cylinder ( board internal units)
  78. * @param aRadius = radius of the cylinder ( board internal units)
  79. * @param aHeight = height of the cylinder ( boardinternal units)
  80. * @param aThickness = tichkness of tube ( boardinternal units)
  81. * @param aZpos = Z position of the bottom side of the cylinder ( board internal units)
  82. * @param aBiuTo3DUnits = board internal units to 3D units scaling value
  83. *
  84. * If aHeight = height of the cylinder is 0, only one ring will be drawn
  85. * If aThickness = 0, only one cylinder (not a tube) will be drawn
  86. */
  87. void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
  88. int aHeight, int aThickness,
  89. int aZpos, double aBiuTo3DUnits );
  90. /** draw an oblong cylinder (oblong tube) using 3D primitives.
  91. * the cylinder axis are parallel to the Z axis
  92. * @param aAxis1Pos = position of the first axis cylinder
  93. * @param aAxis2Pos = position of the second axis cylinder
  94. * @param aRadius = radius of the cylinder ( board internal units )
  95. * @param aHeight = height of the cylinder ( board internal units )
  96. * @param aThickness = tichkness of tube ( board internal units )
  97. * @param aZpos = Z position of the bottom side of the cylinder ( board internal units )
  98. * @param aBiuTo3DUnits = board internal units to 3D units scaling value
  99. */
  100. void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
  101. int aRadius, int aHeight, int aThickness,
  102. int aZpos, double aBiuTo3DUnits );
  103. /**
  104. * Set the current 3D color from a Kicad color, with optional transparency
  105. * @param aColor = a EDA_COLOR_T kicad color index
  106. * @param aTransparency = the color transparency (default = 1.0 = no transparency)
  107. */
  108. void SetGLColor( EDA_COLOR_T aColor, double aTransparency = 1.0 );
  109. /**
  110. * Set the current 3D color from a S3D_COLOR color, with optional transparency
  111. * @param aColor = a S3D_COLOR RGB color index
  112. * @param aTransparency = the color transparency (default = 1.0 = no transparency)
  113. */
  114. void SetGLColor( S3D_COLOR& aColor, float aTransparency );
  115. /**
  116. * Set a texture id and a scale to apply when rendering the polygons
  117. * @param text_id = texture ID created by glGenTextures
  118. * @param scale = scale to apply to texture coords
  119. */
  120. void SetGLTexture( GLuint text_id, float scale );
  121. #endif // _3D_DRAW_BASIC_FUNCTIONS_H_