Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QT 3D

QT 3D

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jafar VM
    wrote on last edited by
    #1

    Hi ,
    I am new to qt3d.i have a requirement like i need to load external 3d models(*.obj or *.stl) to a surface3d with xyz axis.

    thanks in advance for any help

    Jafar

    1 Reply Last reply
    0
    • oria66O Offline
      oria66O Offline
      oria66
      wrote on last edited by
      #2

      Hi @Jafar-VM. Months ago I develop this single example trying to do it, and It works.

      https://gitlab.com/homerooria/3d-model-rotation

      I hope this helps you. If you have any doubt, don't hesitate to ask.

      Good luck

      The truth is out there

      1 Reply Last reply
      3
      • J Offline
        J Offline
        Jafar VM
        wrote on last edited by
        #3

        Hi ,

        Thanks for ur help.

        can we draw xyz axis along with that scene3d?

        oria66O 1 Reply Last reply
        0
        • J Jafar VM

          Hi ,

          Thanks for ur help.

          can we draw xyz axis along with that scene3d?

          oria66O Offline
          oria66O Offline
          oria66
          wrote on last edited by
          #4

          @Jafar-VM Yes, you can. In fact, the final version of the prototype I send you has an XYZ axis in the corner of the scene. But, unfortunately, it belongs to a commercial app.

          Now that you know is possible, do you want to think over it and try by yourself? Or you want that I upload the code?

          Clues:

          1. Do a 3dmodel of an arrow.
          2. Load it into your app and make three Entities.
          3. Modify the rotation axis to fulfill your requirements.

          If you have any doubts, don't hesitate to ask!!!!!

          Good luck

          The truth is out there

          J 1 Reply Last reply
          0
          • oria66O oria66

            @Jafar-VM Yes, you can. In fact, the final version of the prototype I send you has an XYZ axis in the corner of the scene. But, unfortunately, it belongs to a commercial app.

            Now that you know is possible, do you want to think over it and try by yourself? Or you want that I upload the code?

            Clues:

            1. Do a 3dmodel of an arrow.
            2. Load it into your app and make three Entities.
            3. Modify the rotation axis to fulfill your requirements.

            If you have any doubts, don't hesitate to ask!!!!!

            Good luck

            J Offline
            J Offline
            Jafar VM
            wrote on last edited by
            #5

            @oria66 it would be great if you could share the code.

            thanks in advance

            1 Reply Last reply
            0
            • oria66O Offline
              oria66O Offline
              oria66
              wrote on last edited by
              #6

              @Jafar-VM. Here there are the Entities. Enjoy!!!!

                                  Entity{
                                      id: axisManipulationEntity
              
                                      Transform {
                                          id: carTransform3
                                          property real userAngle: 0.0
              
              
                                          matrix: {
                                              var m = Qt.matrix4x4();
                                              m.rotate(userAngle, Qt.vector3d(0, 0, 1));
                                              return m;
                                          }
                                      }
              
                                      components: [ , , carTransform3]
              
              
                                      Entity {
                                          id: arrowZEntity
              
                                          Mesh{
                                              id:axisZ
                                              source: "res/arrow.obj"
                                          }
              
                                          PhongMaterial{
                                              id: zMaterial
                                              ambient: Qt.rgba(0.0, 0.0, 1.0, 1.0)
                                              diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                              specular: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                              shininess: 150.0
                                          }
              
                                          Transform {
                                              id: arrowZTransform
                                              property real userAngle: 0.0
                                              property real x: 0
                                              property real y: 0
                                              property real z: 0
              
                                              rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), 0)
              
                                              matrix: {
                                                  var m = Qt.matrix4x4();
                                                  m.rotate(userAngle, Qt.vector3d(0, 1, 0))
                                                  m.translate(Qt.vector3d(x, y, z))
                                                  return m;
                                              }
                                          }
              
                                          components: [ axisZ, zMaterial, arrowZTransform]
                                      }
              
                                      Entity {
                                          id: arrowXEntity
              
                                          Mesh{
                                              id:axisX
                                              source: "res/arrow.obj"
                                          }
              
                                          PhongMaterial{
                                              id: xMaterial
                                              ambient: Qt.rgba(1.0, 0.0, 0.0, 1.0)
                                              diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                              specular: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                              shininess: 150.0
                                          }
              
                                          Transform {
                                              id: arrowXTransform
                                              property real userAngle: 0.0
                                              property real x: 0
                                              property real y: 0
                                              property real z: 0
              
                                              rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), 90)
              
                                              matrix: {
                                                  var m = Qt.matrix4x4();
                                                  m.rotate(userAngle + 90, Qt.vector3d(0, 1, 0))
                                                  m.translate(Qt.vector3d(x, y, z))
                                                  return m;
                                              }
              
                                          }
              
                                          components: [ axisX, xMaterial, arrowXTransform]
                                      }
              
                                      Entity {
                                          id: arrowYEntity
              
                                          Mesh{
                                              id:axisY
                                              source: "res/arrow.obj"
                                          }
              
                                          PhongMaterial{
                                              id: yMaterial
                                              ambient: Qt.rgba(0.0, 1.0, 0.0, 1.0)
                                              diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                              specular: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                              shininess: 150.0
                                          }
              
                                          Transform {
                                              id: arrowYTransform
                                              property real userAngle: 0.0
                                              property real x: 0
                                              property real y: 0
                                              property real z: 0
              
                                              matrix: {
                                                  var m = Qt.matrix4x4();
                                                  m.rotate(-90, Qt.vector3d(1, 0, 0))
                                                  m.translate(Qt.vector3d(x, y, z))
                                                  return m;
                                              }
              
                                          }
                                          components: [ axisY, yMaterial, arrowYTransform]
                                      }
              
                                  }
              

              Good luck

              The truth is out there

              J 1 Reply Last reply
              1
              • oria66O oria66

                @Jafar-VM. Here there are the Entities. Enjoy!!!!

                                    Entity{
                                        id: axisManipulationEntity
                
                                        Transform {
                                            id: carTransform3
                                            property real userAngle: 0.0
                
                
                                            matrix: {
                                                var m = Qt.matrix4x4();
                                                m.rotate(userAngle, Qt.vector3d(0, 0, 1));
                                                return m;
                                            }
                                        }
                
                                        components: [ , , carTransform3]
                
                
                                        Entity {
                                            id: arrowZEntity
                
                                            Mesh{
                                                id:axisZ
                                                source: "res/arrow.obj"
                                            }
                
                                            PhongMaterial{
                                                id: zMaterial
                                                ambient: Qt.rgba(0.0, 0.0, 1.0, 1.0)
                                                diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                                specular: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                                shininess: 150.0
                                            }
                
                                            Transform {
                                                id: arrowZTransform
                                                property real userAngle: 0.0
                                                property real x: 0
                                                property real y: 0
                                                property real z: 0
                
                                                rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), 0)
                
                                                matrix: {
                                                    var m = Qt.matrix4x4();
                                                    m.rotate(userAngle, Qt.vector3d(0, 1, 0))
                                                    m.translate(Qt.vector3d(x, y, z))
                                                    return m;
                                                }
                                            }
                
                                            components: [ axisZ, zMaterial, arrowZTransform]
                                        }
                
                                        Entity {
                                            id: arrowXEntity
                
                                            Mesh{
                                                id:axisX
                                                source: "res/arrow.obj"
                                            }
                
                                            PhongMaterial{
                                                id: xMaterial
                                                ambient: Qt.rgba(1.0, 0.0, 0.0, 1.0)
                                                diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                                specular: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                                shininess: 150.0
                                            }
                
                                            Transform {
                                                id: arrowXTransform
                                                property real userAngle: 0.0
                                                property real x: 0
                                                property real y: 0
                                                property real z: 0
                
                                                rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), 90)
                
                                                matrix: {
                                                    var m = Qt.matrix4x4();
                                                    m.rotate(userAngle + 90, Qt.vector3d(0, 1, 0))
                                                    m.translate(Qt.vector3d(x, y, z))
                                                    return m;
                                                }
                
                                            }
                
                                            components: [ axisX, xMaterial, arrowXTransform]
                                        }
                
                                        Entity {
                                            id: arrowYEntity
                
                                            Mesh{
                                                id:axisY
                                                source: "res/arrow.obj"
                                            }
                
                                            PhongMaterial{
                                                id: yMaterial
                                                ambient: Qt.rgba(0.0, 1.0, 0.0, 1.0)
                                                diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                                specular: Qt.rgba(0.5, 0.5, 0.5, 1.0)
                                                shininess: 150.0
                                            }
                
                                            Transform {
                                                id: arrowYTransform
                                                property real userAngle: 0.0
                                                property real x: 0
                                                property real y: 0
                                                property real z: 0
                
                                                matrix: {
                                                    var m = Qt.matrix4x4();
                                                    m.rotate(-90, Qt.vector3d(1, 0, 0))
                                                    m.translate(Qt.vector3d(x, y, z))
                                                    return m;
                                                }
                
                                            }
                                            components: [ axisY, yMaterial, arrowYTransform]
                                        }
                
                                    }
                

                Good luck

                J Offline
                J Offline
                Jafar VM
                wrote on last edited by
                #7

                @oria66 hi,thanks for ur help.it worked out for me

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved