QGraphicsBillboardTransform: how to use!?
-
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);
}@ -
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);
}@ -
Merged the two identical threads. Please do not double post. Thanks!