What excatly are you trying to achieve? That the position of the sphere is updated when data is incoming as the QVector3D?
Then you simply have to set the translation on the sphereTransform to the vector and the scene will be updated. On 31.01.2018 15:02, Dimitrios Anagnostakis wrote: > > Hi all, > > > > I’m trying to make a scene in Qt3D which shows an STL object model and > a 3D point which is updated with real time data from a tracking software. > > > > What I have so far is to display the object and a 3d sphere as a 3d > point. Below is my code: > > The position of the sphere is set using the > sphereTransform->setTranslation(QVector3D(-1.0f,10.0f,7.0f)); > > > > How can I set this to be updated directly by the incoming data which > is in the form of QVector3d with x, y and z? > > > > Thank you in advance for any help. > > > > Regards, Dimis. > > > > In the scenemodifier.cpp: > > > > SceneModifier::SceneModifier(Qt3DCore::QEntity*rootEntity) > :m_rootEntity(rootEntity) > { > > LoadSTL(); > displayPoints(); > > } > > > > > > voidSceneModifier::LoadSTL() > > { > > QUrldata=QUrl::fromLocalFile("C:/Qt/Examples/stylus_tip/block1.stl"); > > Qt3DRender::QMesh*partMesh=newQt3DRender::QMesh; > > partMesh->setSource(data); > > > > //PartTransform > > Qt3DCore::QTransform*partTransform=newQt3DCore::QTransform(); > > //partTransform->setScale(4.0f); > > //partTransform->setTranslation(QVector3D(5.0f,-4.0f,0.0f)); > > > > //Partmaterial > > > Qt3DExtras::QPhongMaterial*partMaterial=newQt3DExtras::QPhongMaterial(); > > partMaterial->setDiffuse(QColor(0,200,255)); > > > > //part(STLmodel) > > m_partEntity=newQt3DCore::QEntity(m_rootEntity); > > m_partEntity->addComponent(partMesh); > > m_partEntity->addComponent(partMaterial); > > m_partEntity->addComponent(partTransform); > > } > > > > voidSceneModifier::displayPoints() > > { > > //Sphereshapedata > > Qt3DExtras::QSphereMesh*sphereMesh=newQt3DExtras::QSphereMesh(); > > sphereMesh->setRadius(0.75f);; > > > > //Spheremeshtransform > > Qt3DCore::QTransform*sphereTransform=newQt3DCore::QTransform(); > > sphereTransform->setTranslation(QVector3D(-1.0f,10.0f,7.0f)); > > sphereTransform->setScale(1.3f); > > > > //Spherematerial > > > Qt3DExtras::QPhongMaterial*sphereMaterial=newQt3DExtras::QPhongMaterial(); > > sphereMaterial->setDiffuse(QColor(250,250,0)); > > > > //Sphere > > m_sphereEntity=newQt3DCore::QEntity(m_rootEntity); > > m_sphereEntity->addComponent(sphereMesh); > > m_sphereEntity->addComponent(sphereMaterial); > > m_sphereEntity->addComponent(sphereTransform); > > > > } > > > > In the main: > > > > intmain(intargc,char*argv[]) > { > QApplicationa(argc,argv); > > Qt3DExtras::Qt3DWindowview; > > Qt3DCore::QEntity*rootEntity=newQt3DCore::QEntity; > > Qt3DRender::QCamera*camera=view.camera(); > camera->lens()->setPerspectiveProjection(45.0f,16.0f/9.0f,0.1f,1000.0f); > camera->setPosition(QVector3D(0,0,320.0f)); > camera->setUpVector(QVector3D(0,1,0)); > camera->setViewCenter(QVector3D(0,0,0)); > > > Qt3DExtras::QOrbitCameraController*camController=newQt3DExtras::QOrbitCameraController(rootEntity); > camController->setCamera(camera); > > Qt3DCore::QEntity*lightEntity=newQt3DCore::QEntity(rootEntity); > Qt3DRender::QPointLight*light=newQt3DRender::QPointLight(lightEntity); > light->setColor("white"); > light->setIntensity(1); > lightEntity->addComponent(light); > > Qt3DCore::QTransform*lightTransform=newQt3DCore::QTransform(lightEntity); > lightTransform->setTranslation(QVector3D(50,-50,-150.0f)); > lightEntity->addComponent(lightTransform); > > Qt3DCore::QEntity*lightEntity2=newQt3DCore::QEntity(rootEntity); > Qt3DRender::QPointLight*light2=newQt3DRender::QPointLight(lightEntity2); > light2->setColor("white"); > light2->setIntensity(1); > lightEntity2->addComponent(light2); > > > Qt3DCore::QTransform*lightTransform2=newQt3DCore::QTransform(lightEntity2); > lightTransform2->setTranslation(QVector3D(-50,50,150.0f)); > lightEntity2->addComponent(lightTransform2); > > SceneModifier*modifier=newSceneModifier(rootEntity); > > view.setRootEntity(rootEntity); > view.show(); > > returna.exec(); > } > > > > The display is: > > > > > > > > > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest