1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-28 22:47:45 +00:00
novus/parts/mdl/mdlpart.h

80 lines
1.8 KiB
C
Raw Normal View History

#pragma once
#include <QWidget>
#include <optional>
#include <physis.hpp>
#include "renderer.hpp"
struct GameData;
class VulkanWindow;
class StandaloneWindow;
class MDLPart : public QWidget {
2023-07-07 16:01:39 -04:00
Q_OBJECT
public:
2023-07-07 16:01:39 -04:00
explicit MDLPart(GameData *data);
2023-07-07 16:01:39 -04:00
void exportModel(const QString &fileName);
2023-07-07 16:01:39 -04:00
int lastX = -1;
int lastY = -1;
2023-07-07 16:01:39 -04:00
enum class CameraMode { None, Orbit, Move };
2023-07-07 16:01:39 -04:00
CameraMode cameraMode = CameraMode::None;
float pitch = 0.0f;
float yaw = 0.0f;
float cameraDistance = 5.0f;
glm::vec3 position{0, 0, 0};
2023-07-07 16:01:39 -04:00
std::unique_ptr<physis_Skeleton> skeleton;
struct BoneData {
glm::mat4 localTransform, finalTransform, inversePose;
glm::mat4 deformRaceMatrix{1.0f};
};
std::vector<BoneData> boneData;
Q_SIGNALS:
2023-07-07 16:01:39 -04:00
void modelChanged();
void skeletonChanged();
public Q_SLOTS:
2023-07-07 16:01:39 -04:00
/// Clears all stored MDLs.
void clear();
/// Adds a new MDL with a list of materials used.
void addModel(physis_MDL mdl, std::vector<physis_Material> materials,
int lod);
2023-07-07 16:01:39 -04:00
/// Sets the skeleton any skinned MDLs should bind to.
void setSkeleton(physis_Skeleton skeleton);
2023-07-07 16:01:39 -04:00
/// Sets the race deform matrices
void loadRaceDeformMatrices(physis_Buffer buffer);
2023-07-07 16:01:39 -04:00
/// Clears the current skeleton.
void clearSkeleton();
2023-07-07 16:01:39 -04:00
void reloadBoneData();
void reloadRenderer();
private:
2023-07-07 16:01:39 -04:00
RenderMaterial createMaterial(const physis_Material &mat);
2023-07-07 16:01:39 -04:00
void calculateBoneInversePose(physis_Skeleton& skeleton, physis_Bone& bone, physis_Bone* parent_bone);
void calculateBone(physis_Skeleton& skeleton, physis_Bone& bone, const physis_Bone* parent_bone);
GameData* data = nullptr;
std::vector<RenderModel> models;
Renderer* renderer;
VulkanWindow* vkWindow;
StandaloneWindow* standaloneWindow;
bool firstTimeSkeletonDataCalculated = false;
};