2022-10-02 19:45:46 +00:00
|
|
|
#include "mesh_preview_images_generator.h"
|
|
|
|
#include "theme.h"
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QDebug>
|
2022-10-02 19:45:46 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void MeshPreviewImagesGenerator::addInput(const dust3d::Uuid& inputId, std::unique_ptr<ModelMesh> previewMesh, bool useFrontView)
|
2022-10-02 19:45:46 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
m_previewInputMap.insert({ inputId, PreviewInput { std::move(previewMesh), useFrontView } });
|
2022-10-02 19:45:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MeshPreviewImagesGenerator::process()
|
|
|
|
{
|
|
|
|
generate();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2022-10-02 19:45:46 +00:00
|
|
|
emit finished();
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
std::map<dust3d::Uuid, QImage>* MeshPreviewImagesGenerator::takeImages()
|
2022-10-02 19:45:46 +00:00
|
|
|
{
|
|
|
|
return m_partImages.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MeshPreviewImagesGenerator::generate()
|
|
|
|
{
|
|
|
|
m_partImages = std::make_unique<std::map<dust3d::Uuid, QImage>>();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2022-10-02 19:45:46 +00:00
|
|
|
m_offscreenRender->setZRotation(0);
|
|
|
|
m_offscreenRender->setEyePosition(QVector3D(0, 0, -4.0));
|
2022-10-18 09:35:04 +00:00
|
|
|
for (auto& it : m_previewInputMap) {
|
2022-10-02 19:45:46 +00:00
|
|
|
if (it.second.useFrontView) {
|
|
|
|
m_offscreenRender->setXRotation(0);
|
|
|
|
m_offscreenRender->setYRotation(0);
|
|
|
|
} else {
|
|
|
|
m_offscreenRender->setXRotation(30 * 16);
|
|
|
|
m_offscreenRender->setYRotation(-45 * 16);
|
|
|
|
}
|
|
|
|
m_offscreenRender->updateMesh(it.second.mesh.release());
|
|
|
|
(*m_partImages)[it.first] = m_offscreenRender->toImage(QSize(Theme::partPreviewImageSize, Theme::partPreviewImageSize));
|
|
|
|
}
|
|
|
|
}
|