AxisHelper.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2019 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of Qt Quick 3D.
  7. **
  8. ** $QT_BEGIN_LICENSE:GPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU
  19. ** General Public License version 3 or (at your option) any later version
  20. ** approved by the KDE Free Qt Foundation. The licenses are as published by
  21. ** the Free Software Foundation and appearing in the file LICENSE.GPL3
  22. ** included in the packaging of this file. Please review the following
  23. ** information to ensure the GNU General Public License requirements will
  24. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
  25. **
  26. ** $QT_END_LICENSE$
  27. **
  28. ****************************************************************************/
  29. import QtQuick
  30. import QtQuick3D
  31. Node {
  32. id: axisGrid_obj
  33. property alias gridColor: gridMaterial.diffuseColor
  34. property alias gridOpacity: gridMaterial.opacity
  35. property alias enableXZGrid: gridXZ.visible
  36. property alias enableXYGrid: gridXY.visible
  37. property alias enableYZGrid: gridYZ.visible
  38. property bool enableAxisLines: true
  39. // Axis Lines
  40. Model {
  41. id: xAxis
  42. source: "#Cube"
  43. position: Qt.vector3d(5000, 0, 0)
  44. scale: Qt.vector3d(100, .05, .05)
  45. visible: enableAxisLines
  46. materials: DefaultMaterial {
  47. lighting: DefaultMaterial.NoLighting
  48. diffuseColor: "red"
  49. }
  50. }
  51. Model {
  52. id: yAxis
  53. source: "#Cube"
  54. position: Qt.vector3d(0, 5000, 0)
  55. scale: Qt.vector3d(0.05, 100, 0.05)
  56. visible: enableAxisLines
  57. materials: DefaultMaterial {
  58. lighting: DefaultMaterial.NoLighting
  59. diffuseColor: "green"
  60. }
  61. }
  62. Model {
  63. id: zAxis
  64. source: "#Cube"
  65. position: Qt.vector3d(0, 0, 5000)
  66. scale: Qt.vector3d(0.05, 0.05, 100)
  67. visible: enableAxisLines
  68. materials: DefaultMaterial {
  69. lighting: DefaultMaterial.NoLighting
  70. diffuseColor: "blue"
  71. }
  72. }
  73. // Grid Lines
  74. DefaultMaterial {
  75. id: gridMaterial
  76. lighting: DefaultMaterial.NoLighting
  77. opacity: 0.5
  78. diffuseColor: Qt.rgba(0.8, 0.8, 0.8, 1)
  79. }
  80. Model {
  81. id: gridXZ
  82. source: "meshes/axisGrid.mesh"
  83. scale: Qt.vector3d(100, 100, 100)
  84. materials: [
  85. gridMaterial
  86. ]
  87. }
  88. Model {
  89. id: gridXY
  90. visible: false
  91. source: "meshes/axisGrid.mesh"
  92. scale: Qt.vector3d(100, 100, 100)
  93. eulerRotation: Qt.vector3d(90, 0, 0)
  94. materials: [
  95. gridMaterial
  96. ]
  97. }
  98. Model {
  99. id: gridYZ
  100. visible: false
  101. source: "meshes/axisGrid.mesh"
  102. scale: Qt.vector3d(100, 100, 100)
  103. eulerRotation: Qt.vector3d(0, 0, 90)
  104. materials: [
  105. gridMaterial
  106. ]
  107. }
  108. }