Closed MoreTore closed 3 weeks ago
Basic support is in pre-release 0.5.7.2 (https://github.com/untoldwind/KontrolSystem2/releases/tag/v0.5.7.2). It is broken down to various part components, e.g.
Reason is that you can now do something like this:
use { Vessel } from ksp::vessel
use { sleep } from ksp::game
use { CONSOLE, RED, YELLOW, BLUE, GREEN } from ksp::console
use { DEBUG } from ksp::debug
pub fn main_flight(vessel: Vessel) -> Result<Unit> = {
CONSOLE.clear()
DEBUG.clear_markers()
for(part in vessel.parts) {
if(Some(drag) = part.drag) {
DEBUG.add_vector(fn() -> drag.global_drag_position, fn() -> 10 * drag.global_drag_force, RED, "Drag", 2)
DEBUG.add_vector(fn() -> drag.global_body_lift_position, fn() -> 10 * drag.global_body_lift_force, BLUE, "Body lift", 2)
}
if(Some(lift) = part.lifting_surface) {
DEBUG.add_vector(fn() -> lift.global_lift_position, fn() -> 10 * lift.global_lift_force, GREEN, "L1", 2)
DEBUG.add_vector(fn() -> lift.global_drag_position, fn() -> 10 * lift.global_drag_force, YELLOW, "D1", 2)
}
if(Some(control) = part.control_surface) {
DEBUG.add_vector(fn() -> control.global_lift_position, fn() -> 10 * control.global_lift_force, GREEN, "L2", 2)
DEBUG.add_vector(fn() -> control.global_drag_position, fn() -> 10 * control.global_drag_force, YELLOW, "D2", 2)
}
}
while(true) {
const total_drag = vessel.parts.filter_map(fn(p) -> p.drag).reduce(0.0, fn(f, d) -> f + d.drag_force.magnitude)
const total_body_lift = vessel.parts.filter_map(fn(p) -> p.drag).reduce(0.0, fn(f, d) -> f + d.body_lift_force.magnitude)
const total_lift = vessel.parts.filter_map(fn(p) -> p.lifting_surface).reduce(0.0, fn(f, l) -> f + l.lift_force.magnitude)
const total_lift_drag = vessel.parts.filter_map(fn(p) -> p.lifting_surface).reduce(0.0, fn(f, l) -> f + l.drag_force.magnitude)
const total_control_lift = vessel.parts.filter_map(fn(p) -> p.control_surface).reduce(0.0, fn(f, l) -> f + l.lift_force.magnitude)
const total_control_lift_drag = vessel.parts.filter_map(fn(p) -> p.control_surface).reduce(0.0, fn(f, l) -> f + l.drag_force.magnitude)
CONSOLE.print_at(1, 0, $"total_drag: {total_drag}")
CONSOLE.print_at(2, 0, $"total_body_lift: {total_body_lift}")
CONSOLE.print_at(3, 0, $"total_lift: {total_lift}")
CONSOLE.print_at(4, 0, $"total_lift_drag: {total_lift_drag}")
CONSOLE.print_at(5, 0, $"total_control_lift: {total_control_lift}")
CONSOLE.print_at(6, 0, $"total_control_lift_drag: {total_control_lift_drag}")
sleep(0.1)
}
}
... ok this is pretty cluttered, but you get the idea ...
This will fill the lack of aero-viewer in ksp2 *o*
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
It would be usefull to add drag froce to the vessel like microengineer
https://github.com/Micrologist/MicroEngineer/blob/main/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs