2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-04-09 15:28:00 -04:00
|
|
|
#include "mdlpart.h"
|
|
|
|
#include "glm/gtx/transform.hpp"
|
|
|
|
|
2023-07-07 16:01:39 -04:00
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QVBoxLayout>
|
2023-04-09 15:28:00 -04:00
|
|
|
#include <QVulkanInstance>
|
|
|
|
#include <QVulkanWindow>
|
2023-09-26 20:42:45 -04:00
|
|
|
#include <cmath>
|
2023-04-09 15:28:00 -04:00
|
|
|
#include <glm/gtc/quaternion.hpp>
|
2024-04-30 00:58:35 -04:00
|
|
|
#include <glm/gtx/matrix_major_storage.hpp>
|
2023-04-09 15:28:00 -04:00
|
|
|
|
2023-07-09 10:54:27 -04:00
|
|
|
#include "filecache.h"
|
2023-12-09 15:05:09 -05:00
|
|
|
#include "vulkanwindow.h"
|
2023-04-09 15:28:00 -04:00
|
|
|
|
2023-12-09 21:28:02 -05:00
|
|
|
MDLPart::MDLPart(GameData *data, FileCache &cache, QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
, data(data)
|
2023-10-12 23:45:34 -04:00
|
|
|
, cache(cache)
|
|
|
|
{
|
2023-04-09 15:28:00 -04:00
|
|
|
auto viewportLayout = new QVBoxLayout();
|
2023-07-09 11:04:30 -04:00
|
|
|
viewportLayout->setContentsMargins(0, 0, 0, 0);
|
2023-04-09 15:28:00 -04:00
|
|
|
setLayout(viewportLayout);
|
|
|
|
|
2023-10-13 15:03:17 -04:00
|
|
|
pbd = physis_parse_pbd(physis_gamedata_extract_file(data, "chara/xls/bonedeformer/human.pbd"));
|
|
|
|
|
2024-04-21 17:35:48 -04:00
|
|
|
renderer = new RenderManager(data);
|
2023-04-09 15:28:00 -04:00
|
|
|
|
|
|
|
auto inst = new QVulkanInstance();
|
2024-04-21 17:35:48 -04:00
|
|
|
inst->setVkInstance(renderer->device().instance);
|
2023-04-09 15:28:00 -04:00
|
|
|
inst->setFlags(QVulkanInstance::Flag::NoDebugOutputRedirect);
|
|
|
|
inst->create();
|
|
|
|
|
2023-07-06 17:36:22 -04:00
|
|
|
vkWindow = new VulkanWindow(this, renderer, inst);
|
2023-04-09 15:28:00 -04:00
|
|
|
vkWindow->setVulkanInstance(inst);
|
|
|
|
|
|
|
|
auto widget = QWidget::createWindowContainer(vkWindow);
|
2024-04-27 13:45:08 -04:00
|
|
|
widget->installEventFilter(vkWindow);
|
2023-04-09 15:28:00 -04:00
|
|
|
|
|
|
|
viewportLayout->addWidget(widget);
|
|
|
|
|
|
|
|
connect(this, &MDLPart::modelChanged, this, &MDLPart::reloadRenderer);
|
|
|
|
connect(this, &MDLPart::skeletonChanged, this, &MDLPart::reloadBoneData);
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::exportModel(const QString &fileName)
|
|
|
|
{
|
2023-12-09 15:39:35 -05:00
|
|
|
auto &model = models[0];
|
|
|
|
::exportModel(model.name, model.model, *skeleton, boneData, fileName);
|
2023-04-09 15:28:00 -04:00
|
|
|
}
|
|
|
|
|
2024-04-21 17:35:48 -04:00
|
|
|
DrawObject &MDLPart::getModel(const int index)
|
2023-12-09 14:49:31 -05:00
|
|
|
{
|
|
|
|
return models[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void MDLPart::reloadModel(const int index)
|
|
|
|
{
|
2024-04-21 17:35:48 -04:00
|
|
|
renderer->reloadDrawObject(models[index], 0);
|
2023-12-09 14:49:31 -05:00
|
|
|
|
|
|
|
Q_EMIT modelChanged();
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::clear()
|
|
|
|
{
|
2023-04-09 15:28:00 -04:00
|
|
|
models.clear();
|
|
|
|
|
|
|
|
Q_EMIT modelChanged();
|
|
|
|
}
|
|
|
|
|
2024-02-02 14:28:01 -05:00
|
|
|
void MDLPart::addModel(physis_MDL mdl,
|
2024-02-02 14:37:58 -05:00
|
|
|
bool skinned,
|
2024-02-02 14:28:01 -05:00
|
|
|
glm::vec3 position,
|
|
|
|
const QString &name,
|
|
|
|
std::vector<physis_Material> materials,
|
|
|
|
int lod,
|
|
|
|
uint16_t fromBodyId,
|
|
|
|
uint16_t toBodyId)
|
2023-09-26 21:21:04 -04:00
|
|
|
{
|
2023-04-09 15:28:00 -04:00
|
|
|
qDebug() << "Adding model to MDLPart";
|
|
|
|
|
2024-04-21 17:35:48 -04:00
|
|
|
auto model = renderer->addDrawObject(mdl, lod);
|
2023-09-26 21:21:04 -04:00
|
|
|
model.name = name;
|
2023-10-13 15:03:17 -04:00
|
|
|
model.from_body_id = fromBodyId;
|
|
|
|
model.to_body_id = toBodyId;
|
2024-02-02 14:28:01 -05:00
|
|
|
model.position = position;
|
2024-02-02 14:37:58 -05:00
|
|
|
model.skinned = skinned;
|
2023-04-09 15:28:00 -04:00
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
std::transform(materials.begin(), materials.end(), std::back_inserter(model.materials), [this](const physis_Material &mat) {
|
|
|
|
return createMaterial(mat);
|
|
|
|
});
|
2023-04-09 15:28:00 -04:00
|
|
|
|
2023-07-09 11:52:59 -04:00
|
|
|
if (materials.empty()) {
|
|
|
|
model.materials.push_back(createMaterial(physis_Material{}));
|
|
|
|
}
|
|
|
|
|
2023-04-09 15:28:00 -04:00
|
|
|
models.push_back(model);
|
|
|
|
|
|
|
|
Q_EMIT modelChanged();
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::setSkeleton(physis_Skeleton newSkeleton)
|
|
|
|
{
|
2023-07-06 17:36:22 -04:00
|
|
|
skeleton = std::make_unique<physis_Skeleton>(newSkeleton);
|
|
|
|
|
|
|
|
firstTimeSkeletonDataCalculated = false;
|
2023-04-09 15:28:00 -04:00
|
|
|
|
|
|
|
Q_EMIT skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::clearSkeleton()
|
|
|
|
{
|
2023-04-09 15:28:00 -04:00
|
|
|
skeleton.reset();
|
|
|
|
|
2023-07-06 17:36:22 -04:00
|
|
|
firstTimeSkeletonDataCalculated = false;
|
|
|
|
|
2023-04-09 15:28:00 -04:00
|
|
|
Q_EMIT skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::reloadRenderer()
|
|
|
|
{
|
2023-04-09 15:28:00 -04:00
|
|
|
reloadBoneData();
|
|
|
|
|
|
|
|
vkWindow->models = models;
|
|
|
|
}
|
|
|
|
|
2024-02-02 14:28:01 -05:00
|
|
|
void MDLPart::enableFreemode()
|
|
|
|
{
|
|
|
|
vkWindow->freeMode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MDLPart::event(QEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->type()) {
|
|
|
|
case QEvent::KeyPress:
|
|
|
|
case QEvent::KeyRelease:
|
|
|
|
vkWindow->event(event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QWidget::event(event);
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::reloadBoneData()
|
|
|
|
{
|
2023-07-09 10:54:27 -04:00
|
|
|
if (skeleton) {
|
2023-07-06 17:36:22 -04:00
|
|
|
if (!firstTimeSkeletonDataCalculated) {
|
2023-07-07 16:01:39 -04:00
|
|
|
if (boneData.empty()) {
|
|
|
|
boneData.resize(skeleton->num_bones);
|
|
|
|
}
|
|
|
|
|
2023-07-06 17:36:22 -04:00
|
|
|
calculateBoneInversePose(*skeleton, *skeleton->root_bone, nullptr);
|
2023-04-09 15:28:00 -04:00
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
for (auto &bone : boneData) {
|
2023-07-06 17:36:22 -04:00
|
|
|
bone.inversePose = glm::inverse(bone.inversePose);
|
|
|
|
}
|
|
|
|
firstTimeSkeletonDataCalculated = true;
|
2023-04-09 15:28:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// update data
|
|
|
|
calculateBone(*skeleton, *skeleton->root_bone, nullptr);
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
for (auto &model : models) {
|
2023-04-09 15:28:00 -04:00
|
|
|
// we want to map the actual affected bones to bone ids
|
|
|
|
std::map<int, int> boneMapping;
|
2023-12-09 22:35:59 -05:00
|
|
|
for (uint32_t i = 0; i < model.model.num_affected_bones; i++) {
|
|
|
|
for (uint32_t k = 0; k < skeleton->num_bones; k++) {
|
2023-10-12 23:45:34 -04:00
|
|
|
if (std::string_view{skeleton->bones[k].name} == std::string_view{model.model.affected_bone_names[i]}) {
|
2023-04-09 15:28:00 -04:00
|
|
|
boneMapping[i] = k;
|
2023-07-06 17:36:22 -04:00
|
|
|
}
|
2023-04-09 15:28:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-13 15:03:17 -04:00
|
|
|
std::vector<glm::mat4> deformBones(model.model.num_affected_bones);
|
2023-12-09 22:35:59 -05:00
|
|
|
for (uint32_t i = 0; i < model.model.num_affected_bones; i++) {
|
2023-10-13 15:03:17 -04:00
|
|
|
deformBones[i] = glm::mat4(1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// get deform matrices
|
2024-04-30 16:02:59 -04:00
|
|
|
if (enableRacialDeform) {
|
|
|
|
auto deform = physis_pbd_get_deform_matrix(pbd, model.from_body_id, model.to_body_id);
|
|
|
|
if (deform.num_bones != 0) {
|
|
|
|
for (int i = 0; i < deform.num_bones; i++) {
|
|
|
|
auto deformBone = deform.bones[i];
|
|
|
|
|
|
|
|
for (uint32_t k = 0; k < model.model.num_affected_bones; k++) {
|
|
|
|
if (std::string_view{model.model.affected_bone_names[k]} == std::string_view{deformBone.name}) {
|
|
|
|
deformBones[k] =
|
|
|
|
glm::rowMajor4(glm::vec4{deformBone.deform[0], deformBone.deform[1], deformBone.deform[2], deformBone.deform[3]},
|
|
|
|
glm::vec4{deformBone.deform[4], deformBone.deform[5], deformBone.deform[6], deformBone.deform[7]},
|
|
|
|
glm::vec4{deformBone.deform[8], deformBone.deform[9], deformBone.deform[10], deformBone.deform[11]},
|
|
|
|
glm::vec4{0.0f, 0.0f, 0.0f, 1.0f});
|
|
|
|
}
|
2023-10-13 15:03:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-09 22:35:59 -05:00
|
|
|
for (uint32_t i = 0; i < model.model.num_affected_bones; i++) {
|
2023-10-13 15:03:17 -04:00
|
|
|
const int originalBoneId = boneMapping[i];
|
2024-04-30 00:58:35 -04:00
|
|
|
model.boneData[i] = deformBones[i] * boneData[originalBoneId].localTransform * boneData[originalBoneId].inversePose;
|
2023-04-09 15:28:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
RenderMaterial MDLPart::createMaterial(const physis_Material &material)
|
|
|
|
{
|
2023-04-09 15:28:00 -04:00
|
|
|
RenderMaterial newMaterial;
|
2024-04-27 12:29:19 -04:00
|
|
|
newMaterial.mat = material;
|
2023-04-09 15:28:00 -04:00
|
|
|
|
2024-04-22 16:12:26 -04:00
|
|
|
if (material.shpk_name != nullptr) {
|
|
|
|
std::string shpkPath = "shader/sm5/shpk/" + std::string(material.shpk_name);
|
2024-04-21 19:07:09 -04:00
|
|
|
|
2024-04-22 16:12:26 -04:00
|
|
|
auto shpkData = physis_gamedata_extract_file(data, shpkPath.c_str());
|
|
|
|
if (shpkData.data != nullptr) {
|
|
|
|
newMaterial.shaderPackage = physis_parse_shpk(shpkData);
|
2024-04-27 18:44:53 -04:00
|
|
|
|
|
|
|
// create the material parameters for this shader package
|
|
|
|
newMaterial.materialBuffer =
|
|
|
|
renderer->device().createBuffer(newMaterial.shaderPackage.material_parameters_size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
|
2024-05-10 15:53:32 -04:00
|
|
|
renderer->device().nameBuffer(newMaterial.materialBuffer, "g_MaterialParameter"); // TODO: add material name
|
2024-04-27 18:44:53 -04:00
|
|
|
|
|
|
|
// assumed to be floats, maybe not always true?
|
|
|
|
std::vector<float> buffer(newMaterial.shaderPackage.material_parameters_size / sizeof(float));
|
|
|
|
|
|
|
|
// copy the material data
|
|
|
|
for (int i = 0; i < newMaterial.shaderPackage.num_material_parameters; i++) {
|
|
|
|
auto param = newMaterial.shaderPackage.material_parameters[i];
|
|
|
|
|
|
|
|
for (int j = 0; j < newMaterial.mat.num_constants; j++) {
|
|
|
|
auto constant = newMaterial.mat.constants[j];
|
|
|
|
|
|
|
|
if (constant.id == param.id) {
|
|
|
|
for (int z = 0; z < constant.num_values; z++) {
|
|
|
|
buffer[(param.byte_offset / sizeof(float)) + z] = constant.values[z];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer->device().copyToBuffer(newMaterial.materialBuffer, buffer.data(), buffer.size() * sizeof(float));
|
2024-04-22 16:12:26 -04:00
|
|
|
}
|
2024-04-21 19:07:09 -04:00
|
|
|
}
|
|
|
|
|
2023-12-09 22:35:59 -05:00
|
|
|
for (uint32_t i = 0; i < material.num_textures; i++) {
|
2023-04-09 15:28:00 -04:00
|
|
|
std::string t = material.textures[i];
|
|
|
|
|
|
|
|
if (t.find("skin") != std::string::npos) {
|
|
|
|
newMaterial.type = MaterialType::Skin;
|
|
|
|
}
|
|
|
|
|
2024-05-10 15:53:32 -04:00
|
|
|
if (material.color_table.num_rows > 0) {
|
|
|
|
int width = 4;
|
|
|
|
int height = material.color_table.num_rows;
|
|
|
|
|
|
|
|
qInfo() << "Creating color table" << width << "X" << height;
|
|
|
|
|
|
|
|
std::vector<float> rgbaData(width * height * 4);
|
|
|
|
int offset = 0;
|
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
for (int x = 0; x < width; x++) {
|
|
|
|
const auto row = material.color_table.rows[y];
|
|
|
|
|
|
|
|
glm::vec4 color;
|
|
|
|
if (x == 0) {
|
|
|
|
color = glm::vec4{row.diffuse_color[0], row.diffuse_color[1], row.diffuse_color[2], row.specular_strength};
|
|
|
|
} else if (x == 1) {
|
|
|
|
color = glm::vec4{row.specular_color[0], row.specular_color[1], row.specular_color[2], row.gloss_strength};
|
|
|
|
} else if (x == 2) {
|
|
|
|
color = glm::vec4{row.emissive_color[0], row.emissive_color[1], row.emissive_color[2], row.tile_set};
|
|
|
|
} else if (x == 3) {
|
|
|
|
color = glm::vec4{row.material_repeat[0], row.material_repeat[1], row.material_skew[0], row.material_skew[1]};
|
|
|
|
}
|
|
|
|
|
|
|
|
rgbaData[offset] = color.x;
|
|
|
|
rgbaData[offset + 1] = color.y;
|
|
|
|
rgbaData[offset + 2] = color.z;
|
|
|
|
rgbaData[offset + 3] = color.a;
|
|
|
|
|
|
|
|
offset += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
physis_Texture textureConfig;
|
|
|
|
textureConfig.texture_type = TextureType::TwoDimensional;
|
|
|
|
textureConfig.width = width;
|
|
|
|
textureConfig.height = height;
|
|
|
|
textureConfig.depth = 1;
|
|
|
|
textureConfig.rgba = reinterpret_cast<uint8_t *>(rgbaData.data());
|
|
|
|
textureConfig.rgba_size = rgbaData.size() * sizeof(float);
|
|
|
|
|
|
|
|
// TODO: use 16-bit floating points like the game
|
|
|
|
newMaterial.tableTexture = renderer->addGameTexture(VK_FORMAT_R32G32B32A32_SFLOAT, textureConfig);
|
|
|
|
renderer->device().nameTexture(*newMaterial.tableTexture, "g_SamplerTable"); // TODO: add material name
|
|
|
|
}
|
|
|
|
|
|
|
|
qInfo() << "Loading" << t;
|
2024-04-30 19:05:55 -04:00
|
|
|
|
2023-04-09 15:28:00 -04:00
|
|
|
char type = t[t.length() - 5];
|
2024-04-18 17:57:16 -04:00
|
|
|
auto texture = physis_texture_parse(cache.lookupFile(QLatin1String(material.textures[i])));
|
|
|
|
if (texture.rgba != nullptr) {
|
|
|
|
switch (type) {
|
|
|
|
case 'm': {
|
2024-05-10 15:53:32 -04:00
|
|
|
newMaterial.multiTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
|
|
|
|
renderer->device().nameTexture(*newMaterial.multiTexture, material.textures[i]);
|
2024-04-18 17:57:16 -04:00
|
|
|
} break;
|
|
|
|
case 'd': {
|
2024-05-10 15:53:32 -04:00
|
|
|
newMaterial.diffuseTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
|
|
|
|
renderer->device().nameTexture(*newMaterial.diffuseTexture, material.textures[i]);
|
2024-04-18 17:57:16 -04:00
|
|
|
} break;
|
|
|
|
case 'n': {
|
2024-05-10 15:53:32 -04:00
|
|
|
newMaterial.normalTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
|
|
|
|
renderer->device().nameTexture(*newMaterial.normalTexture, material.textures[i]);
|
2024-04-18 17:57:16 -04:00
|
|
|
} break;
|
|
|
|
case 's': {
|
2024-05-10 15:53:32 -04:00
|
|
|
newMaterial.specularTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
|
|
|
|
renderer->device().nameTexture(*newMaterial.specularTexture, material.textures[i]);
|
2024-04-18 17:57:16 -04:00
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
qDebug() << "unhandled type" << type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qInfo() << "Failed to load" << t;
|
2023-04-09 15:28:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return newMaterial;
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::calculateBoneInversePose(physis_Skeleton &skeleton, physis_Bone &bone, physis_Bone *parent_bone)
|
|
|
|
{
|
2023-04-09 15:28:00 -04:00
|
|
|
const glm::mat4 parentMatrix = parent_bone == nullptr ? glm::mat4(1.0f) : boneData[parent_bone->index].inversePose;
|
|
|
|
|
2023-07-07 16:01:39 -04:00
|
|
|
glm::mat4 local = glm::mat4(1.0f);
|
2023-04-09 15:28:00 -04:00
|
|
|
local = glm::translate(local, glm::vec3(bone.position[0], bone.position[1], bone.position[2]));
|
|
|
|
local *= glm::mat4_cast(glm::quat(bone.rotation[3], bone.rotation[0], bone.rotation[1], bone.rotation[2]));
|
|
|
|
local = glm::scale(local, glm::vec3(bone.scale[0], bone.scale[1], bone.scale[2]));
|
|
|
|
|
|
|
|
boneData[bone.index].inversePose = parentMatrix * local;
|
|
|
|
|
2023-12-09 22:35:59 -05:00
|
|
|
for (uint32_t i = 0; i < skeleton.num_bones; i++) {
|
2023-10-12 23:45:34 -04:00
|
|
|
if (skeleton.bones[i].parent_bone != nullptr && std::string_view{skeleton.bones[i].parent_bone->name} == std::string_view{bone.name}) {
|
2023-04-09 15:28:00 -04:00
|
|
|
calculateBoneInversePose(skeleton, skeleton.bones[i], &bone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 23:45:34 -04:00
|
|
|
void MDLPart::calculateBone(physis_Skeleton &skeleton, physis_Bone &bone, const physis_Bone *parent_bone)
|
|
|
|
{
|
2023-10-13 15:03:17 -04:00
|
|
|
const glm::mat4 parent_matrix = parent_bone == nullptr ? glm::mat4(1.0f) : (boneData[parent_bone->index].localTransform);
|
2023-04-09 15:28:00 -04:00
|
|
|
|
|
|
|
glm::mat4 local = glm::mat4(1.0f);
|
2023-07-09 10:54:27 -04:00
|
|
|
local = glm::translate(local, glm::vec3(bone.position[0], bone.position[1], bone.position[2]));
|
|
|
|
local *= glm::mat4_cast(glm::quat(bone.rotation[3], bone.rotation[0], bone.rotation[1], bone.rotation[2]));
|
|
|
|
local = glm::scale(local, glm::vec3(bone.scale[0], bone.scale[1], bone.scale[2]));
|
2023-04-09 15:28:00 -04:00
|
|
|
|
|
|
|
boneData[bone.index].localTransform = parent_matrix * local;
|
2023-10-13 15:03:17 -04:00
|
|
|
boneData[bone.index].finalTransform = parent_matrix;
|
2023-07-07 16:01:39 -04:00
|
|
|
|
2023-12-09 22:35:59 -05:00
|
|
|
for (uint32_t i = 0; i < skeleton.num_bones; i++) {
|
2023-10-12 23:45:34 -04:00
|
|
|
if (skeleton.bones[i].parent_bone != nullptr && std::string_view{skeleton.bones[i].parent_bone->name} == std::string_view{bone.name}) {
|
2023-04-09 15:28:00 -04:00
|
|
|
calculateBone(skeleton, skeleton.bones[i], &bone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-25 23:48:03 -04:00
|
|
|
void MDLPart::removeModel(const physis_MDL &mdl)
|
|
|
|
{
|
|
|
|
models.erase(std::remove_if(models.begin(),
|
|
|
|
models.end(),
|
2024-04-21 17:35:48 -04:00
|
|
|
[mdl](const DrawObject &other) {
|
2023-12-09 15:55:33 -05:00
|
|
|
return mdl.p_ptr == other.model.p_ptr;
|
2023-09-25 23:48:03 -04:00
|
|
|
}),
|
|
|
|
models.end());
|
2023-12-09 15:55:33 -05:00
|
|
|
Q_EMIT modelChanged();
|
2023-09-25 23:48:03 -04:00
|
|
|
}
|
|
|
|
|
2024-04-14 14:09:40 -04:00
|
|
|
void MDLPart::setWireframe(bool wireframe)
|
|
|
|
{
|
2024-04-21 17:35:48 -04:00
|
|
|
// renderer->wireframe = wireframe;
|
2024-04-14 14:09:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MDLPart::wireframe() const
|
|
|
|
{
|
2024-04-21 17:35:48 -04:00
|
|
|
// return renderer->wireframe;
|
|
|
|
return false;
|
2024-04-14 14:09:40 -04:00
|
|
|
}
|
|
|
|
|
2024-04-27 13:45:08 -04:00
|
|
|
int MDLPart::numModels() const
|
|
|
|
{
|
|
|
|
return models.size();
|
|
|
|
}
|
|
|
|
|
2023-04-09 15:28:00 -04:00
|
|
|
#include "moc_mdlpart.cpp"
|