Пример #1
0
PrologElement * PrologRoot :: dir (char * location) {
	DIR * directory = opendir (strcmp (location, "*.*") == 0 ? "." : location);
	if (directory == NULL) return NULL;
	struct dirent * file = readdir (directory);
	struct stat st;
	PrologElement * directories = earth ();
	PrologElement * files = earth ();
	PrologElement * dp = directories;
	PrologElement * fp = files;
	while (file != NULL) {
		if (strcmp (file -> d_name, ".") != 0 && strcmp (file -> d_name, "..") != 0) {
			lstat (file -> d_name, & st);
			if (S_ISDIR (st . st_mode)) {
				dp -> setPair ();
				dp -> getLeft () -> setText (file -> d_name);
				dp = dp -> getRight ();
			} else {
				fp -> setPair ();
				fp -> getLeft () -> setText (file -> d_name);
				fp = fp -> getRight ();
			}
		}
		file = readdir (directory);
	}
	closedir (directory);
	return pair (directories, pair (files, earth ()));
}
Пример #2
0
// Draw method
void displayFcn()
{
  int xc = winWidth / 2, yc = winHeight / 2;
  float green[3] = {0.0, 0.75, 0.0};
  float orange[3] = {1.0, 0.6, 0};
  float red[3] = {1.0, 0.0, 0.0};
  float blue[3] = {0.0, 0.0, 1.0};

  // Clear display window.
  glClear(GL_COLOR_BUFFER_BIT);  

  glColor3f(1.0, 0.0, 0.0);

  Sun sun("Sun", xc, yc, 3.0);

  glColor3fv(green);
  Planet earth("Earth", xc, yc, 1.0, 1.0);

  glColor3fv(orange);
  Planet mercury("Mercury", xc, yc, 0.382, 0.39);

  glColor3fv(blue);
  Planet venus("Venus", xc, yc, 0.949, 0.72);

  glColor3fv(red);
  Planet mars("Mars", xc, yc, 0.532, 1.52);


  glFlush( );
}
Пример #3
0
void sun() 
{

	/*setup lightsource 1 at the center of the world*/
	GLfloat light_position[] = {0.0, 0.0, 0.0, 1.0};
	GLfloat light_ambient[] = {0.0, 0.0, 0.0, 0.0};			//"[...]keine ambient Komponente[...]"
	GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0};			//"[...]kräftige Diffuse- und"
	GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0};		//"Specular Komponenten besitzen."
	
	glLightfv(GL_LIGHT1, GL_AMBIENT,  light_ambient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE,  light_diffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, light_position);
	glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
	
	/*setup material specification of the sun*/
	GLfloat yellow[] = {1.0, 1.0, 0.0, 1.0};
	if(glIsEnabled(GL_LIGHT1)) {
		glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, yellow);
	}

	/*setup sphere representing the sun*/
	glColor3f(1.0, 1.0, 0.0);
	planet(0.8);
	glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, zeroes); // disable emission for everybody else

	earth();
	mars();
}
void display(void)
{
	lPosition();

	///////////////////////////////////////////////////////////////////////////////////////////////////////
	glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glColor3f (1.0, 1.0, 1.0);
	glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);			//Texturing Contour Anchored To The Object
	glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);			//Texturing Contour Anchored To The Object

	//glEnable(GL_TEXTURE_GEN_S);										//Auto Texture Generation
	//glEnable(GL_TEXTURE_GEN_T);										//Auto Texture Generation
	glEnable(GL_TEXTURE_2D);
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	stars();
	//glBindTexture(GL_TEXTURE_2D, g_cactus[1]);
	//gluSphere(g_text,0.4,48,48);
	stars();
	sun();
	adam();
	hesper();
	earth();
	mars();
	jupiter();
	saturn();
	uranus();
	neptune();
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	glDisable(GL_TEXTURE_2D);		
	//glDisable(GL_TEXTURE_GEN_S);										//Auto Texture Generation
	//glDisable(GL_TEXTURE_GEN_T);
	glutSwapBuffers();
}
unsigned short MoonPhaseCalendar::computeMoonPhase( const KStarsDateTime &date ) {

    KSNumbers num( date.djd() );
    KSPlanet earth( I18N_NOOP( "Earth" ), QString(), QColor( "white" ), 12756.28 /*diameter in km*/ );
    earth.findPosition( &num );

    m_Moon.findGeocentricPosition( &num, &earth );
    m_Moon.findPhase();

    return m_Moon.getIPhase();

}
Пример #6
0
PrologElement * PrologRoot :: dir (char * location) {
	WIN32_FIND_DATA find_data;
	HANDLE handle = FindFirstFile (location, & find_data);
	if (handle == INVALID_HANDLE_VALUE) return NULL;
	PrologElement * directories = earth ();
	PrologElement * files = earth ();
	PrologElement * dp = directories;
	PrologElement * fp = files;
	do {
		if (find_data . dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) {
			dp -> setPair ();
			dp -> getLeft () -> setText (find_data . cFileName);
			dp = dp -> getRight ();
		} else {
			fp -> setPair ();
			fp -> getLeft () -> setText (find_data . cFileName);
			fp = fp -> getRight ();
		}
	} while (FindNextFile (handle, & find_data));
	FindClose (handle);
	return pair (directories, pair (files, earth ()));
}
int main() {
  {
    auto& simple_bank = gkb().bankApplication().name("Bank").createBank();
    auto& andrzej = earth().registerCitizen("Andrzej");
    auto& checking = simple_bank.openCheckingAccount(andrzej);
  }

  {
    auto& simple_bank = gkb().bankApplication().name("Bank").createBank();
    auto& andrzej = earth().registerCitizen("Andrzej");
    auto& saving = simple_bank.openSavingAccount(andrzej);
  }

  {
    auto& simple_bank = gkb().bankApplication().name("Bank").createBank();
    auto& andrzej = earth().registerCitizen("Andrzej");
    auto& account_bic = simple_bank.openCurrencyAccount(andrzej, Currency::BIC);
    auto& account_dil = simple_bank.openCurrencyAccount(andrzej, Currency::DIL);
    auto& account_lit = simple_bank.openCurrencyAccount(andrzej, Currency::LIT);

    // trying to set buying rate of unknown currency is illegal
    try {
      simple_bank.exchangeTable().buyingRate(2.0);
      assert(false);
    }
    catch (...){
    }

    // trying to set buying rate of unknown currency is illegal
    try {
      simple_bank.exchangeTable().sellingRate(2.0);
      assert(false);
    }
    catch (...){
    }

  }
  return 0;
}
Пример #8
0
    void
    init_SunEarth( memory::Domain<floatType>& myDomain )
    {
      const memory::vector3D<double> rE( 0.0, simParams::distance_Sun_Earth, 0.0 );
      const memory::vector3D<double> vE( simParams::EarthSpeed, 0.0, 0.0 );
      //memory::vector3D<double> vE( 0.0, simParams::EarthSpeed, 0.0 );
      memory::Particle<double> earth( rE, vE, simParams::mass * simParams::partialEarthSun );

      const memory::vector3D<double> rS( 0.0, 0.0, 0.0 );
      const memory::vector3D<double> vS( 0.0, 0.0, 0.0 );
      memory::Particle<double> sun( rS, vS, simParams::mass );

      // initialize particles
      myDomain.addParticle( earth );
      myDomain.addParticle( sun );
    }
Пример #9
0
int main() {
  const int num_steps=1000;
  const real_t x=1., y=1., z=1., sigma=10., rho=28, beta=8./3., dt=0.02;

  air sky(x, sigma);
  cloud puff(y, rho);
  ground earth(z, beta);
  ptr_t boundary_layer = ptr_t(new atmosphere(sky, puff, earth));

  real_t t = 0.;
  std::cout << fmt(t,5,2) << " "
	    << fmt(boundary_layer->state_vector()) << "\n";
  for(int step = 1; step <= num_steps; ++step) {
    integrate(boundary_layer, dt);
    t += dt;
    std::cout << fmt(t,5,2) << " "
	      << fmt(boundary_layer->state_vector()) << "\n";
  }
}
Пример #10
0
//--------------------------------------------------------------
void ofApp::setup(){
     //set background to black
     ofBackground(0,0,0);
    
    //makes planet ( xVel, yVel, xPos, yPos,mass, radius, red, green, blue)
    Planet earth(0, 1.5, 700,400,2000, 5, 255, 0, 0);
    planets.push_back(earth);
    earth.~Planet();
    
    Planet mars( 2, 0, 500, 200, 2000, 5, 0, 255, 0);
    planets.push_back(mars);
    mars.~Planet();
    
    Planet mars2( 2, 0, 400, 100, 2000, 5, 0, 0, 255);
    planets.push_back(mars2);
    mars2.~Planet();
    
    //make sun (x, y, mass, radius, R, G, B)
    Sun sunOne(400, 400, 10000000000, 20, 255, 255, 0);
    suns.push_back(sunOne);
    sunOne.~Sun();

}
Пример #11
0
int main(int argc, const char * argv[])
{
	vector < Passenger > passengersA;
	vector < Passenger > passengersB;
	
	passengersB.push_back(Passenger("Saffron",200,50
									,Coordinate(20,15,12,"Delphi System"),"I travel very light"));
	
	passengersB.push_back(Passenger("Mrs. Reynolds",150,120
									,Coordinate(2,2,2,"Europa Colony"),"Just trying to get back my husband!"));
	
	passengersB.push_back(Passenger("Yolanda",500,100
									,Coordinate(20,15,12,"Delphi System"),"I am a courier of sensitive items"));
	
	passengersB.push_back(Passenger("Tracey Smith ",200,50
									,Coordinate(20,15,12,"Delphi System"),"Just a guy"));
	
	passengersA.push_back(Passenger("Magistrate Higgins ",600,120
									,Coordinate(2,2,2,"Europa Colony"),"I am very important person"));
	
	passengersA.push_back(Passenger("Stitch Hessian",100,100
									,Coordinate(100,72,32,"3rd moon of Persephone"),"Just get me there"));
	
	
	
	Coordinate earth(0,0,0,"Earth");
	Coordinate europa(2,2,2,"Europa Colony");
	
	vector< CargoBin > cargo;
	cargo.push_back(*new CargoBin(ACR.WARP,10));
	cargo.push_back(*new CargoBin(ACR.ISOLC,10));
	
	vector< SpaceThing > stations;
	stations.push_back( *new SpaceThing("Far Point Station",100,100,cargo,europa,passengersB) );
	stations.push_back( *new SpaceThing("Mars Research Station",100,100,cargo,europa,passengersB) );
	stations.push_back( *new SpaceThing("Earth Space Command Station",100,100,cargo,europa,passengersB) );
	
//=====================================everything above line is dummy data, replace with an object factory
	
	//SpaceFactory factory = SpaceFactory("/Users/Neil/Dropbox/webster/COSC4260/IAWSCA/SpaceFactory/");
	//vector< SpaceThing > stations(randomStations(5));
	//Dosn't work. Don't know why. Memory error in buy. Can't hunt it down. Brain is fried, out of time.
	
	Ship ship(interface,"HMS Out Of Time",1000,2000,cargo,earth,passengersA);
	
	bool close;
	
	string choices[] = {//TODO: map menu options to function pointers??
		"TRADE CARGO", //1
		"LOAD PASSENGERS", //2
		"SET COURSE", //3
		"DOCK", //4
		"MANAGE CARGO", //5
		"VIEW PASSENGERS", //6
	};
	
	interface.message("Welcome to your space ship",true);
	vector < string >  mainMenu(begin_address(choices),end_address(choices));
	
	while (!close) {
		
		ship.displayHUD();
		
		int choice = interface.showMenu("\n\nMAIN MENU", mainMenu,"Please choose an action");
		
		switch (choice){
			case 1: ship.buy();
				break;
			case 2: ship.loadPassengers();
				break;
			case 3: ship.setNewCourse();
				break;
			case 4: ship.dock(stations);
				//stations = randomStations(5);
				break;
			case 5: ship.manageInventory();
				break;
			case 6:	ship.viewPassengers();
				break;
			case 7: close = interface.prompt("Are you sure you want to quit","Yes","No");
				break;
		}
	}
	quit();
    return 0;
}
Пример #12
0
int main()
{
   double PI = 4*std::atan(1.0);
   clock_t start, finish;
   std::string dimension = "AU"; //can be 'AU' or 'ly'

//-------------------------------------------------------------
   /* problem a)
    * additional functionality as parallelisation
    * and adaptive timesteps in other classes was commented out
    * while generating plots and time for this part*/
//-------------------------------------------------------------
   //initialize sun
   std::string nameSun = "sun";
   arma::Col<double> positionSun(3), velocitySun(3);
   double massSun = 1.0; //SolarMass
   positionSun.zeros();
   velocitySun.zeros();

   //initialize earth
   std::string nameEarth = "earth";
   arma::Col<double> positionEarth(3), velocityEarth(3);
   double massEarth = 3e-6; //solarmass
   positionEarth.zeros();
   velocityEarth.zeros();

   //declare solar system
   System solarsystem;

   positionEarth(0) = 1.0;
   velocityEarth(1) = -2*PI;


   //Declaration of objects
   Object earth(positionEarth,velocityEarth, massEarth, nameEarth);
   Object sun(positionSun, velocitySun, massSun, nameSun);

   //add objects to system
   solarsystem.addObject(sun);
   solarsystem.addObject(earth);

   std::string nameAdd = "rk4";
   earth.newFile(nameAdd);
   sun.newFile(nameAdd);
   SolveStep solver(solarsystem);

   solver.solve(0.01,0.05,"rk4_","rk4", dimension);

   earth.closeFile(nameAdd);
   sun.closeFile(nameAdd);

//-------------------------------------------------------------
   /* problem b)
    * additional functionality in other classes was commented out
    * while generating plots for this part*/
//-------------------------------------------------------------

   //reset sun
   positionSun.zeros();
   velocitySun.zeros();
   earth.setPosition(positionSun);
   earth.setVelocity(velocitySun);

   //reset earth
   positionEarth.zeros();
   velocityEarth.zeros();
   positionEarth(0) = 1.0;
   velocityEarth(1) = -2*PI;
   earth.setPosition(positionEarth);
   earth.setVelocity(velocityEarth);

   //initialize moon
   std::string nameMoon = "moon";
   arma::Col<double> positionMoon(3), velocityMoon(3);
   double massMoon = 3e-6*0.0123; //solarmass
   positionMoon.zeros();
   velocityMoon.zeros();

//   positionMoon(0) = 1.0;
//   positionMoon(1) = -0.00257;
//   velocityMoon(1) = -2*PI;
//   velocityMoon(0) = 0.1668*PI;
   positionMoon(0) = 1.0;
   positionMoon(1) = -2e-3;
   velocityMoon(1) = -2*PI;
   velocityMoon(2) = 0.21544;
   Object moon(positionMoon, velocityMoon, massMoon, nameMoon);

   //declare solar system
   System solarsystemAdapt;

   //add objects to system
   solarsystemAdapt.addObject(sun);
   solarsystemAdapt.addObject(earth);
   solarsystemAdapt.addObject(moon);

   std::string nameAdd = "verletAdapt_";
   earth.newFile(nameAdd);
   sun.newFile(nameAdd);
   moon.newFile(nameAdd);
   SolveStep solverAdapt(solarsystemAdapt);

   double timestep = 1.0;

   start = clock(); //start timer
   solverAdapt.solve(timestep,4.0,nameAdd,"verlet", dimension);
   finish = clock(); //stop timer
   std::cout << "Simulation time: " <<
                static_cast<double>(finish - start)/
                static_cast<double>(CLOCKS_PER_SEC ) << " s" << std::endl;

   earth.closeFile(nameAdd);
   sun.closeFile(nameAdd);
   moon.closeFile(nameAdd);

   //-------------------------------------------------------------
      /* problem c)-->
       * creation of a simple model of an open cluster. The lines
       * in Solvestep that saves every position for every particle
       * is commented out during these calculations. */
   //-------------------------------------------------------------
   dimension = "ly";
   RandomGenerator generate;
   double R0 = 20;
   double epsilon = 1.5*7.3e-11;//7.3e-8;
   int N = 500;
   System mysystem = generate.randomSystem(N, R0);
   mysystem.setEpsilon(epsilon);
   SolveStep solver(mysystem);
   double timestep = 0.1;
   double simulationTime = 10.0;
   std::string fileName = "solve_";
   std::string method = "rk4";


   solver.solve(timestep, simulationTime, fileName, method, dimension);

   std::ofstream fout("start.m");
   fout << "A = [";
   double mass = 0.0;
   for (int i = 0 ; i < mysystem.numberOfObject ; ++i)
   {
      Object &mainbody = mysystem.objectlist[i];

      fout << mainbody.getPosition()(0) << "\t\t" << mainbody.getPosition()(1)
           << "\t\t" << mainbody.getPosition()(2) << "\n";
      mass += mainbody.getMass();
   }
   fout << "] \n";
   fout << "plot3(A(:,1), A(:,2),A(:,3), 'o')";
   fout.close();
   std::cout <<"average mass:"<< mass/static_cast<double>(N) << std::endl;
}
Пример #13
0
int main(int argc, const char * argv[]) {
    // rejestracja obywateli na poszczególnych planetach
    auto& captain = earth().registerCitizen("Jean-Luc Picard");
    auto& officer = qonos().registerCitizen("Worf");
    auto& b0 = bynaus().registerCitizen("00000000");
    auto& b1 = bynaus().registerCitizen("11111111");
    auto& binarius = bynaus().registerCitizen(b0, b1);

    // możemy odszukać obywatela, o ile znamy jego identyfikator...
    auto& found = earth().findCitizen(captain.id());
    try {
        auto& spock = earth().findCitizen("SPOCK-ID");
    } catch (...) {
        // ...jeśli nie istnieje, to zgłaszany jest wyjątek
        ::std::cout << "Spock not found" << ::std::endl;
    }

    /*
    // nowe banki otwieramy poprzez wniosek do Gwiezdnej Komisji Bankowej
    // hint: wzorzec Builder oraz fluent interface
    // opłaty zawsze w ENC
    auto& enterpriseBank = gkb().bankApplication()
        .name("Enterprise Bank")
        .checkingAccount()
        .savingAccount().monthlyCharge(2.00).transferCharge(1.00).interestRate(5)
        .currencyAccount().transferCharge(2.00).interestRate(1.5)
        .createBank();
    // domyślnie brak opłat oraz 0 oprocentowanie
    auto& raisaBank = gkb().bankApplication()
        .name("Raisa Bank")
        .createBank();

    // możemy otwierać różne rodzaje kont dla obywateli Zjednoczonej Federacji Planet
    auto& picardsChecking = enterpriseBank.openCheckingAccount(captain);
    auto& picardsSaving = enterpriseBank.openSavingAccount(captain);
    auto& binariusCurrency = raisaBank.openCurrencyAccount(binarius, Currency::DIL);

    // operacje na koncie rozliczeniowym
    picardsChecking.deposit(101.5);
    picardsChecking.withdraw({1.5, Currency::ENC});
    picardsChecking.transfer(100, picardsSaving.id());

    // operacje na koncie oszczędnościowym
    picardsSaving.transfer(49.99, binariusCurrency.id(), "for binarius");

    // przesuwamy kalendarz
    // odsetki są kapitalizowane miesięcznie pierwszego dnia miesiąca o g. 0
    // opłaty miesięczne za prowadzenie konta są pobierane pierwszego dnia miesiąca o g. 0
    interstellarClock().nextMonth().nextDay();

    // operacje na koncie walutowym
    // domyślnie kurs jest 1 do 1
    binariusCurrency.withdraw(1);
    binariusCurrency.withdraw({1, Currency::ENC});

    // zmiana kursu waluty i wypłata
    raisaBank.exchangeTable()
        .exchangeRate(Currency::DIL).buyingRate(2.0).sellingRate(3.0);
    binariusCurrency.withdraw({1, Currency::ENC});
    binariusCurrency.withdraw({1.0, Currency::DIL});

    // stan konta rozliczeniowego Picarda
    ::std::cout << picardsChecking.balance() << ::std::endl;
    ::std::cout << picardsChecking.history() << ::std::endl;

    // stan konta oszczędnościowego Picarda
    ::std::cout << picardsSaving << ::std::endl;

    // stan konta walutowego Binariusa
    ::std::cout << binariusCurrency << ::std::endl;

    // próba przelewu na nieistniejące konto...
    try {
        binariusCurrency.transfer(1, "Far Far In a Galaxy");
    } catch (...) {
        // ...powinna zakończyć się wyjątkiem
        ::std::cout << "Account not found" << ::std::endl;
    }
    */
    return 0;
}
Пример #14
0
int main(){

	//Body Init=================+

	//Earth =========NAME==MASS===POS====VEL======+
	Body<double> earth("Earth", 5.97e24, {10, 10, 0}, {0, 0, 0});
	bodies.push_back(earth);

	//Satellite =======NAME=MASS===POS======VEL=======+ 7545.687
	Body<double> sat("Benley", 5000, {7e6, 0, 0}, {0, 7545.687, 0});
	bodies.push_back(sat);

	//End Body Init=============+
	
	
	
	std::vector<std::vector<double>> forcesBro = netForce();
	
	for(int i = 0; i < forcesBro.size(); ++i){
		for(int j = 0; j < 3; ++j){
			std::cout << forcesBro[i][j] << " ";
		}
		std::cout << '\n';
	}
	
	

	//Time init
	double t = 0.0, dt = 0.2, ElapT=0.0;

	std::cout << "bodies.size(): " << bodies.size() << std::endl;

	//File output
	std::ofstream fout("SystemStates.txt");

	//Integration Loop
	std::vector<double> posNewTemp = {0, 0, 0};
	std::vector<double> velNewTemp = {0, 0, 0};
	std::vector<double> posTemp = {0, 0, 0};
	std::vector<double> velTemp = {0, 0, 0};
	//double massTemp = 0;

	for(double i=0; i<100000; ++i){ // Full propagated iteration
		//Running only with sat
		for(size_t j=0;j<bodies.size();++j){ // Per-body propagation
			// Reassign Temps
			posTemp = bodies[j].getPos();
			velTemp = bodies[j].getVel();
			//massTemp = bodies[j].getMass();
			// Integrate
			prop(posTemp, velTemp, dt, (j-1)%2);
			// setPos and setVel Update
			bodies[j].setPosNew(posTemp);
			bodies[j].setVelNew(velTemp);
		}
		// Update time
		ElapT += dt;
		t += dt;

		// Update positions
		updateStates();

		// File output
		fout << bodies[1].getPos()[0] << '\t' << bodies[1].getPos()[1] << '\t' << bodies[1].getPos()[2] << '\t'
			<< bodies[0].getPos()[0] << '\t' << bodies[0].getPos()[1] << '\t' << bodies[0].getPos()[2] << '\t'
			<< bodies[1].getVel()[0] << '\t' << bodies[1].getVel()[1] << '\t' << bodies[1].getVel()[2] << '\t'
			<< ElapT << '\n';
	}

        return 0;

}
// main func is temporary ugly
int main(int argc, char ** argv)
{
	srand(time(NULL));

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE | GLUT_ACCUM);
	glutInitWindowPosition(glutGet(GLUT_SCREEN_WIDTH) / 14, glutGet(GLUT_SCREEN_HEIGHT) / 21);
	glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH) * 6 / 7, glutGet(GLUT_SCREEN_HEIGHT) * 6/7);
	int window = glutCreateWindow("Star System");
	//glutFullScreen();

	glEnable(GL_ACCUM);
	glEnable(GL_DEPTH_TEST);
	//glEnable(GL_LINE_SMOOTH);
	//glEnable(GL_CULL_FACE);
	glEnable(GL_LIGHTING);

	//glCullFace(GL_BACK);
	
	//glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

	glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
	TwInit(TW_OPENGL, NULL);

	glutDisplayFunc(GlutCB::Display);
	glutReshapeFunc(GlutCB::Reshape);
	
	glutMouseFunc(GlutCB::Mouse);
	glutMotionFunc(GlutCB::Motion);
	glutPassiveMotionFunc(GlutCB::PassiveMotion);
	glutKeyboardFunc(GlutCB::Keyboard);
	glutKeyboardUpFunc(GlutCB::KeyboardUp);
	glutSpecialFunc(GlutCB::Special);
	glutSpecialUpFunc(GlutCB::SpecialUp);

	TwGLUTModifiersFunc(glutGetModifiers);

	glutTimerFunc(Constants::deltaTime, GlutCB::Timer, 1);

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

	Star sun("Sun", 2.0e30, 1.4e9, Vector3f(1.0f, 1.0f, 0.0f), Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 0.0, 0.0));

	Planet mercury("Mercury", 3.3e23, 5.0e6, Vector3f(0.8f, 0.0f, 0.0f), Vector3d(4.6e10, 0.0, 0.0), Vector3d(0.0, 4.7e4, 0.0));

	Planet venus("Venus", 4.8e24, 1.2e7, Vector3f(0.8f, 0.6f, 0.7f), Vector3d(1.0e11, 0.0, 0.0), Vector3d(0.0, 3.5e4, 0.0));

	Planet earth("Earth", 6.0e24, 1.2e7, Vector3f(0.0f, 0.0f, 1.0f), Vector3d(1.5e11, 0.0, 0.0), Vector3d(0.0, 3.0e4, 0.0));
	Sputnik moon("Moon", 7.35e22, 3.4e6, Vector3f(0.7f, 0.7f, 0.7f), &earth, Vector3d(4.0e8, 0.0, 0.0), Vector3d(0.0, 1.0e3, 0.0));

	Planet mars("Mars", 6.4e23, 6.7e6, Vector3f(1.0f, 0.0f, 0.0f), Vector3d(2.0e11, 0.0, 0.0), Vector3d(0.0, 2.4e4, 0.0));

	Teapot rasselsTeapot("RasselsTeapot", 0.0, 0.3, Vector3f(1.0f, 1.0f, 1.0f), Vector3d(3.0e11, 0.0, 0.0), Vector3d(0.0, 2.0e4, 0.0));

	Planet jupiter("Jupiter", 1.9e27, 1.3e8, Vector3f(1.0f, 0.8f, 0.0f), Vector3d(7.4e11, 0.0, 0.0), Vector3d(0.0, 1.3e4, 0.0));

	RenderManager * renderManager = RenderManager::getInstance();
	renderManager->initAll();

	Camera * camera = new Camera();
	
	ControlPane * ctrlPane = ControlPane::getInstance(camera, renderManager);
	ctrlPane->show();

	TwCopyStdStringToClientFunc(CopyStdStringToClient);

	ctrlPane->addSpaceObject(&sun);
	renderManager->renderSpaceObject(&sun);

	ctrlPane->addSpaceObject(&mercury);
	renderManager->renderSpaceObject(&mercury);

	ctrlPane->addSpaceObject(&venus);
	renderManager->renderSpaceObject(&venus);

	ctrlPane->addSpaceObject(&earth);
	renderManager->renderSpaceObject(&earth);

	ctrlPane->addSpaceObject(&moon);
	renderManager->renderSpaceObject(&moon);

	ctrlPane->addSpaceObject(&mars);
	renderManager->renderSpaceObject(&mars);

	ctrlPane->addSpaceObject(&rasselsTeapot);
	renderManager->renderSpaceObject(&rasselsTeapot);

	ctrlPane->addSpaceObject(&jupiter);
	renderManager->renderSpaceObject(&jupiter);

	GlutCBInitializer::init(camera, renderManager);

	glutMainLoop();
	
	delete ctrlPane;
	glutDestroyWindow(window);
	return EXIT_SUCCESS;
}
int window_maker(const sf::Vector2f& windims, const std::string& program_name)
{
	const float millis{5.0f/1000.0f};
	
	const sf::Color black{sf::Color(0, 0, 0)};
	const sf::Color light_red{sf::Color(191, 63, 63)};
	const sf::Color light_green{sf::Color(63, 191, 63)};	const sf::Color light_blue{sf::Color(63, 63, 191)};
	
	const float divis{10.0f};
	
	square lefter(windims, wing::left, light_red);
	square righter(windims, wing::right, light_blue);
	
	std::vector <shot> shots;
	
	ground earth(windims, divis, light_green);
	
	sf::RenderWindow window(sf::VideoMode(windims.x, windims.y), program_name, sf::Style::Default);
	
	sf::Clock clock;
	
	sf::Time time;
		
	while (window.isOpen())
	{
		clock.restart();
		
		sf::Event event;
		
		window.clear(black);
		
		earth.displaying(window);
		lefter.displaying(window);
		righter.displaying(window);
		
		time = clock.getElapsedTime();
		
		while(time.asSeconds() < millis)
		{
			time = clock.getElapsedTime();
		}
		
		window.display();
		
		lefter.acting(earth, righter);
		righter.acting(earth, lefter);
		
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
		{
			window.close();
			return 0;
		}
		
		while (window.pollEvent(event))
		{			
			if (event.type == sf::Event::Closed)
			{
				window.close();
				return 0;
			}		
		}		
	}
	
	return 1;	
}