Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- #include <math.h>
- using namespace std;
- int main(int argc, char *argv[])
- {
- ofstream output ("output.cfg");
- string name;
- cout << "Name:";
- cin >> name;
- output << "@Kopernicus:AFTER[Kopernicus]" << '\n';
- output << "{" << '\n';
- output << " Body" << '\n';
- output << " {" << '\n';
- output << " name = " << name << '\n';
- output << " Template" << '\n';
- output << " {" << '\n';
- output << " name = Sun" << '\n';
- output << " removeProgressTree = false" << '\n';
- output << " }" << '\n';
- output << " Properties" << '\n';
- output << " {" << '\n';
- output << " mass = 7.0950549e+26" << '\n';
- output << " radius = 6571392" << '\n';
- output << " description = A potentially habitable brown dwarf." << '\n';
- output << " }" << '\n';
- output << " Orbit" << '\n';
- output << " {" << '\n';
- output << " referenceBody = Sun" << '\n';
- output << " inclination = 0" << '\n';
- output << " eccentricity = 0" << '\n';
- output << " semiMajorAxis = 1E+14" << '\n';
- output << " longitudeOfAscendingNode = 0" << '\n';
- output << " argumentOfPeriapsis = 0" << '\n';
- output << " meanAnomalyAtEpoch = 0" << '\n';
- output << " epoch = 0" << '\n';
- output << " color = 0.3,0.0,0.0,0.5" << '\n';
- output << " }" << '\n';
- output << " ScaledVersion" << '\n';
- output << " {" << '\n';
- output << " SolarLightColor" << '\n';
- output << " {" << '\n';
- output << " " << '\n';
- output << " sunlightColor = 1.0, 0.0, 0.0, 1.0" << '\n';
- output << " sunlightIntensity = 0.45" << '\n';
- output << " scaledSunlightColor = 1.0, 0.0, 0.0, 1.0" << '\n';
- output << " scaledSunlightIntensity = 0.45" << '\n';
- output << " IVASunColor = 1.0, 0.977, 0.896, 1.0" << '\n';
- output << " IVASunIntensity = 0.34" << '\n';
- output << " sunLensFlareColor = 0.2, 0.0, 0.0, 1.0" << '\n';
- output << " sunAU = 13599840256" << '\n';
- output << " brightnessCurve" << '\n';
- output << " {" << '\n';
- output << " key = -0.01573471 0.217353 1.706627 1.706627" << '\n';
- output << " key = 5.084181 3.997075 -0.001802375 -0.001802375" << '\n';
- output << " key = 38.56295 1.82142 0.0001713 0.0001713" << '\n';
- output << " }" << '\n';
- output << " }" << '\n';
- output << " " << '\n';
- output << " Material" << '\n';
- output << " {" << '\n';
- output << " emitColor0 = 0.3,0.0,0.2,1.0" << '\n';
- output << " emitColor1 = 0.3,0.0,0.2,1.0" << '\n';
- output << " sunspotColor = 1.0,0.0,0.0,1.0" << '\n';
- output << " rimColor = 0.4,0.05,0.05,1.0" << '\n';
- output << " rimPower = 0" << '\n';
- output << " rimBlend = 1.4" << '\n';
- output << " }" << '\n';
- output << "" << '\n';
- output << "" << '\n';
- output << " Coronas" << '\n';
- output << " {" << '\n';
- output << " Corona" << '\n';
- output << " {" << '\n';
- output << " rotation = 0" << '\n';
- output << " speed = -1" << '\n';
- output << " updateInterval = 5" << '\n';
- output << " scaleLimitX = 5" << '\n';
- output << " scaleLimitY = 5" << '\n';
- output << " scaleSpeed = 0.007" << '\n';
- output << "" << '\n';
- output << " Material" << '\n';
- output << " {" << '\n';
- output << " texture = ProcBrownDwarves/corona.png" << '\n';
- output << " inverseFade = 2.553731" << '\n';
- output << " }" << '\n';
- output << " }" << '\n';
- output << "" << '\n';
- output << " Corona" << '\n';
- output << " {" << '\n';
- output << " rotation = 0" << '\n';
- output << " speed = 1" << '\n';
- output << " updateInterval = 5" << '\n';
- output << " scaleLimitX = 5" << '\n';
- output << " scaleLimitY = 5" << '\n';
- output << " scaleSpeed = 0.009" << '\n';
- output << "" << '\n';
- output << " Material" << '\n';
- output << " {" << '\n';
- output << " texture = ProcBrownDwarves/corona.png" << '\n';
- output << " inverseFade = 2.553731" << '\n';
- output << " }" << '\n';
- output << " }" << '\n';
- output << " }" << '\n';
- output << " }" << '\n';
- output << " SolarPowerCurve" << '\n';
- output << " {" << '\n';
- output << " key = 206000000000 0 0 0" << '\n';
- output << " key = 13599840256 1 0 0" << '\n';
- output << " key = 68773560320 0.5 0 0" << '\n';
- output << " key = 0 10 0 0" << '\n';
- output << " }" << '\n';
- output << " } " << '\n';
- int planets;
- int moons = 3;
- cout << "Number of planets to generate:";
- cin >> planets;
- int pcounter = 1;
- int mcounter = 1;
- int body;
- float mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- //store constants
- double period, relativeMass, relativeDensity, relativeRadius;
- double mass, radius, density, factor, sma;
- double inc, ecc, fcc, man;
- double log10 = 2.302;
- double v1=-0.209594; //constants from the exoplanet mass-radius paper - Seager et al
- double v2=0.0799;
- double v3=0.413;
- double vm=10.55; //mass scaling factor
- double vr=3.9; // radius scaling factor
- do
- {
- body = rand() % 3;
- if (body == 0)
- {
- mass = ((mrand*10 + 0.1)*100)/100;
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- factor = v1+1/3*log10*(mass/vm)-v2*pow((mass/vm),v3);
- radius = (pow(10,factor)*vr*6371)*100;
- density = mass*4.0e12/(4/3*3.1416*pow(radius,3))/0.62/5.52;
- }
- else
- {
- mass = ((mrand/40+0.0001)*10000)/10000;
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- density = ((mrand*4 + 1) *100)/100/5.52;
- factor = v1+1/3*log10*(mass/vm)-v2*pow((mass/vm),v3);
- radius = (pow(10,factor)*vr*1415)*100;
- }
- mcounter = 1;
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- period = (((mrand*22 + 8 )*10 )/10)*3600;
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- sma = (mrand * 5);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- inc = (mrand * 5);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- ecc = (mrand / 10);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- man = (mrand * 6.28318531);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- fcc = rand() % 361;
- output << " Body" << '\n';
- output << " {" << '\n';
- output << " name = " << name << " " << pcounter << '\n';
- output << " Template" << '\n';
- output << " {" << '\n';
- output << " name = Tylo" << '\n';
- output << " }" << '\n';
- output << " Properties" << '\n';
- output << " {" << '\n';
- output << " description = A planet" << '\n';
- output << " radius = " << radius << '\n';
- output << " mass = 5.29157926281091E+22" << '\n';
- output << " @mass *= " << mass << '\n';
- output << " rotates = True" << '\n';
- output << " rotationPeriod = " << period << '\n';
- output << " tidallyLocked = false" << '\n';
- output << " initialRotation = 0" << '\n';
- output << " }" << '\n';
- output << " Orbit" << '\n';
- output << " {" << '\n';
- output << " referenceBody = " << name << '\n';
- output << " inclination = " << inc << '\n';
- output << " eccentricity = " << ecc << '\n';
- output << " semiMajorAxis = 1359984025" << '\n';
- output << " @semiMajorAxis *= " << sma << '\n';
- output << " longitudeOfAscendingNode = " << fcc << '\n';
- fcc = rand() % 361;
- output << " argumentOfPeriapsis = " << fcc << '\n';
- output << " meanAnomalyAtEpoch = " << man << '\n';
- output << " epoch = 0" << '\n';
- output << " color = 0.5,0.5,0.5,1" << '\n';
- output << " }" << '\n';
- output << " }" << '\n';
- do
- {
- mass = ((mrand/40+0.0001)*10000)/10000;
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- density = ((mrand*4 + 1) *100)/100/5.52;
- factor = k1+1/3*log10*(mass/km)-k2*pow((mass/km),k3);
- radius = (pow(10,factor)*kr*1415)*40;
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- sma = (mrand * 5);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- inc = (mrand * 5);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- ecc = (mrand / 10);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- man = (mrand * 6.28318531);
- mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- fcc = rand() % 361;
- output << " Body" << '\n';
- output << " {" << '\n';
- output << " name = " << name << " " << pcounter << "." << mcounter << '\n';
- output << " Template" << '\n';
- output << " {" << '\n';
- output << " name = Tylo" << '\n';
- output << " }" << '\n';
- output << " Properties" << '\n';
- output << " {" << '\n';
- output << " description = A moon" << '\n';
- output << " radius = " << radius << '\n';
- output << " mass = 5.29157926281091E+22" << '\n';
- output << " @mass *= " << mass << '\n';
- output << " rotates = True" << '\n';
- output << " rotationPeriod = " << period << '\n';
- output << " tidallyLocked = false" << '\n';
- output << " initialRotation = 0" << '\n';
- output << " }" << '\n';
- output << " Orbit" << '\n';
- output << " {" << '\n';
- output << " referenceBody = " << name << " " << pcounter << '\n';
- output << " inclination = " << inc << '\n';
- output << " eccentricity = " << ecc << '\n';
- output << " semiMajorAxis = 12000000" << '\n';
- output << " @semiMajorAxis *= " << sma << '\n';
- output << " longitudeOfAscendingNode = " << fcc << '\n';
- fcc = rand() % 361;
- output << " argumentOfPeriapsis = " << fcc << '\n';
- output << " meanAnomalyAtEpoch = " << man << '\n';
- output << " epoch = 0" << '\n';
- output << " color = 0.5,0.5,0.5,1" << '\n';
- output << " }" << '\n';
- output << " }" << '\n';
- mcounter++;
- } while (mcounter <= moons);
- pcounter++;
- } while (pcounter != planets);
- output << "}" << '\n';
- std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement