Jump to content

Fengist's Online Drag Cube Calculator


Recommended Posts

So, if you haven't been watching my frustration with drag cubes in this thread:

You're missing all the fun!

I realize not everyone is going to be needing to play with drag cubes.  But trust me on this, if you create parts, sooner or later, it's going to catch up to you.

Here's a tidbit I learned in my experiments that I haven't read anywhere.  If you add in a DRAG_CUBE to your part.cfg, it will overwrite the PartDatabase.cfg!  It'll even change the entry in the PartDatabase.cfg to match your part.cfg entry. That means, if you screw up and release a part that's HUGE (not that anyone around here would do that), you're going to need to add in a fixed drag cube to your part.cfg file.  Otherwise, that database entry won't get recalculated unless your end user is using Module Manager.   And since not all of us do, you best make sure you put a manual drag cube in your .cfg file.

Next problem.  And this won't affect everyone but it affects me hugely.  Drag cubes have a serious effect on drag AND buoyancy.  So much so, I've come to the realization that I need to manually adjust any part that I have that comes into contact with the water.  That's a lot of parts.  And if you've seen the mess that the drag cube entry is... it's not pretty.

cube = Default, 14.605,0.3707,4.811, 14.605,0.3729,4.811, 18.040,0.31955,5.828, 18.040,0.28225,2.854, 14.71,0.3717,4.811, 14.71,0.3728,4.811, 0,3.73,0, 7.236,7.46,7.236
 

Yea, so trying to 'tweak' the drag cubes for a bunch of parts and having to run that through a calculator and manually enter in the new values?  Right... I didn't learn programming to waste my time with a calculator.

I present:

Fengist's Drag Cube Calculator

http://www.datainterlock.com/dragcubes.php

Ok, this is easy.  Copy the line from the drag cube, like the one above... and paste it into the text field on this web page.  Next, enter in the percentage change you want to each of the 3 fields... area, drag, depth.  And, through the magic of PHP, it'll spit out an adjusted drag cube with the new values.  Paste it into your .cfg file and voila... a customized drag cube and you didn't have to do any math.

Now pardon me while I go facedesk a few more times...

And should anyone want their own, here's the source code.  I hacked this together in about 15 minutes so it's not even close to pretty. It just works.

Do as you wish with it.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
if (isset($_POST["button"]) && $_POST["button"]=="Submit")
{
	//var_dump($_POST);
	if ($_POST["DragCube"]>'')
	{
		echo '<h2>Calculations</h2> <br>';
		echo 'Original Drag Cube: '.$_POST["DragCube"].'<br>';
		$firstcut = explode('=',$_POST["DragCube"]);
		$secondcut = explode(',',$firstcut[1]);
		$title = $secondcut[0];
		$outstring = 'cube = '.$title;
		$looper = 1;
		for ($x=1;$x<19;$x++)
		{
			switch ($looper)
			{
				case 1:
				{
					$newvalue = $secondcut[$x] * (floatval($_POST["AreaModifier"] / 100));
					echo 'Area: '.$secondcut[$x].' -> '.$newvalue.'&nbsp;&nbsp;&nbsp;';
					break;
				}
				case 2:
				{
					$newvalue = $secondcut[$x] * (floatval($_POST["DragPercentage"] / 100));
					echo 'Drag: '.$secondcut[$x].' -> '.$newvalue.'&nbsp;&nbsp;&nbsp;';
					break;
				}
				case 3:
				{
					$newvalue = $secondcut[$x] * (floatval($_POST["DepthPercentage"] / 100));
					echo 'Depth: '.$secondcut[$x].' -> '.$newvalue.'<br>';
					break;
				}
			}
			$outstring .= ',';
			$looper++;
			if ($looper > 3)
			{
				$looper = 1;
			}
			$outstring .= $newvalue;
		}
		for ($x=19;$x<25;$x++)
		{
			$outstring .= ','.$secondcut[$x];
		}
		echo '<br>';
		echo '<h2>New Drag Cube</h2><br>';
		echo 'DRAG_CUBE<br>';
		echo '{<br>';
		echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$outstring.'<br>';
		echo '}<br>';
		echo '<hr>';
	}
}
if (isset($_POST["AreaModifier"]))
{
	$v1 = $_POST["AreaModifier"];
}
else
{
	$v1 = 100;
}
if (isset($_POST["DragPercentage"]))
{
	$v2 = $_POST["DragPercentage"];
}
else
{
	$v2 = 100;
}
if (isset($_POST["DepthPercentage"]))
{
	$v3 = $_POST["DepthPercentage"];
}
else
{
	$v3 = 100;
}
?>
<form id="form1" name="form1" method="post" action="">
<h2> Fengist's Drag Cube Modifier </h2>
This is a KSP Drag Cube modifier.  It's purpose is to simply recalculate drag cubes based on a percentage of the original values.  Copy the single line representing the drag cube from the PartDatabase.cfg and paste it in the text box below.  Change the percentages to the new desired value and click submit.
  <p>Paste your one line from your Drag Cube below.</p>
  <p>It should look like this:</p>
  <p>cube = Default, 14.605,0.3707,4.811, 14.605,0.3729,4.811, 18.040,0.31955,5.828, 18.040,0.28225,2.854, 14.71,0.3717,4.811, 14.71,0.3728,4.811, 0,3.73,0, 7.236,7.46,7.236
</p>
  <p>Original Drag Cube
    <input name="DragCube" type="text" id="DragCube" size="100" maxlength="200" />
  </p>
  Enter in the percentage change you'd like to make to each of the 3 values.
  <p>Area Percentage Modifier
    <input name="AreaModifier" type="text" id="AreaModifier" value="<?php echo $v1; ?>" maxlength="3" />
  </p>
  <p>Drag Percentage Modifier
    <input name="DragPercentage" type="text" id="DragPercentage" value="<?php echo $v2; ?>" maxlength="3" />
  </p>
  <p>Depth Percentage Modifier
<input name="DepthPercentage" type="text" id="DepthPercentage" value="<?php echo $v3; ?>" maxlength="3" />
  </p>
  <p>
    <input type="submit" name="button" id="button" value="Submit" />
  </p>
</form>
</body>
</html>

 

Edited by Fengist
Link to comment
Share on other sites

  • 2 years later...

Hi,

Sorry to revive this old thread, but it's directly related to your post.

This might be something I'm looking for. But I want to make sure I understand and implement this properly.

Here's what I'm trying to do:

I running 1.2.2 (yeah, I don't see any reason to abandon that save and restart in a newer version) and I need to change the drag on the part below:

PART
{
    url = NearFutureSpacecraft/Parts/RCS/rcsblock-aero/rcsblock-aero-5way-1/rcsblock-aero-5way-1
    DRAG_CUBE
    {
        cube = Default, 0.114,0.9575,0.1246, 0.114,0.7514,0.2121, 0.03761,0.6311,0.3331, 0.03761,0.6303,0.3377, 0.03762,0.6281,0.3331, 0.03762,0.6307,0.3377, -0.04475,0.0001625,2.205E-09, 0.1381,0.3859,0.3859
    }

It's an RCS thruster block that I use on my spaceplane—I want to reduce the drag created by it to about half its original value. I found the above values from the PartDatabase.cfg from my game directory, and after copying them into your calculator and setting the "Drag Percentage Modifier" to 50%, I am presented with the "Calculations" and "New Drag Cube" values.

If I understand it right, I just need to place these values and the drag created by this part will be reduced.

Where do I place these values?

 

On 7/23/2016 at 10:57 PM, Fengist said:

Paste it into your .cfg file and voila...

Which cfg file are you referring to? The PartDatabase.cfg or the actual part cfg file from the Gamedata folder?

 

Appreciate your work and any help you are willing to dispense.

Edited by iFlyAllTheTime
Added your quote for clarification
Link to comment
Share on other sites

14 hours ago, iFlyAllTheTime said:

Which cfg file are you referring to?

Hi use this tool a lot for all kinds of things , so very familiar with it's use .
The modified drag cube has to go into the parts cfg,  Only this way will it be permanent and unchanged, if you paste the modded version into the part database cfg it will be rewritten at every load and return to the undesirable drag values , you can put it anywhere in  cfg although i've gone the squad way  and paste it in just before the part  modules.

Link to comment
Share on other sites

3 hours ago, SpannerMonkey(smce) said:

Hi use this tool a lot for all kinds of things , so very familiar with it's use .
 

3

Fantastic! I hope you don't mind if I pick your brain a little more...

The following is the part cfg file

//// Near Future Spacecraft 0.5.4
// Shielded 5-Way RCS Block
PART
{

	// --- general parameters ---
	name = rcsblock-aero-5way-1
	module = Part
	author = ChrisAdderley

	// --- asset parameters ---
	MODEL
	{
		model = NearFutureSpacecraft/Parts/RCS/rcsblock-aero/rcsblock-aero-5way-1
		position = 0.0, 0.0, 0.0
		scale = 1,1,1
		rotation = 0, 0, 0
	}
	scale = 1

	// --- node definitions ---
	// definition format is Position X, Position Y, Position Z, Up X, Up Y, Up Z
	node_attach = 0.00, -0.0, -0.00, 1.0, 0.0, 0.0

	// --- editor parameters ---
	TechRequired = specializedControl
	entryCost = 4000
	cost = 650
	category = Control
	subcategory = 0
	title = RV-105x5 RCS Thruster Block
	manufacturer = STEADLER Engineering Corps
	description = This aerodynamically shielded thruster block has a fifth nozzle for improved maneuvering. This comes at the cost of slightly lower total thrusts.

	// attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
	attachRules = 0,1,0,0,0

	// --- standard part parameters ---
	mass = 0.07
	dragModelType = default
	maximum_drag = 0.001
	minimum_drag = 0.001
	angularDrag = 2
	crashTolerance = 15
	maxTemp = 2300
	bulkheadProfiles = srf
	tags = cluster control dock maneuver manoeuvre react rendezvous rotate stab steer translate shielded nearfuture

	// --- rcs module parameters ---
	EFFECTS
	{
		running
		{
			AUDIO_MULTI_POOL
			{
				channel = Ship
				transformName = thrustVector
				clip = sound_rocket_mini
				volume = 0.0 0.0
				volume = 0.1 0.0
				volume = 0.5 0.025
				volume = 1.0 0.1
				pitch = 0.0 0.75
				pitch = 1.0 1.5
				loop = true
			}
			MODEL_MULTI_PARTICLE
			{
				modelName = Squad/FX/Monoprop_small
				transformName = thrustVector
				emission = 0.0 0.0
				emission = 0.1 0.0
				emission = 1.0 1.0
				speed = 0.0 0.8
				speed = 1.0 1.0
				localRotation = -90, 0, 0
			}
		}
	}
	MODULE
	{
		name = ModuleRCSFX
		thrusterTransformName = thrustVector
		thrusterPower = 0.9
		tagingEnabled = False
		resourceFlowMode = STAGE_PRIORITY_FLOW
		resourceName = MonoPropellant
		runningEffectName = running
		atmosphereCurve
		{
		 key = 0 240
		 key = 1 100
		}
	}
}

If I understand this correctly, I need to paste everything after "url = NearFutureSpacecraft...." all the way to the very last value "... 0.3859" inside of the "PART {..........................}" in the text file?

 

Link to comment
Share on other sites

3 minutes ago, iFlyAllTheTime said:

If I understand this correctly, I need to paste everything after "url = NearFutureSpacecraft...." all the way to the very last value "... 0.3859" inside of the "PART {..........................}" in the text file?

You've lost me there,  if you have the part as above,  you copy the parts original drag cube( from the partdatabase.cfg into the online tool, nothing else, then  using the same format  paste the results back into your part cfg, no need to create another cfg . an example below
 

Spoiler

PART
{
	name = xxxxxxxxxxx
	module = Part
	author = xxxxxxxxxx
//	-2.33
CoMOffset = 0.0, -2.33, 0

	
	MODEL
	{
		model = xxxxxxxxx/xxxxxx/xxxx
		scale = 1.0, 1.0, 1.0
	}
	rescaleFactor = 1
		NODE
{
name = Node1 //HULL
transform = Node1
size = 2
method = FIXED_JOINT
}
		NODE
{
name = Node2 //HULL
transform = Node2
size = 2
method = FIXED_JOINT
}

	TechRequired = aerodynamicSystems
	entryCost = 2600
	cost = 1250
	category = Aero
	subcategory = 0
	title = xxxxxxxxxxxxx
		manufacturer = xxxxxxxxxxxxxxxxxxx
	description = xxxxxxxxxxxxxxxxxxxxxxx
	mass = 13
	dragModelType = default
	maximum_drag = 0.1
	minimum_drag = 0.1
	angularDrag = 2
	crashTolerance = 30
	breakingForce = 200
	breakingTorque = 200
	maxTemp = 4000
	skinMaxTemp = 4000
	
	//vesselType = Ship
	fuelCrossFeed = True
	
	bulkheadProfiles = size1
	DRAG_CUBE
{
     cube = A, 50.29,0.49224,4.942,50.29,0.48912,8.56,16.02,0.57048,19.85,16.02,0.45376,20.34,229.3,0.78936,0.8803,229.3,0.74184,2.983, -0.002204,-0.7631,-0.5761, 9.722,20.22,2.918
	cube = B, 50.29,0.49224,4.942,50.29,0.48912,8.56,16.02,0.57048,19.85,16.02,0.45376,20.34,229.3,0.78936,0.8803,229.3,0.74184,2.983, -0.002204,-0.7631,-0.5761, 9.722,20.22,2.918
}
///////////////////////////////////////////////ANIMATIONS////////////////////////
	MODULE
	{
	   name = ModuleAnimateGeneric
	  layer = 1
	  
	 
	}
			MODULE
	{
		name = ModuleCargoBay
		
	}

	
	MODULE
	{
	   name = ModuleAnimateGeneric
	   layer = 2
	   
	   
	}
				MODULE
	{
		name = ModuleCargoBay
		DeployModuleIndex = 2
		closedPosition = 0
		lookupRadius = 2.5
		nodeInnerForeID = Node17
		nodeInnerAftID = Node13
	}
	MODULE
	{
		name = ModuleReactionWheel
		PitchTorque = 100
		YawTorque = 80
		RollTorque = 40
		RESOURCE
		{
			
		}
	}


//////LIFTING BODY/////////////////////////////////
	MODULE
	{
		
	}

//////////////////////GENERATOR////////////////////////

MODULE
	{
	
	{
	      
	}	
	OUTPUT_RESOURCE
	{
	   
	}	
}

	RESOURCE
	{
		
	}
	RESOURCE
	{
		
	}

}

 

 

Link to comment
Share on other sites

  • 1 year later...

It's back!

Thanks!

That has been an invaluable tool for me, for years. I have not had to use it in the past few months, but I used it regularly in the past, and now I have to fix several drag cubes.

When I saw the 404 error, I was like "OMG I am screwed... I have ZERO clue how to fix these without this tool"

Thanks again.

Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...

Hi, how to recalculate drag for "Size 1.5 Decoupler" (part of MakingHistory DLC)? If I leave the default drag in "cfg", then KSP will not recalculate the drag. If I delete the default drag in "cfg", KSP recalculates the drag incorrectly. The default size is 1.875m and drag cube is:

DRAG_CUBE
 {
      cube = 0, 0.5479,0.6578,1.063, 0.5479,0.6627,1.063, 2.363,0.7644,0.7397, 2.363,0.7599,0.5773, 0.5479,0.7109,1.063, 0.5479,0.7101,1.063, 0,0.00108,0, 1.917,0.5397,1.917
      cube = 1, 0.5479,0.6578,1.063, 0.5479,0.6627,1.063, 2.363,0.7644,0.7397, 2.363,0.7599,0.5773, 0.5479,0.7109,1.063, 0.5479,0.7101,1.063, 0,0.00108,0, 1.917,0.5397,1.917
  }

I need a recalculation for:

rescale = 2.66667 // (5.0m)

rescale = 2.0 // (3.75m)

rescale = 1.33333 // (2.5m)

rescale = 1.2  // (2.25m)

rescale = 0.8  // (1.5m)

rescale = 0.53333  // (1.0m)

rescale = 0.4  // (0.75m)

Thank you very much for your help.

Link to comment
Share on other sites

3 hours ago, RiCZrd said:

Hi, how to recalculate drag for "Size 1.5 Decoupler"

Hi. Never knew this thread ever existed. I use custom drag cubes for buoyancy issues and for making shapes that aren't aerodynamic work as lifting bodies.

I have no idea how to calculate drag cubes myself but instead create a basic shape in 3D modeler that has the dimensions I want and config it to appear in game. Load up so the game calculates a drag cube for it. I then go back out, open PartDatabase.cfg (found in the main Kerbal Space Program folder, not GameData.) and use the search function to find my uniquely named part. I then copy the Drag cube from in there into the real parts config file.

Now I don't know how you know that they are being calculated incorrectly but If there are any other parts that are basically the same size and shape you can use their drag cubes from the database and paste into your parts so that they override auto calculation.

Be interested to know why the drag cube of a decoupler is important in what you are doing?

Also @Lisias is the master of rescale and the guy who does all the hard work on Tweakscale, so may be able to give you some info on the subject.

Edited by ColdJ
Link to comment
Share on other sites

22 hours ago, ColdJ said:

Also @Lisias is the master of rescale and the guy who does all the hard work on Tweakscale, so may be able to give you some info on the subject.

Well.. mangling with the drag curves can be made extremely easy by using TweakScale to handle the mess for you. :) 

You can create a parte with "premade" TweakScale data with the TS's UI turned off, something like:

PART
{
	name = FancyPartsSize1
	bulkheadProfiles = size1, srf
	
	<lots of more stuff>
	
	TweakScale
	{
		type = stack_square
		defaltScale = 1.5
		available = false
	}
}

+PART[FancyPartsSize1]
{
	name = FancyPartsSize2
	%bulkheadProfiles = size2, srf
	@TweakScale
	{
		%currentScale = 2.5
	}
}

+PART[FancyPartsSize1]
{
	name = FancyPartsSize3
	%bulkheadProfiles = size3, srf
	@TweakScale
	{
		%currentScale = 3.75
	}
}

That code above mocks the definition of a part with the Size 1 bulkhead, then define two more similar parts but with 2.5 and 3.75 sizes. On all of them, TweakScale will be made unavailable (besides being active), meaning that the part is not user scalable and will behave forever as it would be a "stock defined" part.

You can even go Infernal Robotics style, and use only one part with the predefined sizes (as they would be variants):

SCALETYPE
{
	name = FancyScale_stacked
	freeScale = false
	scaleFactors = 1.5, 2.5, 3.75
	scaleNames = Mk1, Mk2, Mk3
	defaultScale = 1.5
}

PART
{
	name = FancyPartsMultiSize
	bulkheadProfiles = size1, size2, size3, srf
	
	<lots of more stuff>
	
	TweakScale
	{
		type = FancyScale_stacked
		defaultScale = 1.5
	}
}

The code above will create a PAW with the options "Mk1", "Mk2" and "Mk3" instead of the classic, free style scaling bar used normally by TweakScale.

Advantages:

  • No fuss, no buzz. Just define the new size of the thing, and you are done!
  • TweakScale handles any kind of KSP idiosyncrasy for you.
  • You don't need to learn how to scale 3rd party Modules - TweakScale does everything for you.
  • If something goes wrong, you have someone else to blame! :sticktongue:

Disadvantages:

  • You will create a dependency to TweakScale.

But… This may not be what you want. So, if you want to scale the drag cubes yourself, you need to understand what they are.

First, some needed background: there're 6 freedoms of movements - 3 linear, 3 angular:

800px-6DOF.svg.png

But we don't handle the angular ones on drag cubes, only the linear ones:

translations-diagram.jpg

On KSP, this translates:

  • Forward => +X
  • Back => -X
  • Left => -Y
  • Right => +Y
  • Up => +Z
  • Down => -Z

On VAB, +X points into the sky. On SPH, +X points into the hangar's door.

On KSP, the drag is not calculated using the surface's polygon hitting the airflow as one would expect. Instead, some arbitrary values (inferred by the surfaces when you let KSP do the job for you) are defined and these values are used by the Physics Engine to calculate the drag of the part when moving on that direction. The vector formed by the sum of all the 6 possible drag vectors (into Z+, into Z-, into X+, into X-, into Y+, into Y-) are the drag we see in red when we hit F12 while flying.

A mesh of a cube will have the same drag definition on all its 3 possible freedoms of movement.

A rectangular pyramid those top vertex is pointed into +Z will not. The +Z may have some drag (at the thing is somewhat aerodynamic), the -Z will have a huge drag (as the flat face is hitting the airstream), the +/-X and the +/-Y would have ~1/3 the -Z drag, because they are smaller than it and a little bit inclined, favouring some aerodynamics.

notWebP

Now, a triangular pyramid will be yet more different. Let's suppose the top vertex is pointed into +Z, and one of the edges is pointed into +X:

notWebP

 

The +Z and the -Z will be similar as the previous example, but the -X will be, let's guess, ⅔ of the -Z one (due the inclination) and the +X will be ⅓ of the -X one (as it's edge is facing the airstream and is way more aerodynamic than the -X one). Both +Y and -Y will have slightly less drag than -X, as these two faces are inclined in relation to the airstream.

Great. We now have the needed background to understand what the heck is a drag cube. Now let's discuss what the heck is a drag cube for KSP. :) 

A drag cube definition is a tuple with 3 elemens, where the first element is the area, the second is the "dragness" and the third is the depth (since the name "cube"): [A, d, D].  Each value is a float. The Area is straightforward, it is how much surface is hitting the airflow. The drag defines the "dragness" of the material - smooth surfaces will induce less parasitic drag than a rough one. I didn't figure out exactly what Depths models on this thing. The drag is nice because you can reuse values from parts with similar sizes but different surfaces, and then you just change de drag to reflect the surface's smoothness (or the medium in which its flowing).

@ColdJ, this is also interesting to define hydrodynamics. You can create drag cubes to be used under water, so you don't screw up the definition for the atmospheric flight. Essentially, you just copy&paste the dragcubes for atmosphere and change the dragness on each dragcube to reflect the viscosity of the water! :) (more later).

Somehow, KSP takes these 3 values, apply them into the current airflow and atmosphere density, and from this hat KSP gets the Drag being applied to the part on that direction of movement related to the airflow.

Oukey. Now we learnt how to define the DragCube for a single direction of movement. But we have another 5 to cope with. How we write it into a config file?

Well, this way:

DRAG_CUBE
{
	cube = <NAME>, <+X cube>, <-X cube>, <+Y cube>, <-Y cube>, <+Z cube>, <-Z cube>, <BOUNDS_CENTER>, <BOUNDS_EXTEND>
}

Since each cube is a tuple with 3 elements, you will see something like:

DRAG_CUBE
{
	cube = <NAME>, +XA, +Xd, +XD,   -XA, -Xd, -XD,   +YA, +Yd, +YD,   +YA, +Yd, +YD,   +ZA, +Zd, +ZD,   -ZA, -Zd, -ZD,   <BOUNDS_CENTER>,   <BOUNDS_EXTEND>
}

Nice. But what the heck is the BOUNDS thingies? There are more 2 tuples with 3 elements (X,Y,Z) where you define where is the center of the object and how long it extends from the center - i.e, you are defining the smallest cube what could fit the part's mesh inside. In essence, it's a "collider" cube that's used to see if the airflow will hit the part. Bounds Center is a X,Y,Z coordinate related to the origin of the part (think of it as the CoD - Center of Drag). Bounds Extend are sizes.

Practical example:

PART
{
	url = Squad/Parts/Aero/airlinerWings/MainWing/airlinerMainWing
	DRAG_CUBE
	{
		cube = Default, 4.031,0.7793,11.34, 4.031,0.2816,11.34, 4.736,0.5131,7.268, 4.736,0.3404,6.481, 29.19,0.9493,0.5587, 29.19,0.9497,0.5587, -5.512,0.125,-7.448E-08,11.33,7.823,0.9217
	}
}

Gave us:

  • Name : Default
  • +X
    • A = 4.031
    • d = 0.7793
    • D = 11.34
  • -X
    • A = 4.031
    • d = 0.2816
    • D = 11.34
  • +Y
    • A = 4.736
    • d = 0.5131
    • D = 7.268
  • -Y
    • A = 4.736
    • d = 0.3404
    • D = 6.481
  • +Z
    • A = 29.19
    • d = 0.9493
    • D = 0.5587
  • -Z
    • A = 29.19
    • d = 0.9497
    • D = 0.5587
  • Bounds Center
    • X = -5.512
    • Y = 0.125
    • Z = -7.448E-08
  • Bounds Extend
    • X = 11.33
    • Y = 7.823
    • Z = 0.9217

Since this is a wing, consider that the drag will be very different depending the face that it's hitting the airflow (as we intuitively would presume).

Great, now we know how to read and write dragcubes. But how in hell we scale that damned thing? :)

Well, it's more or less intuitive. If I have a part with 3 times the size of the reference one, we need to scale the dragcube accordingly.

For a part with 3 times the size, we have a factor of 3. All unidimentional values are multiplied by 3, all bidimensional values are multiplied by 3**2 = 9.

So, all Areas should be multplied by 9. All Depths by 3. The Bounds Center and the dragness are not changed, and the Bounds Extends dimensions are multiplied by 3 too:

  • Name : Default_times_3
  • +X
    • A = 4.031 * 9
    • d = 0.7793
    • D = 11.34 * 3
  • -X
    • A = 4.031 * 9
    • d = 0.2816
    • D = 11.34 * 3
  • +Y
    • A = 4.736 * 9
    • d = 0.5131
    • D = 7.268 * 3
  • -Y
    • A = 4.736 * 9
    • d = 0.3404
    • D = 6.481 * 3
  • +Z
    • A = 29.19 * 3
    • d = 0.9493
    • D = 0.5587 * 3
  • -Z
    • A = 29.19 * 9
    • d = 0.9497
    • D = 0.5587 * 3
  • Bounds Center
    • X = -5.512
    • Y = 0.125
    • Z = -7.448E-08
  • Bounds Extend
    • X = 11.33 * 3
    • Y = 7.823 * 3
    • Z = 0.9217 * 3

or:

  • Name : Default_times_3
  • +X
    • A = 36.279
    • d = 0.7793
    • D = 34.02
  • -X
    • A = 36.279
    • d = 0.2816
    • D = 34.02
  • +Y
    • A = 69.624
    • d = 0.5131
    • D = 21.804
  • -Y
    • A =69.624
    • d = 0.3404
    • D = 19.443
  • +Z
    • A = 262.71
    • d = 0.9493
    • D = 1.6761
  • -Z
    • A = 262.71
    • d = 0.9497
    • D = 1.6761
  • Bounds Center
    • X = -5.512
    • Y = 0.125
    • Z = -7.448E-08
  • Bounds Extend
    • X = 33.99
    • Y = 23769
    • Z = 2.7651

Shoving these wall of numbers into a config:

PART
{
	url = Squad/Parts/Aero/airlinerWings/MainWing/airlinerMainWing_times_3
	DRAG_CUBE
	{
		cube = Default,   36.279,0.7793,34.02   36.279, 0.2816, 34.02   69.624, 0.5131 21.804,   69.624,0.3404,19.443,   262.71,0.9493,1.6761,   262.71,0.9497,1.6761,   -5.512,0.125,-7.448E-08,   33.99,23769,2.7651
	}
}

As we can see, all of this is very simple, straightforward and intuitive. :sticktongue:

In time, this is for @ColdJ:

You can define a dragcube to be used under water. From the part I used as example above:

PART
{
	name = airlinerMainWing
	module = Part

	// Yada yada yada

	MODEL
	{
		model = Squad/Parts/Aero/airlinerWings/MainWing
	}

	DRAG_CUBE
	{
		cube = Default, 4.031,0.7793,11.34, 4.031,0.2816,11.34, 4.736,0.5131,7.268, 4.736,0.3404,6.481, 29.19,0.9493,0.5587, 29.19,0.9497,0.5587, -5.512,0.125,-7.448E-08,11.33,7.823,0.9217
		cube = BuoyancyDragCube, 4.031,7.793,11.34, 4.031,2.816,11.34, 4.736,5.131,7.268, 4.736,3.404,6.481, 29.19,9.493,0.5587, 29.19,0.9497,0.5587, -5.512,0.125,-7.448E-08,11.33,7.823,0.9217
	}

	buoyancyUseCubeNamed = BuoyancyDragCube

	// Yada yada yada
}

Note that BuoyanceDragCube is the exact Default one, but with the dragness multiplied by 10 (number pulled from my hat, just to make a point).

Your main problem is that you will need to have the DragCubes precalculated on the part config itself, as when you define the DRAG_CUBE KSP will not do it for you, and you don't want the dragcube used for water to be used on the atmosphere.

Cheers!

 

 

Edited by Lisias
references
Link to comment
Share on other sites

@RiCZrd please read the above post.

@Lisias very nice to have a proper explanation, trouble is I tend to glaze over with big technical explanations.

At the end, my brain is reading both drag cubes as being the same. Did I miss the bit where it is treating it as 10 times as draggy?

Also the drag cube of a part determines how buoyant a part is in relation to it's mass so if I make a part for a submarine I generally give it the drag cube of a part with a smaller diameter so that it doesn't take an over the top amount of mass to sink it. Drag cube also determines how a craft will float on the surface, so I give boat or craft that I want to sit natural in the water a drag cube that makes them look right when they are floating.

The game already increases underwater drag imensely. Craft that will go 300m/s in the air will only do about 20m/s underwater. So for water craft I give them an atmospere curve that will kill the engine 10 metres above the surface. Getting closer is possible but takes much finessing.

Link to comment
Share on other sites

1 hour ago, ColdJ said:

@Lisias very nice to have a proper explanation, trouble is I tend to glaze over with big technical explanations.

Yep. The information density of that thing is pretty high!

 

1 hour ago, ColdJ said:

At the end, my brain is reading both drag cubes as being the same. Did I miss the bit where it is treating it as 10 times as draggy?

It's the problem with large streams of numbers, humans are not trained to handle them. :P 

I will try to highlight the affected numbers:

cube = Default, 4.031,0.7793,11.34, 4.031,0.2816,11.34, 4.736,0.5131,7.268, 4.736,0.3404,6.481, 29.19,0.9493,0.5587,
                                                                            
29.19,0.9497,0.5587, -5.512,0.125,-7.448E-08,11.33,7.823,0.9217

cube = BuoyancyDragCube, 4.031,7.793,11.34, 4.031,2.816,11.34, 4.736,5.131,7.268, 4.736,3.404,6.481, 29.19,9.493,0.5587,
                                                                             
29.19,0.9497,0.5587, -5.512,0.125,-7.448E-08,11.33,7.823,0.9217

O broke the line to separated the dragcubes from the Bounds ones. Try to mentally group the numbers in "arrays" of elements, and name them [A, d, D] where A = Area, d = dragness, D = Depth. On the code above, all the dragness (d) are in red.

To create a dragcube to be used under water, essentially duplicate the dragcube used on atmosphere, change de dragness of each "array of 3" to the number that satisfy you and set 

buoyancyUseCubeNamed = BuoyancyDragCube

where the value is the name of the dragcube you created. The first dragcube (labeled Default above) are always used on Atmospheric flight - unless I find some more info telling me how to customise it. I can think on a part with many dragcubes definitions and some code selecting the one depending of the environment the craft is travelling. Or even specialised dragcubes to change the drag based on the mach number the part is travelling.

 

1 hour ago, ColdJ said:

Also the drag cube of a part determines how buoyant a part is in relation to it's mass so if I make a part for a submarine I generally give it the drag cube of a part with a smaller diameter so that it doesn't take an over the top amount of mass to sink it. Drag cube also determines how a craft will float on the surface, so I give boat or craft that I want to sit natural in the water a drag cube that makes them look right when they are floating.

Yep. But by doing that you are also changing how the part is behaving on the atmosphere.  By using two sets of dragcubes, you can trimm the water one without changing the atmospheric one.

It will be also the key to scaling parts without changing the buoyancy, as it's happening on TweakScale (remember that video on TS thread?).

Link to comment
Share on other sites

@Lisias That made it easier. No matter how many times I read it before I could never see that.

So "buoyancyUseCubeNamed" is an actual parameter the program recognises?

If so, good to know, also are there others?

We really need someone to do an updated thread on all the available modules, their parameters and how they work.

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...