2022-03-06 09:51:57 +01:00
|
|
|
// MassBuilderSaveTool
|
2024-03-08 20:25:32 +01:00
|
|
|
// Copyright (C) 2021-2024 Guillaume Jacquemin
|
2022-03-06 09:51:57 +01:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2024-03-28 13:18:56 +01:00
|
|
|
#include "PropertyNames.h"
|
2023-11-29 12:33:26 +01:00
|
|
|
#include "../Gvas/Types/ArrayProperty.h"
|
|
|
|
#include "../Gvas/Types/BoolProperty.h"
|
|
|
|
#include "../Gvas/Types/ColourStructProperty.h"
|
|
|
|
#include "../Gvas/Types/FloatProperty.h"
|
|
|
|
#include "../Gvas/Types/GenericStructProperty.h"
|
|
|
|
#include "../Gvas/Types/RotatorStructProperty.h"
|
|
|
|
#include "../Gvas/Types/VectorStructProperty.h"
|
|
|
|
#include "../Gvas/Types/Vector2DStructProperty.h"
|
|
|
|
#include "../Gvas/Types/IntProperty.h"
|
2022-03-06 09:51:57 +01:00
|
|
|
|
|
|
|
#include "Mass.h"
|
|
|
|
|
|
|
|
using namespace Containers::Literals;
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
namespace mbst { namespace GameObjects {
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Mass::getDecals(Containers::ArrayView<Decal> decals, Gvas::Types::ArrayProperty* decal_array) {
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t i = 0; i < decal_array->items.size(); i++) {
|
2023-11-29 12:33:26 +01:00
|
|
|
auto decal_prop = decal_array->at<Gvas::Types::GenericStructProperty>(i);
|
2022-03-30 19:51:00 +02:00
|
|
|
CORRADE_INTERNAL_ASSERT(decal_prop);
|
2022-03-06 09:51:57 +01:00
|
|
|
auto& decal = decals[i];
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
decal.id = decal_prop->at<Gvas::Types::IntProperty>(MASS_DECAL_ID)->value;
|
|
|
|
auto colour_prop = decal_prop->at<Gvas::Types::ColourStructProperty>(MASS_DECAL_COLOUR);
|
2022-03-06 09:51:57 +01:00
|
|
|
decal.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto pos_prop = decal_prop->at<Gvas::Types::VectorStructProperty>(MASS_DECAL_POSITION);
|
2022-03-06 09:51:57 +01:00
|
|
|
decal.position = Vector3{pos_prop->x, pos_prop->y, pos_prop->z};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto u_prop = decal_prop->at<Gvas::Types::VectorStructProperty>(MASS_DECAL_UAXIS);
|
2022-03-06 09:51:57 +01:00
|
|
|
decal.uAxis = Vector3{u_prop->x, u_prop->y, u_prop->z};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto v_prop = decal_prop->at<Gvas::Types::VectorStructProperty>(MASS_DECAL_VAXIS);
|
2022-03-06 09:51:57 +01:00
|
|
|
decal.vAxis = Vector3{v_prop->x, v_prop->y, v_prop->z};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto offset_prop = decal_prop->at<Gvas::Types::Vector2DStructProperty>(MASS_DECAL_OFFSET);
|
2022-03-06 09:51:57 +01:00
|
|
|
decal.offset = Vector2{offset_prop->x, offset_prop->y};
|
2023-11-29 12:33:26 +01:00
|
|
|
decal.scale = decal_prop->at<Gvas::Types::FloatProperty>(MASS_DECAL_SCALE)->value;
|
|
|
|
decal.rotation = decal_prop->at<Gvas::Types::FloatProperty>(MASS_DECAL_ROTATION)->value;
|
|
|
|
decal.flip = decal_prop->at<Gvas::Types::BoolProperty>(MASS_DECAL_FLIP)->value;
|
|
|
|
decal.wrap = decal_prop->at<Gvas::Types::BoolProperty>(MASS_DECAL_WRAP)->value;
|
2022-03-06 09:51:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Mass::writeDecals(Containers::ArrayView<Decal> decals, Gvas::Types::ArrayProperty* decal_array) {
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t i = 0; i < decal_array->items.size(); i++) {
|
2023-11-29 12:33:26 +01:00
|
|
|
auto decal_prop = decal_array->at<Gvas::Types::GenericStructProperty>(i);
|
2022-03-30 19:51:00 +02:00
|
|
|
CORRADE_INTERNAL_ASSERT(decal_prop);
|
2022-03-06 09:51:57 +01:00
|
|
|
auto& decal = decals[i];
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
decal_prop->at<Gvas::Types::IntProperty>(MASS_DECAL_ID)->value = decal.id;
|
|
|
|
auto colour_prop = decal_prop->at<Gvas::Types::ColourStructProperty>(MASS_DECAL_COLOUR);
|
2022-03-06 09:51:57 +01:00
|
|
|
colour_prop->r = decal.colour.r();
|
|
|
|
colour_prop->g = decal.colour.g();
|
|
|
|
colour_prop->b = decal.colour.b();
|
|
|
|
colour_prop->a = decal.colour.a();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto pos_prop = decal_prop->at<Gvas::Types::VectorStructProperty>(MASS_DECAL_POSITION);
|
2022-03-06 09:51:57 +01:00
|
|
|
pos_prop->x = decal.position.x();
|
|
|
|
pos_prop->y = decal.position.y();
|
|
|
|
pos_prop->z = decal.position.z();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto u_prop = decal_prop->at<Gvas::Types::VectorStructProperty>(MASS_DECAL_UAXIS);
|
2022-03-06 09:51:57 +01:00
|
|
|
u_prop->x = decal.uAxis.x();
|
|
|
|
u_prop->y = decal.uAxis.y();
|
|
|
|
u_prop->z = decal.uAxis.z();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto v_prop = decal_prop->at<Gvas::Types::VectorStructProperty>(MASS_DECAL_VAXIS);
|
2022-03-06 09:51:57 +01:00
|
|
|
v_prop->x = decal.vAxis.x();
|
|
|
|
v_prop->y = decal.vAxis.y();
|
|
|
|
v_prop->z = decal.vAxis.z();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto offset_prop = decal_prop->at<Gvas::Types::Vector2DStructProperty>(MASS_DECAL_OFFSET);
|
2022-03-06 09:51:57 +01:00
|
|
|
offset_prop->x = decal.offset.x();
|
|
|
|
offset_prop->y = decal.offset.y();
|
2023-11-29 12:33:26 +01:00
|
|
|
decal_prop->at<Gvas::Types::FloatProperty>(MASS_DECAL_SCALE)->value = decal.scale;
|
|
|
|
decal_prop->at<Gvas::Types::FloatProperty>(MASS_DECAL_ROTATION)->value = decal.rotation;
|
|
|
|
decal_prop->at<Gvas::Types::BoolProperty>(MASS_DECAL_FLIP)->value = decal.flip;
|
|
|
|
decal_prop->at<Gvas::Types::BoolProperty>(MASS_DECAL_WRAP)->value = decal.wrap;
|
2022-03-06 09:51:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Mass::getAccessories(Containers::ArrayView<Accessory> accessories, Gvas::Types::ArrayProperty* accessory_array) {
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t i = 0; i < accessory_array->items.size(); i++) {
|
2023-11-29 12:33:26 +01:00
|
|
|
auto acc_prop = accessory_array->at<Gvas::Types::GenericStructProperty>(i);
|
2022-03-30 19:51:00 +02:00
|
|
|
CORRADE_INTERNAL_ASSERT(acc_prop);
|
2022-03-06 09:51:57 +01:00
|
|
|
auto& accessory = accessories[i];
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
accessory.attachIndex = acc_prop->at<Gvas::Types::IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value;
|
|
|
|
accessory.id = acc_prop->at<Gvas::Types::IntProperty>(MASS_ACCESSORY_ID)->value;
|
|
|
|
auto acc_styles = acc_prop->at<Gvas::Types::ArrayProperty>(MASS_ACCESSORY_STYLES);
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) {
|
2023-11-29 12:33:26 +01:00
|
|
|
accessory.styles[j] = acc_styles->at<Gvas::Types::IntProperty>(j)->value;
|
2022-03-06 09:51:57 +01:00
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_pos_prop = acc_prop->at<Gvas::Types::VectorStructProperty>(MASS_ACCESSORY_RELPOS);
|
2022-03-06 09:51:57 +01:00
|
|
|
accessory.relativePosition = Vector3{rel_pos_prop->x, rel_pos_prop->y, rel_pos_prop->z};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_pos_offset_prop = acc_prop->at<Gvas::Types::VectorStructProperty>(MASS_ACCESSORY_OFFPOS);
|
2022-03-06 09:51:57 +01:00
|
|
|
accessory.relativePositionOffset = Vector3{rel_pos_offset_prop->x, rel_pos_offset_prop->y, rel_pos_offset_prop->z};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_rot_prop = acc_prop->at<Gvas::Types::RotatorStructProperty>(MASS_ACCESSORY_RELROT);
|
2022-03-06 09:51:57 +01:00
|
|
|
accessory.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_rot_offset_prop = acc_prop->at<Gvas::Types::RotatorStructProperty>(MASS_ACCESSORY_OFFROT);
|
2022-03-06 09:51:57 +01:00
|
|
|
accessory.relativeRotationOffset = Vector3{rel_rot_offset_prop->x, rel_rot_offset_prop->y, rel_rot_offset_prop->z};
|
2023-11-29 12:33:26 +01:00
|
|
|
auto local_scale_prop = acc_prop->at<Gvas::Types::VectorStructProperty>(MASS_ACCESSORY_SCALE);
|
2022-03-06 09:51:57 +01:00
|
|
|
accessory.localScale = Vector3{local_scale_prop->x, local_scale_prop->y, local_scale_prop->z};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, Gvas::Types::ArrayProperty* accs_array) {
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t i = 0; i < accs_array->items.size(); i++) {
|
2023-11-29 12:33:26 +01:00
|
|
|
auto acc_prop = accs_array->at<Gvas::Types::GenericStructProperty>(i);
|
2022-03-30 19:51:00 +02:00
|
|
|
CORRADE_INTERNAL_ASSERT(acc_prop);
|
2022-03-06 09:51:57 +01:00
|
|
|
auto& accessory = accessories[i];
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
acc_prop->at<Gvas::Types::IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex;
|
|
|
|
acc_prop->at<Gvas::Types::IntProperty>(MASS_ACCESSORY_ID)->value = accessory.id;
|
|
|
|
auto acc_styles = acc_prop->at<Gvas::Types::ArrayProperty>(MASS_ACCESSORY_STYLES);
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) {
|
2023-11-29 12:33:26 +01:00
|
|
|
acc_styles->at<Gvas::Types::IntProperty>(j)->value = accessory.styles[j];
|
2022-03-06 09:51:57 +01:00
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_pos_prop = acc_prop->at<Gvas::Types::VectorStructProperty>(MASS_ACCESSORY_RELPOS);
|
2022-03-06 09:51:57 +01:00
|
|
|
rel_pos_prop->x = accessory.relativePosition.x();
|
|
|
|
rel_pos_prop->y = accessory.relativePosition.y();
|
|
|
|
rel_pos_prop->z = accessory.relativePosition.z();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_pos_offset_prop = acc_prop->at<Gvas::Types::VectorStructProperty>(MASS_ACCESSORY_OFFPOS);
|
2022-03-06 09:51:57 +01:00
|
|
|
rel_pos_offset_prop->x = accessory.relativePositionOffset.x();
|
|
|
|
rel_pos_offset_prop->y = accessory.relativePositionOffset.y();
|
|
|
|
rel_pos_offset_prop->z = accessory.relativePositionOffset.z();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_rot_prop = acc_prop->at<Gvas::Types::RotatorStructProperty>(MASS_ACCESSORY_RELROT);
|
2022-03-06 09:51:57 +01:00
|
|
|
rel_rot_prop->x = accessory.relativeRotation.x();
|
|
|
|
rel_rot_prop->y = accessory.relativeRotation.y();
|
|
|
|
rel_rot_prop->z = accessory.relativeRotation.z();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto rel_rot_offset_prop = acc_prop->at<Gvas::Types::RotatorStructProperty>(MASS_ACCESSORY_OFFROT);
|
2022-03-06 09:51:57 +01:00
|
|
|
rel_rot_offset_prop->x = accessory.relativeRotationOffset.x();
|
|
|
|
rel_rot_offset_prop->y = accessory.relativeRotationOffset.y();
|
|
|
|
rel_rot_offset_prop->z = accessory.relativeRotationOffset.z();
|
2023-11-29 12:33:26 +01:00
|
|
|
auto local_scale_prop = acc_prop->at<Gvas::Types::VectorStructProperty>(MASS_ACCESSORY_SCALE);
|
2022-03-06 09:51:57 +01:00
|
|
|
local_scale_prop->x = accessory.localScale.x();
|
|
|
|
local_scale_prop->y = accessory.localScale.y();
|
|
|
|
local_scale_prop->z = accessory.localScale.z();
|
|
|
|
}
|
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
|
|
|
|
}}
|