Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to translate Qt3d shapes (like a sphere) continually.

    Game Development
    3
    14
    3445
    Loading More Posts
    • 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.
    • E
      eyadshami last edited by

      hi , i am trying to draw sphere that changes its place continually, i tried this :

      @
      void GLWidget::paintGL(QGLPainter *painter)
      {
      while (true)
      {
      vertex.setX(qrand()%5);
      vertex.setY(qrand()%5);
      vertex.setZ(qrand()%5);
      painter->modelViewMatrix().translate(vertex);
      sphere->draw(painter);
      }
      }
      @

      where :
      " sphere " is a QGLSceneNode.
      " vertex " is a QVector3D.

      the result of the previous code is :
      the sphere position is being changed when i zoom in or out or when i move around it (with the mouse ) , but not automatically !!???
      i think i must use QGLBuffer .

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        You should not use a while loop, you are locking your program in paintGL and he can't to anything else. Just use the standard approach that updates your GL scene at a regular fps and you should be good.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • E
          eyadshami last edited by

          thank you very much , i am glad to be here ....
          my class descending from "QGLView" and it seems that there is no way to call updateGL() from it ,so what should i do ? .
          on the other hand , i have made another project that uses "QGLWidget" and " QGLBuffer" , and i easily used updateGL() , however the advantage of using " QGLView " class is the ease of using " QGLBuilder " to build spheres .
          is there away to call " updateGL() " in a class that inherit from "QGLView " class , or a way to use " QGLSphere " in a class inherit from "QGLWidget "?

          1 Reply Last reply Reply Quote 0
          • E
            eyadshami last edited by

            i couldn't call " updateGL " from my class that inherits from " QGLView "

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              AFAIK, QGLView inherit QGLWidget so you should be able to call updateGL

              What error are you getting ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 0
              • E
                eyadshami last edited by

                in the documentation of " QGLView " class , there is no definition for "updateGL" i know that QGLView inherit from QGLWidget but i think they had changed it to "private" in the QGLView class , i am not sure

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  What error are you getting when calling updateGL ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply Reply Quote 0
                  • E
                    eyadshami last edited by

                    error: C3861: 'updateGL': identifier not found

                    1 Reply Last reply Reply Quote 0
                    • S
                      sunil.nair last edited by

                      Hi, I am stuck with the same problem. Could you figure out a solution for the same?

                      1 Reply Last reply Reply Quote 0
                      • S
                        sunil.nair last edited by

                        Hi, I am stuck with the same problem. Could you figure out a solution for the same?

                        1 Reply Last reply Reply Quote 0
                        • SGaist
                          SGaist Lifetime Qt Champion last edited by

                          I've made a mistake, QGLView inherits QWindow where there's no updateGL.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply Reply Quote 0
                          • SGaist
                            SGaist Lifetime Qt Champion last edited by

                            I've made a mistake, QGLView inherits QWindow where there's no updateGL.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply Reply Quote 0
                            • S
                              sunil.nair last edited by

                              But, is there any update method in QGLView?

                              1 Reply Last reply Reply Quote 0
                              • S
                                sunil.nair last edited by

                                But, is there any update method in QGLView?

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post