Open theodoregoetz opened 9 years ago
All parts already have a :FACING, whether they're engines or not. All parts already have a :POSITION, but it's currently bugged. A new fix for this is in a pull request already.
The part's position is in absolute terms, but it's in the same reference frame as the ship's position (which is it's COM), so it should be possible to get the part's position relative to the ship's COM with just vector subtraction.
The only missing piece is that the Part's POSITION is the location of the center of it's mesh model's local coords, which is sometimes NOT the position of the application of its thrust, which matters for calculating the fulcrum arm between that spot and ship COM. (i.e. the point of thrust on an engine is not it's center, but rather it's nozzle which tends to be toward the bottom of the model not in its center..)
One issue that we will run into if we dont have a thrust vector for engines would be thrust gimbal and many VTOL engines that can redirect their thrust.
You might be able to use the gimbal module's current roll, pitch and yaw values, combined with its gimbal range to get the angle off of FACING and rotate that vector accordingly to get thrust. That sounds like a fun function to write.
Actually, just pull the .thrustTransforms array and sum the vectors present in it and you will get the thrust direction for that ModuleEngines/ModuleEnginesFX.
This vector is what the game looks at to apply thrust so the ModuleGimabal actually changes the .thrustTransform's relative position to the part when gimballing so compensating for the gimbal can be ignored with this method.
Note that in actuality the total thrust of the ModuleEngine is evenly split between all .thrustTransforms on the part, but I am not aware of any parts that don't line all thrustTransforms pointing in the same direction.
Similar to #350 But for specific parts. Needs both position relative to vessel center of mass and direction relative to facing.
Not sure if this can be extended to block RCS type thrusters.