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. QGraphicsBillboardTransform: how to use!?
QtWS25 Last Chance

QGraphicsBillboardTransform: how to use!?

Scheduled Pinned Locked Moved Game Development
3 Posts 2 Posters 1.6k 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.
  • O Offline
    O Offline
    Oleg
    wrote on last edited by
    #1

    Hallo

    How the QGraphicsBillboardTransform is used? simple:

    @QGLBuilder b;
    ...
    QGLSceneNode n = b.finalizedSceneNode();

    QGraphicsBillboardTransform *billboard = new QGraphicsBillboardTransform();

    n->addTransform(billboard);@

    not work.

    I wrote a small test program. There are only two shapes simply pane and sphere. The target is it, when sphere rotates pane remains with the face to the camera. I want to use a pane as a label template. I.e. I will create the texture with the text and apply it to pane.

    Does anyone have an example how to use QGraphicsBillboardTransform?

    Source code of example (not work):
    Header:
    @#ifndef NETVIEW_H
    #define NETVIEW_H
    #include "qglview.h"
    #include "qglscenenode.h"
    #include "qgraphicsbillboardtransform.h"
    class NetView : public QGLView
    {
    public:
    explicit NetView(QWidget *parent = 0);
    protected:
    void initializeGL(QGLPainter *painter);
    void paintGL(QGLPainter *painter);
    private:
    QGLSceneNode *mPane;
    QGraphicsBillboardTransform *mBillboard;
    };
    #endif // NETVIEW_H@

    Cpp:

    @#include "netview.h"
    #include "qglbuilder.h"
    #include "qglsphere.h"
    NetView::NetView(QWidget *parent)
    : QGLView(parent)
    {
    QGLBuilder b;
    b.addPane(QSizeF(1.0, 1.0));
    b.currentNode()->setObjectName("pane");
    b.newSection();
    b << QGLSphere();
    b.currentNode()->setPosition(QVector3D(-1.5, 0.0, 0.0));
    mPane = b.finalizedSceneNode();
    //create a Billboard transform
    mBillboard = new QGraphicsBillboardTransform();
    mPane->addTransform(mBillboard);
    QGLMaterial *m = new QGLMaterial;
    m->setColor(Qt::blue);
    mPane->setMaterial(m);
    mPane->setEffect(QGL::LitMaterial);
    }
    void NetView::initializeGL(QGLPainter *painter)
    {
    }
    void NetView::paintGL(QGLPainter *painter)
    {
    mPane->draw(painter);
    }@

    with kind regards

    Oleg

    1 Reply Last reply
    0
    • O Offline
      O Offline
      Oleg
      wrote on last edited by
      #2

      Hallo

      How the QGraphicsBillboardTransform is used? simple:

      @QGLBuilder b;
      ...
      QGLSceneNode n = b.finalizedSceneNode();

      QGraphicsBillboardTransform *billboard = new QGraphicsBillboardTransform();

      n->addTransform(billboard);@
      not work.

      I wrote a small test program. There are only two shapes simply pane and sphere. The target is it, when sphere rotates pane remains with the face to the camera. I want to use a pane as a label template. I.e. I will create the texture with the text and apply it to pane.

      Does anyone have an example how to use QGraphicsBillboardTransform?

      Source code of example (not work):
      Header:
      @#ifndef NETVIEW_H
      #define NETVIEW_H
      #include "qglview.h"
      #include "qglscenenode.h"
      #include "qgraphicsbillboardtransform.h"
      class NetView : public QGLView
      {
      public:
      explicit NetView(QWidget *parent = 0);
      protected:
      void initializeGL(QGLPainter *painter);
      void paintGL(QGLPainter *painter);
      private:
      QGLSceneNode *mPane;
      QGraphicsBillboardTransform *mBillboard;
      };
      #endif // NETVIEW_H@
      Cpp:

      @#include "netview.h"
      #include "qglbuilder.h"
      #include "qglsphere.h"
      NetView::NetView(QWidget *parent)
      : QGLView(parent)
      {
      QGLBuilder b;
      b.addPane(QSizeF(1.0, 1.0));
      b.currentNode()->setObjectName("pane");
      b.newSection();
      b << QGLSphere();
      b.currentNode()->setPosition(QVector3D(-1.5, 0.0, 0.0));
      mPane = b.finalizedSceneNode();
      //create a Billboard transform
      mBillboard = new QGraphicsBillboardTransform();
      mPane->addTransform(mBillboard);
      QGLMaterial *m = new QGLMaterial;
      m->setColor(Qt::blue);
      mPane->setMaterial(m);
      mPane->setEffect(QGL::LitMaterial);
      }
      void NetView::initializeGL(QGLPainter *painter)
      {
      }
      void NetView::paintGL(QGLPainter *painter)
      {
      mPane->draw(painter);
      }@

      with kind regards

      Oleg

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        Merged the two identical threads. Please do not double post. Thanks!

        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