2022-10-25 11:31:44 +00:00
|
|
|
#ifndef DUST3D_APPLICATION_UV_MAP_GENERATOR_H_
|
|
|
|
#define DUST3D_APPLICATION_UV_MAP_GENERATOR_H_
|
|
|
|
|
2022-10-28 23:30:22 +00:00
|
|
|
#include "model_mesh.h"
|
|
|
|
#include <QImage>
|
2022-10-25 11:31:44 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <dust3d/base/object.h>
|
|
|
|
#include <dust3d/base/snapshot.h>
|
|
|
|
#include <dust3d/uv/uv_map_packer.h>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class UvMapGenerator : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
UvMapGenerator(std::unique_ptr<dust3d::Object> object, std::unique_ptr<dust3d::Snapshot> snapshot);
|
|
|
|
void generate();
|
2022-10-28 23:30:22 +00:00
|
|
|
std::unique_ptr<QImage> takeResultTextureColorImage();
|
|
|
|
std::unique_ptr<QImage> takeResultTextureNormalImage();
|
|
|
|
std::unique_ptr<QImage> takeResultTextureRoughnessImage();
|
|
|
|
std::unique_ptr<QImage> takeResultTextureMetalnessImage();
|
|
|
|
std::unique_ptr<QImage> takeResultTextureAmbientOcclusionImage();
|
|
|
|
std::unique_ptr<ModelMesh> takeResultMesh();
|
2022-10-25 11:31:44 +00:00
|
|
|
std::unique_ptr<dust3d::Object> takeObject();
|
2022-10-28 23:30:22 +00:00
|
|
|
bool hasTransparencySettings() const;
|
|
|
|
static QImage* combineMetalnessRoughnessAmbientOcclusionImages(QImage* metalnessImage,
|
|
|
|
QImage* roughnessImage,
|
|
|
|
QImage* ambientOcclusionImage);
|
2022-10-25 11:31:44 +00:00
|
|
|
signals:
|
|
|
|
void finished();
|
|
|
|
public slots:
|
|
|
|
void process();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<dust3d::Object> m_object;
|
|
|
|
std::unique_ptr<dust3d::Snapshot> m_snapshot;
|
|
|
|
std::unique_ptr<dust3d::UvMapPacker> m_mapPacker;
|
2022-10-28 23:30:22 +00:00
|
|
|
std::unique_ptr<QImage> m_textureColorImage;
|
|
|
|
std::unique_ptr<QImage> m_textureNormalImage;
|
|
|
|
std::unique_ptr<QImage> m_textureRoughnessImage;
|
|
|
|
std::unique_ptr<QImage> m_textureMetalnessImage;
|
|
|
|
std::unique_ptr<QImage> m_textureAmbientOcclusionImage;
|
|
|
|
std::unique_ptr<ModelMesh> m_mesh;
|
|
|
|
bool m_hasTransparencySettings = false;
|
|
|
|
static size_t m_textureSize;
|
2022-10-29 23:05:55 +00:00
|
|
|
void packUvs();
|
|
|
|
void generateTextureColorImage();
|
|
|
|
void generateUvCoords();
|
2022-10-25 11:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|