mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 22:44:59 +01:00
The door wings are in the main model, where the door animation finds them, so seen from inside the vehicle they are lit like the exterior and ignore the compartment lights. A door panel put into the low poly interior instead stayed closed, since nothing moved it. A door wing animation now also picks up the submodel of the same name in the low poly interior, if it has one, and gives it the same pose (shift, rotate, fold with its child wings, plug). Placed under a compartment section, such a wing is lit with the section and follows its light switch. The pose maths moved unchanged to vehicle/doorwings.h, with unit tests. Assets: optional. No low poly interior in the SVN or in the Steam install has a submodel named like a door wing, so nothing changes for existing vehicles. To use it, a low poly interior gets the inside of each door wing as a submodel named like the wing in the main model (door1, door01, drzwi1, ...), with the same pivot and transform, under the compartment section it belongs to, with a SelfIllum threshold like the section's, and slightly inside the wing of the main model.
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <algorithm>
|
|
|
|
#include <glm/vec3.hpp>
|
|
|
|
// the poses of the animated door wings of a vehicle, for the door position of the mover. a wing is posed alike
|
|
// in the main model and, when the low poly interior has a submodel of the same name, in the interior as well
|
|
namespace door_wings {
|
|
|
|
// whether the animation with the given flags (TAnim::iFlags, the kind of animation in bits 4-7) moves a door wing
|
|
inline bool is_wing(int const Flags) {
|
|
return (Flags & 0xF0) == 0x10;
|
|
}
|
|
|
|
// odd numbered wings (door1, door3...) are on the left side of the vehicle, even numbered on the right
|
|
inline bool on_right_side(int const Number) {
|
|
return (Number & 1) == 0;
|
|
}
|
|
|
|
// sliding door (type 1): shifted along the vehicle
|
|
inline glm::vec3 slide(float const Position) {
|
|
return {0.f, 0.f, Position};
|
|
}
|
|
|
|
// plug door (type 4): pushed out first, up to Rangeout, then slid along the vehicle
|
|
inline glm::vec3 plug(float const Position, float const Rangeout) {
|
|
return {std::min(Position * 2.f, Rangeout), 0.f, std::max(0.f, Position - Rangeout * 0.5f)};
|
|
}
|
|
|
|
// folding door (type 3): the angles of the smaller wing, of the larger wing (its child) and of the step (the
|
|
// child of the larger wing)
|
|
struct fold_angles {
|
|
float smaller;
|
|
float larger;
|
|
float step;
|
|
};
|
|
|
|
inline fold_angles fold(float const Position) {
|
|
return {Position, -Position - Position, Position};
|
|
}
|
|
|
|
} // namespace door_wings
|