Jump to content

Recommended Posts

So looking at how the new aerodynamics interact with hollow parts (cargo bays, etc), I'm wondering how the drag cubes work and how they're defined. I can infer from the stock parts that they have coordinates for all eight corners of a box, but there are two of then defined for each part, and I'm not sure what they do exactly or how the coordinate system works.

Below is an example from the Mk2 long cargo bay (mk2CargoBayL). The bay's length, according to the stack nodes, is about 3.5m, randing from +1.875m to -1.875m. Obviously the width is smaller, and yet the cubes have much larger coordinates.

I'm guessing that the cargo bays in my mod packs are probably not behaving the same without these?


DRAG_CUBE
{
cube = A, 5.658236,0.420993,1.323529, 5.658236,0.4213952,1.323529, 2.494907,0.962501,0.154902, 2.494907,0.9625011,0.154902, 9.393588,0.9362289,0.7000003, 9.393588,0.9330578,0.7000003, 0,0.0002499819,0, 2.5,3.7505,1.500001
cube = B, 7.086244,0.5649103,2.071565, 7.086244,0.5715333,2.071565, 2.494907,0.962501,0.154902, 2.494907,0.9625011,0.154902, 14.94524,0.8164638,1.929913, 14.94524,0.8081035,2.098116, 8.34465E-07,0.0002498627,-0.2787333, 3.992453,3.750501,2.057467
}

Link to comment
Share on other sites

Take a cube, put it in a dress and high heels, viola! drag cube.

all jokes aside, your guess is as good as mine. but I would imagine that it's an aerodynamic collider containing dimensions and coefficients. I see some of the values are in scientific notation too...

Link to comment
Share on other sites

Both of you are wrong.

The drag cubes are created by rendering the part from the perspective of the sixe faces of a cube. The first six triplets are the six faces of the cube, with the first value being the area, the second the drag coefficient, and the third it's depth. Mind you, the drag cubes do not represent an actual shap or object.

The nice thing is that unless you are going to create your own PartModule, you don't have to worry at *all* about them. They are created automatically for each part by the game. If your cargo bays use the stock cargo bay module, then the cargo bay module will direct the drag cube rendering system to create the correct cubes for the part. If you plan to deal with them through code for some reason, I'm open to answer to any other question you might have :)

Link to comment
Share on other sites

Well, 99% automatically. If your part is hollow, you will need to manually adjust its cube. That's why hollow parts have custom cubes defined in their part cfgs.

In particular, for a stackmounted hollow part, change the Y+ and Y- area values (the first numbers in the third and fourth groupings) to be the area for a non-hollow version of that part.

Link to comment
Share on other sites

Ah crap, so I do need to include them then. It's my hollow cargo bays that I'm concerned about. I'm assuming that the "A" and "B" versions are for with the doors open and closed.

Is there a way to view the calculated version so I can just tweak that to insert in the configs? If not, then I guess I need to calculate by hand, and/or just guesstimate some values.

Also, since there are sets for +/- X,Y,Z, what are the last two groupings?

Link to comment
Share on other sites

Has anyone come across more information regarding the drag-cubes? I have a Command pod with integrated parachute that refuses to properly automatically calculate its drag cubes (likely due to additional non-parachute related animations), and it is looking like I will need to override/custom specify all drag-cubes in the part .cfg file. I guess the missing bits of info are -- if the first six groups are for the aspect projects from each orientation, what do the last two groups of numbers represent?

Link to comment
Share on other sites

It looks like (but I don't know for sure) that the last triplet may be dimensional information, specifically linear sizes for X,Y,Z. I have no idea on the second to last. So far I've used values close to the stock cargo bays that define the drag cubes in the CFG.

Link to comment
Share on other sites

the first six triplets are X+, X-, Y+, Y-, Z+, Z- faces of the cube. The numbers are area, drag coefficient, and depth of widest point from the frontmost point at that angle. The nextr triplet is the bounds center, the final is the bounds extents.

Link to comment
Share on other sites

  • 1 month later...

Sorry for the necro here, but I just started digging into drag cubes myself (thanks for the above info, it was quite helpful), and rigged up the following MonoBehavior to spit out the drag cubes for all the parts in the game in the same format as in the .cfg files to the log file, and thought others might find it helpful as well:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UnityEngine;

namespace BTSM
{
[KSPAddon( KSPAddon.Startup.MainMenu, false )]
class BTSMMonoBehaviorDebugOutput : MonoBehaviour
{
void Start()
{
OutputAllPartsDrag();
}

private void OutputAllPartsDrag()
{
if ( PartLoader.Instance != null && PartLoader.Instance.parts != null )
{
foreach ( AvailablePart tempAvailablePart in PartLoader.Instance.parts )
{
if ( tempAvailablePart.partPrefab != null )
{
Part tempPart = tempAvailablePart.partPrefab;

Debug.Log( "Drag Cubes for: " + tempAvailablePart.name + ", " + tempAvailablePart.title );

foreach ( DragCube tempCube in tempPart.DragCubes.Cubes )
{
Debug.Log( "\r\n\tDRAG_CUBE\r\n\t{\r\n\t\tcube = " + tempCube.Name + ", " +
tempCube.Area[0] + "," + tempCube.Drag[0] + "," + tempCube.Depth[0] + ", " +
tempCube.Area[1] + "," + tempCube.Drag[1] + "," + tempCube.Depth[1] + ", " +
tempCube.Area[2] + "," + tempCube.Drag[2] + "," + tempCube.Depth[2] + ", " +
tempCube.Area[3] + "," + tempCube.Drag[3] + "," + tempCube.Depth[3] + ", " +
tempCube.Area[4] + "," + tempCube.Drag[4] + "," + tempCube.Depth[4] + ", " +
tempCube.Area[5] + "," + tempCube.Drag[5] + "," + tempCube.Depth[5] + ", " +
tempCube.Center.x + "," + tempCube.Center.y + "," + tempCube.Center.z + ", " +
tempCube.Size.x + "," + tempCube.Size.y + "," + tempCube.Size.z +
"\r\n\t}\r\n" );
}
}
}
}
}
}
}

I'm finding it extremely useful if you want to tweak the values on a part you've created or what have you, as you can just copy/paste the ones that stock generates into your .cfg file and then go from there.

Edited by FlowerChild
Link to comment
Share on other sites

Sorry for the necro here, but I just started digging into drag cubes myself (thanks for the above info, it was quite helpful), and rigged up the following MonoBehavior to spit out the drag cubes for all the parts in the game in the same format as in the .cfg files to the log file, and thought others might find it helpful as well:

That's really cool. I have to admit, I've never tried attaching scripts to KSP before, nor have I worked with Mono. Anything special that needs to be done to run this?

Link to comment
Share on other sites

That's really cool. I have to admit, I've never tried attaching scripts to KSP before, nor have I worked with Mono. Anything special that needs to be done to run this?

Well, if you've never done it before, it's likely a bit beyond the scope of this thread. Given it's the plugin development forum I assumed people would know how to compile a plugin :)

On the good news front though, turns out it's entirely unnecessary, as I discovered after writing the above that ModuleManager seems to already handle this (at least I think it's MM doing it, it might be stock outputting the results of compiling all the drag cubes). If you look in your KSP directory you'll find a PartDatabase.cfg file which contains all the existing drag cube values, and you can reference them from there.

Link to comment
Share on other sites

On the good news front though, turns out it's entirely unnecessary, as I discovered after writing the above that ModuleManager seems to already handle this (at least I think it's MM doing it, it might be stock outputting the results of compiling all the drag cubes). If you look in your KSP directory you'll find a PartDatabase.cfg file which contains all the existing drag cube values, and you can reference them from there.

It's stock behaviour to cache the generated drag cubes (good thing too, it cuts loading time almost in half). MM only messes with physics.cfg and the tech tree from the new stuff (the major giveaway being KSP generating the file in the working directory, not GameData)

Link to comment
Share on other sites

It's stock behaviour to cache the generated drag cubes (good thing too, it cuts loading time almost in half).

Yeah, I figured that bit out post-post as well :)

I'm uncertain as to whether it's a good thing though. Turns out my PartDatabase.cfg had become messed up somewhere between 1.02 & 1.04, and had some very whacky values in it that I was basing some of my tweaks off of before realizing I needed to delete it to get it to regenerate.

I'm now wondering if some of the complaints about 1.04 aero behavior in the community might be due to that. Still no idea why it happened, but for example, it lead to the stayputnik taking on a super-aerodynamic shape that was resulting in some very whacky behavior. It was actually that "this can't be right..." behavior that inspired me to start looking into the drag cube values.

If that thing isn't updating correctly from version to version of KSP, I can see a real tech support nightmare resulting.

Edited by FlowerChild
Link to comment
Share on other sites

MM ask KSP to rebuild that file if it detects any patch change. I guess KSP should also purge the file when the game version change...

Do you happen to know if it does? Would certainly give me some peace of mind if that were the case.

Link to comment
Share on other sites

Well, if you've never done it before, it's likely a bit beyond the scope of this thread. Given it's the plugin development forum I assumed people would know how to compile a plugin :)

No worries. It's something I've been meaning to dip my toes into, but haven't yet. (I'm a programmer, just in a very different world-- Perl in Linux) :)

Link to comment
Share on other sites

  • 3 weeks later...

Working on some chute parts. Most troubles solved except for fine calibrating. Wonder if anyone can share some wisdom about how to predict the drag performance of chutes?

I believe it depends now on actual semideployed/deployed chute size (in game meters) and "ModuleDragModifier"s and completely ignore "fullyDeployedDrag" parameter. How to calculate "ModuleDragModifier"s needed for safe Kerbin landing if I know deployed chute diameter and payload weight?

Link to comment
Share on other sites

  • 3 weeks later...
  • 7 months later...

Reading up about drag cubes because my Mars landing ballutes are behaving like they don't exist (although they're now very pretty, animated, pointing in the right direction and so on.  I stuck a 28m ballute on a mechjeb pod and it accelerated at the ground.  So, I figure there's something messed with my drag cubes, or which cubes are which (there's at least 3 for a chute).

Open partDatabase.cfg and find

PART
{
    url = NAR_MEM/Parts/MEM-Ballute/Ballute/MEMBallute
    DRAG_CUBE
    {
    }
}

Not filling me with confidence.  Deleting to see if it'll generate them.

 

Deleted my cached drag cube stanza (I hesitate to say I deleted my drag cubes, seeing there wasn't one) and it didn't generate.  For a ballute, I'm happy to actually create one (or steal the one from the XL chute and hack around with it), so I know what it'll be using.  It'd be nice to know why it didn't create one though.

Edited by TiktaalikDreaming
tried stuff
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...