Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3DExtras Weird behaviour with materials
Qt 6.11 is out! See what's new in the release blog

Qt3DExtras Weird behaviour with materials

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 263 Views 1 Watching
  • 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.
  • B Offline
    B Offline
    BuzzBen
    wrote on last edited by BuzzBen
    #1

    Hi! This is my first entry I hope I can get some knowlegable fellow to help

    Release: Qt 6.4.3
    Language : C++
    Compiler: 6.4.3_msvc2019_64
    IDE: Visual Studio Community 2022 (17.4.3)

    Required modules:

    #include <QApplication>
    #include <Qt3DCore/QEntity>
    #include <Qt3DCore/QTransform>
    #include <Qt3DRender/QCamera>
    #include <Qt3DExtras/Qt3DWindow>
    #include <Qt3DExtras/QOrbitCameraController>
    #include <Qt3DExtras/QSphereMesh>
    #include <Qt3DExtras/QTorusMesh>
    

    Problematic Modules :

    #include <Qt3DExtras/QGoochMaterial>
    #include <Qt3DExtras/QMetalRoughMaterial>
    #include <Qt3DExtras/QDiffuseSpecularMaterial>
    #include <Qt3DExtras/QTextureMaterial>
    #include <Qt3DExtras/QPhongMaterial> // deprecated class
    #include <Qt3DExtras/QPerVertexColorMaterial>
    

    Scene creation Code: (example using class QPerVertexColorMaterial)

    Qt3DCore::QEntity* createScene()
    {
    	Qt3DCore::QEntity* rootEntity = new Qt3DCore::QEntity;
    
    	Qt3DRender::QMaterial* material = new Qt3DExtras::QPerVertexColorMaterial(rootEntity);
    
    	Qt3DCore::QEntity* torusEntity = new Qt3DCore::QEntity(rootEntity);
    	Qt3DExtras::QTorusMesh* torusMesh = new Qt3DExtras::QTorusMesh;
    	torusMesh->setRadius(5);
    	torusMesh->setMinorRadius(1);
    	torusMesh->setRings(100);
    	torusMesh->setSlices(20);
    
    	Qt3DCore::QTransform* torusTransform = new Qt3DCore::QTransform;
    	torusTransform->setScale3D(QVector3D(1.5, 1, 0.5));
    	torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f));
    
    	torusEntity->addComponent(torusMesh);
    	torusEntity->addComponent(torusTransform);
    	torusEntity->addComponent(material);
    
    	Qt3DCore::QEntity* sphereEntity = new Qt3DCore::QEntity(rootEntity);
    	Qt3DExtras::QSphereMesh* sphereMesh = new Qt3DExtras::QSphereMesh;
    	sphereMesh->setRadius(3);
    	sphereMesh->setGenerateTangents(true);
    
    	return rootEntity;
    }
    

    With the main function:

    int main(int argc, char* argv[])
    {
    
    	QGuiApplication a(argc, argv);
    
    	Qt3DExtras::Qt3DWindow view;
    
    	Qt3DCore::QEntity* scene = createScene();
    
    	Qt3DRender::QCamera* camera = view.camera();
    	camera->lens()->setPerspectiveProjection(40.0f, 16.0f / 9.0f, 0.1f, 1000.0f);
    	camera->setPosition(QVector3D(0, 0, 40.0f));
    	camera->setViewCenter(QVector3D(0, 0, 0));
    
    	Qt3DExtras::QOrbitCameraController* camController = new Qt3DExtras::QOrbitCameraController(scene);
    	camController->setLinearSpeed(50.0f);
    	camController->setLookSpeed(180.0f);
    	camController->setCamera(camera);
    
    	view.setRootEntity(scene);
    	view.show();
    
    	return a.exec();
    }
    

    Expected behaviour : Run without issue.. (obviously)

    Current Behaviour
    With classes:

    Qt3DExtras::QPerVertexColorMaterial
    Qt3DExtras::QGoochMaterial
    

    The geometry is not rendered at all.

    Otherwise, with classes:

    Qt3DExtras::QMetalRoughMaterial
    Qt3DExtras::QDiffuseSpecularMaterial
    Qt3DExtras::QTextureMaterial
    Qt3DExtras::QPhongMaterial
    

    The geometry renders correctly but a "memory access violation" exception is raised whenever the app is closed.
    (Raised in QATOMIC_CXX11_H in a pile of 37)

    N.B. This code is partially inspired from Qt 6.4.3 documentation: Qt3D simple example. Some parts from the original example were not compiling so they have been removed.

    Any idea?

    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