Jump to content

Simple Module-Manager Plugin


arkie87

Recommended Posts

I want to make a plugin that performs simple modifications to all parts. All it would do is scale all drag coefficient values by:

C_d_new = C_d_old / mass * Cross-sectional-Area / 0.008

How would i got about doing this? Do i even need a compiler, or can i write the modifications for module-manager to perform? Furthermore, can mass and cross-sectional area be taken dynamically from the part information or do i have to know the values for each part?

Link to comment
Share on other sites

Arkie, what you're trying to do is ambiguous, particularly at the cross-sectional area part. If you assume a certain orientation, you might be able to write a MM config which scales the minimum_drag and maximum_drag values so that the math works out to give you a sane drag value. This would essentially be stock aero with drag values cleverly scaled to divide out the mass and hard-coded 0.008, and instead use some default Cd*cross-section. However, if you plan to do anything like exposed cross-sectional area, or orientation-dependent cross-section, you're going to need to write a plugin.

EDIT: I'm not sure how much math you can do in an MM config, so there's a good chance you would have to plug in the values into a spreadsheet, and then manually patch the drag values for each and every part. I know you can do some things using math in MM configs, but you'd need to parse out the object size out of the part config, and that's no easy task.

Also, aerodynamics under such an MM config-based model would be downright weird. You've destroyed the "drag centered at mass" assumption which makes stock aero kinda work, and it's still not going to act like a realistic aerodynamics model.

Edited by Starman4308
Link to comment
Share on other sites

Arkie, what you're trying to do is ambiguous, particularly at the cross-sectional area part. If you assume a certain orientation, you might be able to write a MM config which scales the minimum_drag and maximum_drag values so that the math works out to give you a sane drag value. This would essentially be stock aero with drag values cleverly scaled to divide out the mass and hard-coded 0.008, and instead use some default Cd*cross-section. However, if you plan to do anything like exposed cross-sectional area, or orientation-dependent cross-section, you're going to need to write a plugin.

EDIT: I'm not sure how much math you can do in an MM config, so there's a good chance you would have to plug in the values into a spreadsheet, and then manually patch the drag values for each and every part. I know you can do some things using math in MM configs, but you'd need to parse out the object size out of the part config, and that's no easy task.

Also, aerodynamics under such an MM config-based model would be downright weird. You've destroyed the "drag centered at mass" assumption which makes stock aero kinda work, and it's still not going to act like a realistic aerodynamics model.

So if i can call part diameter dynamically, then i can calculate cross sectional area (assuming zero AoA) i.e. A_c = pi D^2 /4. Is there a way to dynamically call part diameter and part mass?

Exactly, i'm trying to undo the assumption of A = 0.008 m, by adjusting C_d (instead of changing how KSP treats aerodynamics altogether like NEAR and FAR). This would create some interesting phenomena, such as longer fuel tanks having reduced drag while shorter parts assembled to the same length would have more drag proportional to the square of the number of parts.

Yeah, i'm worried about that. I was thinking maybe i should just try to manually do this via part file edits and see what happens. I dont agree that it would destroy the drag centered at mass assumption. The center of mass wouldnt change (obviously); the center of drag/lift would though...

Link to comment
Share on other sites

So I've gotten this to work:

@PART[fuelTank]

{

@minimum_drag = 0.122718463

@maximum_drag = 0.122718463

}

However, i'd like to be able to calculate the given value dynamically:

@PART[fuelTank]

{

@diameter = 1.25

@minimum_drag *= 3.14159*@diameter^2/4/0.008/@mass

@maximum_drag *= 3.14159*@diameter^2/4/0.008/@mass

}

Or something like that, where diameter i have to define (since its not in there).

Is there a way to call part properties dynamically?

Link to comment
Share on other sites

And how do you plan to find out diameter?

Also, you do realize mass changes in flight, right? Resources get added or removed.

Diameter is available for standard parts, but i would have to manually add a new field called diameter. Alternatively, i could ignore it.

I am aware of that, but Starwaster's stock drag fix takes care of this http://forum.kerbalspaceprogram.com/threads/84978-0-90-Stock-Drag-Fix-Dec-16-2014

I am looking to take care of the fact that drag coefficients are unrealistically large, especially for heavy parts, since drag is proportional to mass, by scaling drag coeffiicents by mass to remove dependency.

I think with my fix combined with Starwaster's would make stock terminal velocities closer to NEAR or FAR, without the added complexity. Though, apparently Maxmaps announced new update will have (improved) aerodynamics so it might be obsolete soon...

Link to comment
Share on other sites

I think you'd definitely need to write a plugin for that. Currently we don't have the ability to reference other part parameters in complex equations. The best you can do it maybe use some advanced MM patching stuff to reference the parameter's old value to calculate the new one, but that would be the limit currently.

Link to comment
Share on other sites

I think you'd definitely need to write a plugin for that. Currently we don't have the ability to reference other part parameters in complex equations. The best you can do it maybe use some advanced MM patching stuff to reference the parameter's old value to calculate the new one, but that would be the limit currently.

So I asked Sarbian and he gave me this format:

So it is possible to dynamically call the parts mass. Part diameter doesnt exist, so i would have to write a patch for each part or group of parts to add a diameter property.

@Part[*]:Final

{

@maximum_drag /=#$mass$

}

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...