[Interest] [QT3D] Has anyone figured out how to use a QSkyboxEntity?
Igor Mironchik
igor.mironchik at gmail.com
Sun Nov 19 07:57:46 CET 2017
Hi,
On 19.11.2017 01:00, Pierre Chicoine wrote:
> This is the only place I found on the Internet that Igor sent me.https://github.com/igormironchik/3Dtree
> <https://github.com/igormironchik/3Dtree>
> Thank Igor.
> Strange to note. It only works in his program in Kubuntu. When I try it, using his program with Android,
> or mine, in Kubuntu or Android, I get this message, which repeats over and over again:
It works on Windows too, I guess that it will work on MacOS. But I guess
that it won't work on any mobile platform because 3Dtree mixes Qt
widgets with Qt3D, I embed Qt3DExtras::Qt3DWindow to Qt widget based
application...
I tested simplest example on Android 4.2.2 and it works...
int main( int argc, char ** argv )
{
QApplication app( argc, argv );
QScopedPointer< Qt3DExtras::Qt3DWindow > view( new
Qt3DExtras::Qt3DWindow );
QScopedPointer< Qt3DCore::QEntity > root( new Qt3DCore::QEntity );
// Camera
Qt3DRender::QCamera * cameraEntity = view->camera();
cameraEntity->lens()->setPerspectiveProjection(
45.0f, 16.0f / 9.0f, 0.1f, 1000.0f );
cameraEntity->setPosition( QVector3D( 0.0f, 5.0f, 20.0f ) );
cameraEntity->setUpVector( QVector3D( 0.0f, 1.0f, 0.0f ) );
cameraEntity->setViewCenter( QVector3D( 0.0f, 5.0f, 0.0f ) );
Qt3DCore::QEntity * lightEntity = new Qt3DCore::QEntity( root.data() );
Qt3DRender::QPointLight * light = new Qt3DRender::QPointLight(
lightEntity );
light->setColor( Qt::white );
light->setIntensity( 1.0f );
lightEntity->addComponent( light );
Qt3DCore::QTransform * lightTransform = new Qt3DCore::QTransform(
lightEntity );
lightTransform->setTranslation( cameraEntity->position() );
lightEntity->addComponent( lightTransform );
Qt3DExtras::QSkyboxEntity * skyBox = new Qt3DExtras::QSkyboxEntity(
root.data() );
skyBox->setBaseName( QStringLiteral( "qrc:/res/skybox" ) );
skyBox->setExtension( QStringLiteral( ".tga" ) );
const float baseScale = 0.1f;
Qt3DCore::QTransform * skyTransform = new Qt3DCore::QTransform(
skyBox );
skyTransform->setTranslation( QVector3D( 0.0f, baseScale / 8.0f -
0.001f, 0.0f ) );
skyTransform->setScale3D( QVector3D( baseScale, baseScale / 4.0f,
baseScale ) );
skyBox->addComponent( skyTransform );
view->setRootEntity( root.take() );
view->show();
return app.exec();
}
> [Qt3DRender::GLTexture] No QTextureImageData generated from functor yet, texture will be invalid for this frame.
> There a fixed bug In Qt's bug list that shows that this message has been fixed. So obviously, I don't understand
> what I'm doing wrong or it's a real bug.
> So I'm asking once more. Has anyone figured out how to properly use QSkyboxEntity? Any input would be appreciated.
> Thanks
> pQSkyboxEntity=newQt3DExtras::QSkyboxEntity(pQEntity);
> pQSkyboxEntity->setBaseName(:/media/Skyboxes/skybox);
> pQSkyboxEntity->setExtension("tga");
> constfloatbaseScale=0.1f;
> Qt3DCore::QTransform*skyTransform=newQt3DCore::QTransform();
> skyTransform->setTranslation(QVector3D(0.0f,baseScale/8.0f-0.001f,0.0f));
> skyTransform->setScale3D(QVector3D(baseScale,baseScale/4.0f,baseScale));
> pQSkyboxEntity->addComponent(skyTransform);
> }
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171119/d1f2f5d9/attachment.html>
More information about the Interest
mailing list