addmix / godot_aerodynamic_physics

MIT License
64 stars 2 forks source link

Allow offset of rotation on AeroSurfaces #18

Closed maxlittlemore closed 2 months ago

maxlittlemore commented 4 months ago

I've noticed it's kinda weird to get surfaces to behave nicely.

Problem: For a real aircraft a flight control will pivot around a line in 3D space offset from its geometric centre, but the surfaces in this library only pivot around the geometric centre of the node. I tried using dummy nodes to parent AeroSurface3Ds, but they were ignored by the AeroBody3D

Possible Solution #1: (probs easier) Every AeroSurface3D should include a pivot offset (float signifying distance on chord)

Possible Solution #2: (my fave) Attach every AreoSurface3D to a pivot line (Node3D + offset) and check the entire tree for valid AeroSurface3Ds in a vehicle and add them to the list of things to consider.

I love your work, hope it continues <3

addmix commented 4 months ago

I tried using dummy nodes to parent AeroSurface3Ds, but they were ignored by the AeroBody3D

This is actually something I have considered, where the AeroBody3D has a child Node3D, which then has a child AeroInfluencer. If I remember correctly, Godot has a similar feature for collision shapes, they will be recognized so long as they don't have another CollisionObject3D that would use that collision shape. This seems like the most flexible option, and isn't too difficult to implement, so it will probably be added.

In the meantime, the AeroRotator3D class (which need documentation) does allow you to add AeroInfluencer3D nodes as children, position them as needed, and apply rotations around a specified axis. Most importantly, it also accounts for the resulting forces of that movement making it the best option for propellers (there are already a few derived classes for propellers). AeroRotator3D may be your best option currently.

I think it would be a good idea to have a class that extends AeroRotator3D, which you can specify an axis of rotation, rotation speed, and target rotation for this exact scenario.

One last thing I would like to mention, the point at which the AeroInfluencer/AeroSurface exists is the point that all aerodynamic forces are applied. The square wing section that is shown is simply a visualization aid, and isn't going to realistically represent all wings, nor be realistic when positioning wings in all cases. I positioned it to follow a general rule where the center of aerodynamic pressure (forces) lies at the 1/4 mark from the leading edge of an airfoil.

addmix commented 2 months ago

Implemented in https://github.com/addmix/godot_aerodynamic_physics/commit/ac70d4451c649a9aa677c4871f8a0c151fbf7337