// MassBuilderSaveTool // Copyright (C) 2021-2024 Guillaume Jacquemin // // 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 . #include "PropertyNames.h" #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" #include "Mass.h" using namespace Containers::Literals; namespace mbst::GameObjects { void Mass::getDecals(Containers::ArrayView decals, Gvas::Types::ArrayProperty* decal_array) { for(std::uint32_t i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); auto& decal = decals[i]; decal.id = decal_prop->at(MASS_DECAL_ID)->value; auto colour_prop = decal_prop->at(MASS_DECAL_COLOUR); decal.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; auto pos_prop = decal_prop->at(MASS_DECAL_POSITION); decal.position = pos_prop->vector; auto u_prop = decal_prop->at(MASS_DECAL_UAXIS); decal.uAxis = u_prop->vector; auto v_prop = decal_prop->at(MASS_DECAL_VAXIS); decal.vAxis = v_prop->vector; auto offset_prop = decal_prop->at(MASS_DECAL_OFFSET); decal.offset = offset_prop->vector; decal.scale = decal_prop->at(MASS_DECAL_SCALE)->value; decal.rotation = decal_prop->at(MASS_DECAL_ROTATION)->value; decal.flip = decal_prop->at(MASS_DECAL_FLIP)->value; decal.wrap = decal_prop->at(MASS_DECAL_WRAP)->value; } } void Mass::writeDecals(Containers::ArrayView decals, Gvas::Types::ArrayProperty* decal_array) { for(std::uint32_t i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); auto& decal = decals[i]; decal_prop->at(MASS_DECAL_ID)->value = decal.id; auto colour_prop = decal_prop->at(MASS_DECAL_COLOUR); colour_prop->r = decal.colour.r(); colour_prop->g = decal.colour.g(); colour_prop->b = decal.colour.b(); colour_prop->a = decal.colour.a(); auto pos_prop = decal_prop->at(MASS_DECAL_POSITION); pos_prop->vector = decal.position; auto u_prop = decal_prop->at(MASS_DECAL_UAXIS); u_prop->vector = decal.uAxis; auto v_prop = decal_prop->at(MASS_DECAL_VAXIS); v_prop->vector = decal.vAxis; auto offset_prop = decal_prop->at(MASS_DECAL_OFFSET); offset_prop->vector = decal.offset; decal_prop->at(MASS_DECAL_SCALE)->value = decal.scale; decal_prop->at(MASS_DECAL_ROTATION)->value = decal.rotation; decal_prop->at(MASS_DECAL_FLIP)->value = decal.flip; decal_prop->at(MASS_DECAL_WRAP)->value = decal.wrap; } } void Mass::getAccessories(Containers::ArrayView accessories, Gvas::Types::ArrayProperty* accessory_array) { for(std::uint32_t i = 0; i < accessory_array->items.size(); i++) { auto acc_prop = accessory_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); auto& accessory = accessories[i]; accessory.attachIndex = acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value; accessory.id = acc_prop->at(MASS_ACCESSORY_ID)->value; auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) { accessory.styles[j] = acc_styles->at(j)->value; } auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); accessory.relativePosition = rel_pos_prop->vector; auto rel_pos_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFPOS); accessory.relativePositionOffset = rel_pos_offset_prop->vector; auto rel_rot_prop = acc_prop->at(MASS_ACCESSORY_RELROT); accessory.relativeRotation = rel_rot_prop->vector; auto rel_rot_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFROT); accessory.relativeRotationOffset = rel_rot_offset_prop->vector; auto local_scale_prop = acc_prop->at(MASS_ACCESSORY_SCALE); accessory.localScale = local_scale_prop->vector; } } void Mass::writeAccessories(Containers::ArrayView accessories, Gvas::Types::ArrayProperty* accs_array) { for(std::uint32_t i = 0; i < accs_array->items.size(); i++) { auto acc_prop = accs_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); auto& accessory = accessories[i]; acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex; acc_prop->at(MASS_ACCESSORY_ID)->value = accessory.id; auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) { acc_styles->at(j)->value = accessory.styles[j]; } auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); rel_pos_prop->vector = accessory.relativePosition; auto rel_pos_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFPOS); rel_pos_offset_prop->vector = accessory.relativePositionOffset; auto rel_rot_prop = acc_prop->at(MASS_ACCESSORY_RELROT); rel_rot_prop->vector = accessory.relativeRotation; auto rel_rot_offset_prop = acc_prop->at(MASS_ACCESSORY_OFFROT); rel_rot_offset_prop->vector = accessory.relativeRotationOffset; auto local_scale_prop = acc_prop->at(MASS_ACCESSORY_SCALE); local_scale_prop->vector = accessory.localScale; } } }