Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How to translate Qt3d shapes (like a sphere) continually.

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

Scheduled Pinned Locked Moved Game Development
14 Posts 3 Posters 4.3k Views
  • 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 Offline
    E Offline
    eyadshami
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • E Offline
        E Offline
        eyadshami
        wrote on last edited by
        #3

        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
        0
        • E Offline
          E Offline
          eyadshami
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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
            0
            • E Offline
              E Offline
              eyadshami
              wrote on last edited by
              #6

              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
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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
                0
                • E Offline
                  E Offline
                  eyadshami
                  wrote on last edited by
                  #8

                  error: C3861: 'updateGL': identifier not found

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sunil.nair
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      sunil.nair
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        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
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          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
                          0
                          • S Offline
                            S Offline
                            sunil.nair
                            wrote on last edited by
                            #13

                            But, is there any update method in QGLView?

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              sunil.nair
                              wrote on last edited by
                              #14

                              But, is there any update method in QGLView?

                              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