thank you for your reply,
here is the GitHub repo for my project
https://github.com/Winssench/SkReader.git
here is the function I call in the timer recursively
Qt3DCore::QEntity * MyTimer::myslot(QVector<SkeletonBuilder*> _CurrentBuilder)
{
SkeletonBuilder* Currento = _CurrentBuilder.first();
Qt3DCore::QEntity* test = new Qt3DCore::QEntity();
Currento->paintSkeleton(test);
test->setParent(_root);
CurrentBuilder.removeFirst();
return test;
}
Qt3DCore::QEntity * MyTimer::myslot(QVector<SkeletonBuilder*> _CurrentBuilder)
{
SkeletonBuilder* Currento = _CurrentBuilder.first();
Qt3DCore::QEntity* test = new Qt3DCore::QEntity();
Currento->paintSkeleton(test);
test->setParent(_root);
CurrentBuilder.removeFirst();
return test;
}
To copy to clipboard, switch view to plain text mode
the paintSkeleton fonction in the SkeletonBuilder class
Qt3DCore::QEntity * SkeletonBuilder::paintSkeleton( Qt3DCore::QEntity *ls)
{
QVector<Joint> skeletonBase = this->build();
Qt3DCore::QEntity *global= new Qt3DCore::QEntity(ls);
for(int i=0 ; i <skeletonBase.size() ; i++)
{
Qt3DCore::QEntity *sphereEntity = new Qt3DCore::QEntity(ls);
Qt3DExtras::QSphereMesh *sphereMesh = new Qt3DExtras::QSphereMesh;
sphereMesh->setRadius(0.3);
sphereMesh->setGenerateTangents(true);
Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform;
sphereTransform->setScale(0.98f);
//get the coordinates
Joint Currento = skeletonBase.at(i);
QString jointName
= Currento.
getName();
qDebug() <<Currento.getCoordinates() << Currento.getName()<< Qt::endl;
sphereTransform->setTranslation(Currento.getCoordinates()*10);
sphereTransform->setRotation(Currento.getQuaternion());
auto *materialSphere = new Qt3DExtras::QPhongMaterial(sphereMesh);
sphereEntity->addComponent(sphereMesh);
sphereEntity->addComponent(sphereTransform);
sphereEntity->addComponent(materialSphere);
}
return global;
}
Qt3DCore::QEntity * SkeletonBuilder::paintSkeleton( Qt3DCore::QEntity *ls)
{
QVector<Joint> skeletonBase = this->build();
Qt3DCore::QEntity *global= new Qt3DCore::QEntity(ls);
for(int i=0 ; i <skeletonBase.size() ; i++)
{
Qt3DCore::QEntity *sphereEntity = new Qt3DCore::QEntity(ls);
Qt3DExtras::QSphereMesh *sphereMesh = new Qt3DExtras::QSphereMesh;
sphereMesh->setRadius(0.3);
sphereMesh->setGenerateTangents(true);
Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform;
sphereTransform->setScale(0.98f);
//get the coordinates
Joint Currento = skeletonBase.at(i);
QString jointName = Currento.getName();
qDebug() <<Currento.getCoordinates() << Currento.getName()<< Qt::endl;
sphereTransform->setTranslation(Currento.getCoordinates()*10);
sphereTransform->setRotation(Currento.getQuaternion());
auto *materialSphere = new Qt3DExtras::QPhongMaterial(sphereMesh);
sphereEntity->addComponent(sphereMesh);
sphereEntity->addComponent(sphereTransform);
sphereEntity->addComponent(materialSphere);
}
return global;
}
To copy to clipboard, switch view to plain text mode
and the main
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
Qt3DCore::QEntity* rootEntity = new Qt3DCore::QEntity ;
Qt3DExtras::Qt3DWindow* view = new Qt3DExtras::Qt3DWindow;;
QVector<QVector<Joint>> skeletonData= createScene();
QVector<SkeletonBuilder*> test;
for(int i = 0 ; i< 218; i++)
{
Qt3DCore::QEntity *tamp = new Qt3DCore::QEntity;
SkeletonBuilder* sb = new SkeletonBuilder(skeletonData,i,tamp);
test.append(sb);
}
MyTimer *myTimer = new MyTimer( new Qt3DCore::QEntity,test);
Qt3DRender::QCamera *camera = view->camera();
camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
camera->setPosition(QVector3D(0, 0, 40.0f));
camera->setViewCenter(QVector3D(0, 0, 0));
// For camera controls
Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(myTimer->getRoot());
camController->setLinearSpeed( 50.0f );
camController->setLookSpeed( 180.0f );
camController->setCamera(camera);
view->setRootEntity(myTimer->getRoot());
//view.hide();
view->show();
return app.exec();
}
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
Qt3DCore::QEntity* rootEntity = new Qt3DCore::QEntity ;
Qt3DExtras::Qt3DWindow* view = new Qt3DExtras::Qt3DWindow;;
QVector<QVector<Joint>> skeletonData= createScene();
QVector<SkeletonBuilder*> test;
for(int i = 0 ; i< 218; i++)
{
Qt3DCore::QEntity *tamp = new Qt3DCore::QEntity;
SkeletonBuilder* sb = new SkeletonBuilder(skeletonData,i,tamp);
test.append(sb);
}
MyTimer *myTimer = new MyTimer( new Qt3DCore::QEntity,test);
Qt3DRender::QCamera *camera = view->camera();
camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
camera->setPosition(QVector3D(0, 0, 40.0f));
camera->setViewCenter(QVector3D(0, 0, 0));
// For camera controls
Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(myTimer->getRoot());
camController->setLinearSpeed( 50.0f );
camController->setLookSpeed( 180.0f );
camController->setCamera(camera);
view->setRootEntity(myTimer->getRoot());
//view.hide();
view->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
hope this show bit the picture
Screenshot 2020-06-12 at 06.34.14.jpg
Bookmarks