Beispiel #1
0
int planet_plot(struct zint_symbol *symbol, unsigned char source[], int length)
{
	/* Puts PLANET barcodes into the pattern matrix */
	char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 +  1 ~ 256 */
	unsigned int loopey, h;
	int writer;
	int error_number;

	error_number = 0;

	error_number = planet(symbol, source, height_pattern, length);
	if(error_number != 0) {
		return error_number;
	}

	writer = 0;
	h = strlen(height_pattern);
	for(loopey = 0; loopey < h; loopey++)
	{
		if(height_pattern[loopey] == 'L')
		{
			set_module(symbol, 0, writer);
		}
		set_module(symbol, 1, writer);
		writer += 3;
	}
	symbol->row_height[0] = 6;
	symbol->row_height[1] = 6;
	symbol->rows = 2;
	symbol->width = writer - 1;
	return error_number;
}
Beispiel #2
0
bool NounStructure::build()
{
	if (! isBuilding() )
		return true;

	m_nBuildTime += 1;
	if (! isBuilding() )
	{
		// construction complete!
		if ( isServer() && planet() != NULL )
			factionChat( CharString().format( "<color;ffffff>Comms: %s %s constructed", planet()->name(), name() ) );

		return true;
	}
	return false;
}
Beispiel #3
0
bool NounStructure::updatePosition()
{
	NounPlanet * pPlanet = planet();
	if (! pPlanet  )
	{
		// structure is not on planet... how odd!
		setPosition( Vector3(0,0,0) );
		return true;
	}

	if (! pPlanet->pathMap() )
		return false;		// hex map isn't initialized yet... 

	if (! pPlanet->isHexValid( m_nHex ) )
		m_nHex = pPlanet->findHex( position(), true );
	if (! pPlanet->isHexValid( m_nHex ) )
		return false;		// don't crash at the very least!
	setPosition( pPlanet->hex( m_nHex ).position );

	Matrix33 frame( Vector3(1,0,0), position(), Vector3(0,0,1 ) );
	frame.orthoNormalizeXZ();

	setFrame( frame );

	return true;
}
Beispiel #4
0
//--------------------------------------------------------------------  
// Gibt 1 für einen in eins, sieben oder zehn befindlichen Planeten
// Gibt 0 in allen anderen Fällen  
//--------------------------------------------------------------------  
int pl_1_7_10( int ipl, double house_cusps[], double jd) {
  double pl = planet( ipl, jd );
  int hpos = house_pos( pl, house_cusps);
  return (hpos ==  1) ||
         (hpos ==  7) ||
         (hpos == 10) ;
  }   
Beispiel #5
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();
}
Beispiel #6
0
void NounStructure::destroy( Noun * pKiller )
{
	// add explosion object for client only
	if ( context()->isClient() )
	{
		Scene * pDestroy = WidgetCast<Scene>( nounContext()->resource( "DESTROY" ) );
		if ( pDestroy != NULL )
		{
			// structure destroyed, create the explosion effect
			SceneryEffect * pEffect = new SceneryEffect;
			pEffect->setNounContext( new NounContext( pDestroy ) );
			pEffect->setContext( context() );
			pEffect->setFrame( frame() );
			pEffect->setPosition( position() );
			pEffect->setDelay( 0.0f );

			if (! pEffect->setSegment( "Effect" ) )
				pEffect->setLife( 15.0f );

			context()->attachNoun( pEffect, parent() );
		}
	}

	// add some resources back into the planet
	NounPlanet * pPlanet = planet();
	if( pPlanet )
        pPlanet->addResources( buildCost() / 10 );

	// lastly, detach this object from the world
	setDetach();
}
Beispiel #7
0
	triple Force::planet(int IDP) 
	{

		double mu = ID2GM(IDP);
		return planet(IDP, mu);

	}
Beispiel #8
0
float NounStructure::getTechPercentage() const
{
	NounPlanet * pPlanet = planet();
	if( !pPlanet )
		return 0.0f;
	if( pPlanet->technology() >= this->technology() || this->technology() == 0  )
		return 1.0f;
	return (float)pPlanet->technology() / (float)this->technology();
}
Beispiel #9
0
BString ObjectController::handleBroadcastPlanet(BString message) const
{
    // Get planet name
    int8 rawData[128];
    rawData[0] = 0;

    int32 elementCount = sscanf(message.getAnsi(), "%80s", rawData);
    BString planet(rawData);
    if (elementCount > 0)
    {
        // Yes. Validate the planet name.
        int32 planetId = gWorldManager->getPlanetIdByNameLike(planet);
        if (planetId >= 0)
        {
            // We have no idea of how much white space are inserted in string...
            int32 index = indexOfNextField(message);
            if (index > 0)
            {
                // Now we can get the broadcaste from the message.
                // Remove planet name from message.
                BString ansiData;
                ansiData.setLength(message.getLength());
                message.substring(ansiData, static_cast<uint16>(index), message.getLength());

                // Any valid message?
                elementCount = sscanf(ansiData.getAnsi(), "%80s", rawData);
                if (elementCount > 0)
                {
                    // string planetName(gWorldManager->getPlanetNameById(planetId));

                    this->broadcastGalaxyMessage(ansiData, planetId);
                    sprintf(rawData,"OK");
                }
                else
                {
                    sprintf(rawData,"No broadcast supplied");
                }
            }
            else
            {
                sprintf(rawData,"No valid broadcast supplied");
            }
        }
        else
        {
            sprintf(rawData,"%s is not valid planet name", planet.getAnsi());
        }
    }
    else
    {
        sprintf(rawData,"Missing planet name");
    }
    return rawData;
}
Beispiel #10
0
void moon() 
{
	glPushMatrix();
	//glRotatef(-45.0, 0.0, 0.0, 1.0);
	glRotatef(2*time, 0.0, 0.0, 1.0);
	glTranslatef(0.6, 0.0, 0.0); // temporäre werte
	glColor3f(0.5, 0.5, 0.5);
	planet(0.1);
	glPopMatrix();
	
	orbit(0.6, 0.0, 0.0);
}
Beispiel #11
0
void mars() 
{
	glPushMatrix();
	//glRotatef(-30.0, 0.0, 0.0, 1.0);
	glRotatef(0.5*time, 0.0, 0.0, 1.0);
	glTranslatef(3.0, 0.0, 0.0); // temporäre werte
	glColor3f(1.0, 0.0, 0.0);
	planet(0.2);
	glPopMatrix();

	orbit(3.0, 0.0, 0.0);
}
Beispiel #12
0
void World::spawnEnemies()
{
	while (!mPlanetSpawnPoints.empty()
		&& mPlanetSpawnPoints.back().y > getBattlefieldBounds().top + 300)
	{
		SpawnPoint spawn = mPlanetSpawnPoints.back();

		std::unique_ptr<Planet> planet(new Planet(spawn.type, mTextures));
		planet->setPosition(spawn.x, spawn.y);
		mSceneLayers[Space]->attachChild(std::move(planet));
		mPlanetSpawnPoints.pop_back();
	}
}
Beispiel #13
0
void eating(planet &first_one, planet &sec_one)
{     
    if((first_one.Radius+sec_one.Radius)>=first_one.distance(sec_one))
        if(sec_one.Radius>=first_one.Radius){
             //momentum function (   MV (totol) = M1v + M2v   _)
            sec_one.velocity_x=(first_one.velocity_x* pow(first_one.Radius,3)+sec_one.velocity_x*pow(sec_one.Radius,3))/(pow(sec_one.Radius,3));
            sec_one.velocity_y=(first_one.velocity_y* pow(first_one.Radius,3)+sec_one.velocity_y*pow(sec_one.Radius,3))/(pow(sec_one.Radius,3));

            sec_one.Radius+=first_one.Radius/4;   // increase 1/4 radiius from smaller one

            first_one=planet(-1,-1,0,0,0,0);  //mark radius equal to 0 , then we delete it in big_bang
        }
        else{
            //momentum function (   MV (totol) = M1v + M2v   _)
            first_one.velocity_x=(sec_one.velocity_x* pow(sec_one.Radius,3)+first_one.velocity_x*pow(first_one.Radius,3))/(pow(first_one.Radius,3));
            first_one.velocity_y=(sec_one.velocity_y* pow(sec_one.Radius,3)+first_one.velocity_y*pow(first_one.Radius,3))/(pow(first_one.Radius,3));

            first_one.Radius+=sec_one.Radius/4;  // increase 1/4 radiius from smaller one

            sec_one=planet(-1,-1,0,0,0,0);     //mark radius equal to 0 , then we delete it in big_bang
        }

}
Beispiel #14
0
void earth() 
{
	glPushMatrix();
	//glRotatef(45.0, 0.0, 0.0, 1.0);
	glRotatef(time, 0.0, 0.0, 1.0);
	glTranslatef(1.8, 0.0, 0.0); // temporäre werte
	glColor3f(0.0, 0.0, 1.0);
	planet(0.3);

	moon();
		
	glPopMatrix();

	orbit(1.8, 0.0, 0.0);		
}
Beispiel #15
0
	//
	//the perturbation by additional body #5(central and none-central gravity)
	triple Force:: acc5th_body()
	{
		triple acc_;
		if (Global::b_add5_cun_on)
		{
			//centric part of  acceleration 
			triple acc_point = planet(Global::ID5, Global::GravField_add5.getGM());

			double pos[3], lt;
			spkgps_c(Global::IDC, time, "J2000", Global::ID5, pos, &lt);
			triple pos_CB(pos);
			triple Xbs = pos_CB + X;
			// non-centric part of  acceleration by #5
			triple fs = Global::GravField_add5.getAcceleration(Global::ID5, time, Xbs);
			triple fcb = Global::GravField_add5.getAcceleration(Global::ID5, time, pos_CB);

			acc_ = acc_point + (fs - fcb);
		}
		else
		{
			acc_ = planet(Global::ID5);
		}
		return acc_;
	}
void planet_description(struct mtwist_state *mt, char *buffer, int buflen, int line_len)
{
	char do_avoid[100];

	strcpy(do_avoid, avoid(mt));
	do_avoid[0] = toupper(do_avoid[0]);

	snprintf(buffer, buflen, "This %s %s %s %s %s %s %s and %s %s %s %s. %s the %s %s.  %s %s.\n",
		climate(mt), planet(mt), known_for(mt), producing(mt),
			exceptional(mt), qnationality(mt), product(mt),
			known_for(mt), exceptional(mt), qnationality(mt),
			culture(mt),
			do_avoid, terrible(mt), product(mt),
			bring_your(mt), traveling_accessory(mt));
	break_lines(buffer, line_len);
}
Beispiel #17
0
/**
 * This will look through the parser results and match moons to their corresponding
 * planet.
 */
void SolarSystem::assignMoons(){
	string planet;
	map<string, Planet>::iterator found;

	for(SpaceObject moon : spaceObjects){
			if(moon.type().find(MOONTEXT) != string::npos){ // Found type that contains moon specifier
				planet(moon.type().substr(0, moon.type().size()-MOONTEXT.size())); //Taking the planet name it belongs to
				found = planets.find(planet);
				if(found == planets.end())
					cout << "not found";
				else
					found->second.addMoon(moon); // Adding moon to planet
			}


		}
}
Beispiel #18
0
void NounStructure::scrap()
{
	// return resources back to the planet when scrapped
	NounPlanet * pPlanet = planet();
	if ( pPlanet != NULL )
	{
		// return half of used resources
		int nRestore = buildCost() / 2;
		// reduce restored resources by damage
		nRestore -= (nRestore * damage()) / maxDamage();
		// restore resources to planet
		pPlanet->addResources( nRestore );
	}

	m_nBuildTime = 0;
	// detach this object from the planet
	setDetach();
}
Beispiel #19
0
//--------------------------------------------------------------------  
// Matrix der Planetenhäufigkeiten in den Feldern ausgeben
// Für Häusersysteme V(ehlow), P(lacidus), K(och).
//--------------------------------------------------------------------  
void print_matrix( struct _hordat hordat[], int size) {
  int hs,i,ipl,j;
  int hz[3][10][13], hsys[3]={'V','P','K'};
  double ascmc[10],house_cusps[13];
  int iScore; 
  
// Initialisieren  
  for (hs=0;hs<3;hs++)
    for (i=0;i<10;i++) 
      for (j=1;j<13;j++) 
        hz[hs][i][j] = 0;
  
// Stände zählen  
  for (hs=0;hs<3;hs++) 
    for (i=0;i<size;i++) 
      for (ipl=0;ipl<10;ipl++) {   
// Häuser nach Methode hsys[hs] berechnen
        swe_houses( hordat[i].jd_ut, 
                    hordat[i].lat, 
                    hordat[i].lon, 
                    hsys[hs], 
                    house_cusps, 
                    ascmc );
// Hausziffer inkrementieren                    
        hz[hs]
          [ipl]
          [house_pos(planet(ipl,hordat[i].jd),house_cusps)]++;
         
       }    
         

// Statistik ausgeben
  for (hs=0;hs<3;hs++) {
    printf("Häusersystem %c\n",hsys[hs]);  
    for (ipl=0;ipl<10;ipl++) {
      for (j=1; j<=12; j++) {  
        printf("%d\t",hz[hs][ipl][j]);  
        }
      printf("\n");
      }
    printf("\n");
    }

  }     
Beispiel #20
0
/**
 * This will look through the parser results and match moons to their corresponding
 * planet. It will also add the planets to the planet vector with the updated moon info.
 */
void SolarSystem::assignMoons(){
	string planet("");
	map<string, Planet>::iterator found;

	for(std::vector<SpaceObject>::iterator moon = moons.begin(); moon != moons.end(); ++moon){
		planet.append(moon->_planetName.substr(0, moon->_planetName.size()- MOON_GAP));
		found = planets.find(planet);
		if(found == planets.end()){
			cerr << "not found: " << planet << endl;
		}
		else
			found->second.addMoon(*moon); // Adding moon to planet
	}

	planetVector.clear();
	for(std::map<string, Planet>::iterator planet = planets.begin(); planet != planets.end(); ++planet){
		planetVector.push_back(planet->second);

	}
}
void C4Reloc::Init()
{
	Paths.clear();

	// The system folder (i.e. installation path) has higher priority than the user path
	// Although this is counter-intuitive (the user may want to overload system files in the user path),
	// people had trouble when they downloaded e.g. an Objects.ocd file in a network lobby and that copy permanently
	// ruined their OpenClonk installation with no obvious way to fix it.
	// Not even reinstalling would fix the problem because reinstallation does not overwrite user data.
	// We currently don't have any valid case where overloading system files would make sense so just give higher priority to the system path for now.
#ifndef __APPLE__
	// Add planet subfolder with highest priority because it's used when starting directly from the repository with binaries in the root folder
	StdCopyStrBuf planet(Config.General.ExePath);
	planet.AppendBackslash();
	planet.Append("planet");
	AddPath(planet.getData());
#endif
	// Add main system path
	AddPath(Config.General.SystemDataPath);
	// Add user path for additional data (player files, user scenarios, etc.)
	AddPath(Config.General.UserDataPath, PATH_PreferredInstallationLocation);
}
void GUITests::buildScene_( const std::vector< PhysicalData::PlanetData >& planetData )
{
  // Add one empty SceneNode for each scene layer
  for( size_t i = 0; i < LayerCount; ++i )
  {
    SceneNode::Ptr layer( new SceneNode() );
    sceneLayers_[i] = layer.get();
    sceneGraph_.attachChild( std::move( layer ) );
  }

  physicalObjects_.clear();
  for( size_t i = 0; i < planetData.size(); ++i )
  {
    const PhysicalData::PlanetData& data = planetData[i];
    unique_ptr< Planet > planet( new Planet( data.name, data.mass, data.radius, 0 /*TODO, borde inte behöva sätta detta*/, textureHolder_, csHandler_ ) );
    planet->setPosition( data.position );
    planet->setVelocity( data.velocity );

    physicalObjects_.push_back( planet.get() );

    sceneLayers_[ActionLayer]->attachChild( std::move( planet ) );
  }
}
void SystemViewState::HandleOutput()
{
		unsigned int X = (MOO::Globals::gameWidth / 2);
		unsigned int Y = (MOO::Globals::gameHeight / 2);

		sf::Text nameDisplay;

		nameDisplay.setFont( gameFont );

		switch( starSystem->starType )
		{
			case StarType::O:
			{
				images.OStarImage.setPosition( X, Y );

				engine->Draw( images.OStarImage );

				break;
			}

			case StarType::A:
			{
				images.AStarImage.setPosition( X, Y );

				engine->Draw( images.AStarImage );

				break;
			}

			case StarType::B:
			{
				images.BStarImage.setPosition( X, Y );

				engine->Draw( images.BStarImage );

				break;
			}

			case StarType::F:
			{
				images.FStarImage.setPosition( X, Y );

				engine->Draw( images.FStarImage );

				break;
			}

			case StarType::G:
			{
				images.GStarImage.setPosition( X, Y );

				engine->Draw( images.GStarImage );

				break;
			}

			case StarType::K:
			{
				images.KStarImage.setPosition( X, Y );

				engine->Draw( images.KStarImage );

				break;
			}

			case StarType::M:
			{
				images.MStarImage.setPosition( X, Y );

				engine->Draw( images.MStarImage );

				break;
			}
	}
		nameDisplay.setString( starSystem->name );
		nameDisplay.setCharacterSize(72);
		nameDisplay.setPosition( 0, 0 );

		engine->Draw(nameDisplay);

		for(unsigned int i = 0; i < starSystem->planets.size(); i++)
		{
			unsigned int orbitWidth = 40;

			unsigned int orbitDistance = (starSystem->planets[i].solarLocation + 1) * orbitWidth;
			
			int x = orbitDistance * std::cos( starSystem->planets[i].currentOrbitDegree * MOO::Globals::DegreesToRadians ) + (MOO::Globals::gameWidth / 2);
			int y = orbitDistance * std::sin( starSystem->planets[i].currentOrbitDegree * MOO::Globals::DegreesToRadians ) + (MOO::Globals::gameHeight / 2); 

			float sizeScale = 1;

			sf::CircleShape orbitCircle( orbitDistance, 120 );

			orbitCircle.setFillColor( sf::Color( 0, 0, 0, 0) );
			orbitCircle.setOutlineThickness( 2 );
			orbitCircle.setOutlineColor( sf::Color(	50, 50, 50) );
			orbitCircle.setOrigin( orbitDistance , orbitDistance );
			orbitCircle.setPosition( X, Y);

			engine->Draw( orbitCircle );

			switch( starSystem->planets[i].size )
			{
				case PlanetSize::Tiny:
					{
						sizeScale = 0.5;

						break;
					}

				case PlanetSize::Small:
					{
						sizeScale = 0.75;

						break;
					}

				case PlanetSize::Large:
					{
						sizeScale = 1.25;

						break;
					}

				case PlanetSize::Huge:
					{
						sizeScale = 1.5;

						break;
					}
			}

			switch( starSystem->planets[i].climate )
			{
				case ClimateType::Arid:
					{
						sf::Sprite planet(images.aridPlanetImage);

						planet.setScale( sizeScale, sizeScale );
						
						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Barren:
					{
						sf::Sprite planet(images.barrenPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Desert:
					{
						sf::Sprite planet(images.desertPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Ocean:
					{
						sf::Sprite planet(images.oceanPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Paradise:
					{
						sf::Sprite planet(images.paradisePlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Radiated:
					{
						sf::Sprite planet(images.radiatedPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Swamp:
					{
						sf::Sprite planet(images.swampPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Terran:
					{
						sf::Sprite planet(images.terranPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Toxic:
					{
						sf::Sprite planet(images.toxicPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}

				case ClimateType::Tundra:
					{
						sf::Sprite planet(images.tundraPlanetImage);

						planet.setScale( sizeScale, sizeScale );

						planet.setPosition( x, y );

						engine->Draw( planet );

						break;
					}
			}

		}

		if( displayPlanetData )
		{
			unsigned int orbitWidth = 40;

			unsigned int orbitDistance = (starSystem->planets[planetDataToDisplay].solarLocation + 1) * orbitWidth;
			
			int x = orbitDistance * std::cos( starSystem->planets[planetDataToDisplay].currentOrbitDegree * MOO::Globals::DegreesToRadians ) + (MOO::Globals::gameWidth / 2);
			int y = orbitDistance * std::sin( starSystem->planets[planetDataToDisplay].currentOrbitDegree * MOO::Globals::DegreesToRadians ) + (MOO::Globals::gameHeight / 2); 
			
			y += 30;

			sf::Text displaytext;

			displaytext.setFont( gameFont );
			displaytext.setPosition( x, y );
			
			/*if( starSystem->planets[planetDataToDisplay].colonyData == NULL )
			{
				displaytext.setString( starSystem->planets[planetDataToDisplay].name );
			}

			else
			{
				displaytext.setString( starSystem->planets[planetDataToDisplay].colonyData->name );
			}*/
							
			engine->Draw( displaytext );

			displaytext.setString( starSystem->planets[planetDataToDisplay].GetSizeString() );
			displaytext.setPosition( x, displaytext.getPosition().y + displaytext.getGlobalBounds().height );

			engine->Draw( displaytext );

			displaytext.setString( starSystem->planets[planetDataToDisplay].GetClimateString() );
			displaytext.setPosition( x, displaytext.getPosition().y + displaytext.getGlobalBounds().height );

			engine->Draw( displaytext );
			
			displaytext.setString( starSystem->planets[planetDataToDisplay].GetMineralString() );
			displaytext.setPosition( x, displaytext.getPosition().y + displaytext.getGlobalBounds().height );

			engine->Draw( displaytext );

			/*if( starSystem->planets[planetDataToDisplay].colonyData != NULL )
			{
				unsigned long int populationAmount = 0;

				for(unsigned int i = 0; i < starSystem->planets[planetDataToDisplay].colonyData->population.size(); i++)
				{
					populationAmount += starSystem->planets[planetDataToDisplay].colonyData->population[i].population;
				}

				std::stringstream populationText;

				populationText << populationAmount;

				displaytext.setString( populationText.str() );
				displaytext.move( 0, displaytext.getGlobalBounds().height );

				engine->Draw( displaytext );
			}*/
		}
}
Beispiel #24
0
void doit()
{
	//Image img(600, 400);
	Image img(1280, 960);

	img.addRef();

	//Set up the scene
	GeometryGroup scene(ACC_STRUCT);

	LWObject cow;
	//cow.read("models/cow.obj", true);
	cow.read("models/untitled.obj", true);
	//cow.read("models/house_obj.obj", true);
	//cow.read("models/3spheretest.obj", true);
	//cow.read("models/TheDragon.obj", true);
	cow.addReferencesToScene(scene.primitives);
/*
    ((TexturedPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->diffTexture->filterMode = Texture::TFM_Bilinear;
 	((TexturedPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->ambientTexture->filterMode = Texture::TFM_Bilinear;
 	((TexturedBumpPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->bumpTexture->filterMode = Texture::TFM_Bilinear;
*/
/*
    SmartPtr<Image> imag;
    imag->readPNG("models/tiles.png");

    SmartPtr<Texture> tiles;
    tiles->image = imag;

    ((TexturedBumpPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->diffTexture = tiles;
*/
    MirrorPhongShader sh77;
    sh77.diffuseCoef = float4(220.f/255, 193.f/255, 42.f/255, 0);
    sh77.ambientCoef = sh77.diffuseCoef;
    sh77.specularCoef = float4::rep(0.0f);
    sh77.specularExponent = 10000.f;
    sh77.reflCoef = 0.6f;
    sh77.addRef();

    CheckBoard3DShader check;
	check.scale = float4::rep(1);
	check.addRef();

    float4 woodenBrownDark = float4(103.f/255,53.f/255,3.f/255,0);
    float4 woodenBrownLight = float4(167.f/255,86.f/255,7.f/255,0);

    float4 kBraun = float4(181.f/255,58.f/255,4.f/255,0);
    float4 dBraun = float4(119.f/255,15.f/255,0.f/255,0);

    float4 marmorDunkel = float4(0.6,0.6,0.6,0);
    float4 marmorHell = float4(0.4,0.4,0.4,0);

    SmartPtr<ProceduralTexture> woodTex = new ProceduralWoodTexture(woodenBrownDark, woodenBrownLight, 0.1f, 0.8f);
    SmartPtr<ProceduralTexture> marbleTex = new ProceduralMarbleTexture(kBraun,dBraun, 0.8f, 0.8f);
    SmartPtr<ProceduralTexture> planetTex = new ProceduralPlanetTexture();
    SmartPtr<ProceduralTexture> waterTex = new ProceduralWaterTexture(0.5f, 0.9f);
    SmartPtr<ProceduralTexture> floorMarbleTex = new ProceduralMarbleTexture(marmorHell,marmorDunkel, 0.4f, 0.3f);

	RefractivePhongShader shader;
    shader.refractionIndex = 1.6f;
    shader.diffuseCoef = float4(0.2f, 0.2f, 0, 0);
	shader.ambientCoef = shader.diffuseCoef;
	shader.specularCoef = float4::rep(0.8f);
	shader.specularExponent = 10000.f;
	shader.transparency = float4::rep(0.7f);
	shader.addRef();

    cow.materials[cow.materialMap["glass"]].shader = &shader;

	RefractivePhongShader diamondShader;
    diamondShader.refractionIndex = 2.6f;
    diamondShader.diffuseCoef = float4(0.2f, 0.2f, 0, 0);
	diamondShader.ambientCoef = diamondShader.diffuseCoef;
	diamondShader.specularCoef = float4::rep(0.8f);
	diamondShader.specularExponent = 10000.f;
	diamondShader.transparency = float4::rep(0.7f);
	diamondShader.addRef();

    cow.materials[cow.materialMap["diamant"]].shader = &diamondShader;

    ProceduralBumpShader procBumpShader(marbleTex);
    procBumpShader.diffuseCoef = float4(110.f/255,54.f/255,9.f/255,0.f);
    procBumpShader.ambientCoef = procBumpShader.diffuseCoef;
    procBumpShader.specularCoef = float4::rep(0.3f);
    procBumpShader.specularExponent = 10000.f;

    ProceduralBumpShader floor(floorMarbleTex);
    floor.diffuseCoef = float4(0.5,0.5,0.5,0);
    floor.ambientCoef = floor.diffuseCoef;
    floor.specularCoef = float4::rep(0.3f);
    floor.specularExponent = 10000.f;

    ProceduralBumpShader planet(planetTex);
    planet.diffuseCoef = float4(110.f/255,54.f/255,9.f/255,0.f);
    planet.ambientCoef = planet.diffuseCoef;
    planet.specularCoef = float4::rep(0.3f);
    planet.specularExponent = 10000.f;

    ProceduralBumpShader procBumpShader2(woodTex);
    procBumpShader2.diffuseCoef = float4(110.f/255,54.f/255,9.f/255,0.f);
    procBumpShader2.ambientCoef = procBumpShader2.diffuseCoef;
    procBumpShader2.specularCoef = float4::rep(0.3f);
    procBumpShader2.specularExponent = 10000.f;

    ProceduralRefractiveBumpShader water(waterTex);
    water.refractionIndex = 1.4f;
    water.diffuseCoef = float4(0.6,0.6,0.8,0.f);
    water.ambientCoef = water.diffuseCoef;
    water.specularCoef = float4::rep(0.3f);
	water.transparency = float4::rep(0.7f);
    water.specularExponent = 10000.f;
    water.addRef();

    cow.materials[cow.materialMap["water"]].shader = &water;
    cow.materials[cow.materialMap["dragonskin"]].shader = &procBumpShader;
    cow.materials[cow.materialMap["podest"]].shader = &procBumpShader2;
    cow.materials[cow.materialMap["Material.001_stones_diffuse.png"]].shader = &floor;

    DefaultPhongShader defaultPhong;
    defaultPhong.diffuseCoef = float4(0.3f,0.3f,0.3f, 0);
    defaultPhong.ambientCoef = defaultPhong.diffuseCoef;
    defaultPhong.specularCoef = float4::rep(0.0f);
    defaultPhong.specularExponent = 10000.f;
    defaultPhong.addRef();

    //cow.materials[cow.materialMap["Gold"]].shader = &sh77;
    //cow.materials[cow.materialMap["glass"]].shader = &procBumpShader;


	InfinitePlane p2(Point(-5.f, 0.f, 0.f), Vector(1, 0, 0), &defaultPhong);
	InfinitePlane p1(Point(0, -2.f, 0), Vector(0, 1, 0), &defaultPhong);
    //scene.primitives.push_back(&p1);
    //scene.primitives.push_back(&p2);

    // sphere test purpose
    Sphere s2(Point(0.1,    2.0f,     11), 2.0f, &planet);

    Sphere s3(Point(6.1,    1.0f,     10), 1.0f, &shader);
    Sphere s4(Point(1.1,    1.5f,     14.5f), 1.5f, &shader);

    scene.primitives.push_back(&s2);
    scene.primitives.push_back(&s3);
    scene.primitives.push_back(&s4);

    //InfinitePlane plane(Point(0,0.f,0),Vector(0,1,0), &check);

	PerspectiveCamera cam1(Point(-10.398149f, -7.266083f, 6.348377f), Point(-6.324413f, -2.961229f, 4.203216f), Vector(0, 0, 1), 30,
		std::make_pair(img.width(), img.height()));
    //cam1.addRef();

    //PerspectiveLensCamera cam3(Point(-10.398149f, -7.266083f, 6.348377f), Point(-6.324413f, -2.961229f, 4.203216f), Vector(0, 0, 1), 30,
	//	std::make_pair(img.width(), img.height()),0.9f,0.0f,1.f,4,false);

    PerspectiveLensCamera cam4(Point(30.f, 6.f, 0), Point(4,2.f,0), Vector(0, 1, 0), 50,
		std::make_pair(img.width(), img.height()),0.9f,0.3f,1.f,16,true);

    //PerspectiveLensCamera cam1(Point(30.f, 0.f, 0.f), Point(0, 0, 0), Vector(0, 1, 0), 60,
	//	std::make_pair(img.width(), img.height()),0.9f,0.0f,1.f,4,true);
    //cam1.addRef();


	PerspectiveCamera cam2(Point(6.f, 1.f, 0.f), Point(0, -1, 0), Vector(0, 1, 0), 60,
		std::make_pair(img.width(), img.height()));
	//cam2.addRef();


    // index scene
    scene.rebuildIndex();

    //Set up the integrator
	PhotonMap_Integrator integrator;
	//IntegratorImpl integrator;
	integrator.addRef();
	integrator.scene = &scene;

	PointLightSource pls;
	pls.falloff = float4(0, 0, 1, 0);
	pls.intensity  = float4::rep(0.6f);
	pls.position = Point(7.f, 3.f, 0.f);
	integrator.lightSources.push_back(pls);

	PointLightSource pls2;
	pls2.falloff = float4(0, 0, 1, 0);
	pls2.intensity  = float4::rep(0.7f);
	pls2.position = Point(30.f, 6.f, 0.f);
	integrator.lightSources.push_back(pls2);

    PointLightSource pls3;
	pls3.falloff = float4(0, 0, 1, 0);
	pls3.intensity  = float4(0.3f,0.1f,0.1f,0);
	pls3.position = Point(7.f, 3.f, -8.f);
	integrator.lightSources.push_back(pls3);

	integrator.ambientLight = float4::rep(0.1f);

    integrator.start_photonmapping();

	DefaultSampler samp;
	samp.addRef();

	HaltonSampleGenerator halton;
	halton.sampleCount = 4;

	//Render
	Renderer r;
	r.integrator = &integrator;
	r.target = &img;
	r.sampler = &halton;

	r.camera = &cam4;
	r.render(32,23);
	img.writePNG("frey_leonhardt_rc.png");

}
// The MAIN function, from here we start our application and run our Game loop
int main()
{
    // Init GLFW
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    GLFWwindow* window = glfwCreateWindow(screenWidth, screenHeight, "LearnOpenGL", nullptr, nullptr); // Windowed
    glfwMakeContextCurrent(window);

    // Set the required callback functions
    glfwSetKeyCallback(window, key_callback);
    glfwSetCursorPosCallback(window, mouse_callback);

    // Options
    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);	

    // Initialize GLEW to setup the OpenGL Function pointers
    glewExperimental = GL_TRUE;
    glewInit();

    // Define the viewport dimensions
    glViewport(0, 0, screenWidth, screenHeight);

    // Setup OpenGL options
    glEnable(GL_DEPTH_TEST);

    // Setup and compile our shaders
    Shader planetShader("planet.vs", "planet.frag");
    Shader instanceShader("instanced_asteroids.vs", "instanced_asteroids.frag");

    // Load models
    Model rock("../../../resources/objects/rock/rock.obj");
    Model planet("../../../resources/objects/planet/planet.obj");

    // Set projection matrix
    glm::mat4 projection = glm::perspective(45.0f, (GLfloat)screenWidth/(GLfloat)screenHeight, 1.0f, 10000.0f);
    planetShader.Use();
    glUniformMatrix4fv(glGetUniformLocation(planetShader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
    // Also of instance shader
    instanceShader.Use();
    glUniformMatrix4fv(glGetUniformLocation(instanceShader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));

    // Generate a large list of semi-random model transformation matrices
    GLuint amount = 100000;
    glm::mat4* modelMatrices;
    modelMatrices = new glm::mat4[amount];
    srand(glfwGetTime()); // initialize random seed	
    GLfloat radius = 150.0f;
    GLfloat offset = 25.0f;
    for(GLuint i = 0; i < amount; i++)
    {
        glm::mat4 model;
        // 1. Translation: Randomly displace along circle with radius 'radius' in range [-offset, offset]
        GLfloat angle = (GLfloat)i / (GLfloat)amount * 360.0f;
        GLfloat displacement = (rand() % (GLint)(2 * offset * 100)) / 100.0f - offset;
        GLfloat x = sin(angle) * radius + displacement;
        displacement = (rand() % (GLint)(2 * offset * 100)) / 100.0f - offset;
        GLfloat y = -2.5f + displacement * 0.4f; // Keep height of asteroid field smaller compared to width of x and z
        displacement = (rand() % (GLint)(2 * offset * 100)) / 100.0f - offset;
        GLfloat z = cos(angle) * radius + displacement;
        model = glm::translate(model, glm::vec3(x, y, z));
        
        // 2. Scale: Scale between 0.05 and 0.25f
        GLfloat scale = (rand() % 20) / 100.0f + 0.05;
        model = glm::scale(model, glm::vec3(scale));		
        
        // 3. Rotation: add random rotation around a (semi)randomly picked rotation axis vector
        GLfloat rotAngle = (rand() % 360);
        model = glm::rotate(model, rotAngle, glm::vec3(0.4f, 0.6f, 0.8f));

        // 4. Now add to list of matrices
        modelMatrices[i] = model;
    }

    // Set transformation matrices as an instance vertex attribute (with divisor 1)
    // NOTE: We're cheating a little by taking the, now publicly declared, VAO of the model's mesh(es) and adding new vertexAttribPointers
    // Normally you'd want to do this in a more organized fashion, but for learning purposes this will do.
    for(GLuint i = 0; i < rock.meshes.size(); i++)
    {
        GLuint VAO = rock.meshes[i].VAO;
        GLuint buffer;
        glBindVertexArray(VAO);
        glGenBuffers(1, &buffer);
        glBindBuffer(GL_ARRAY_BUFFER, buffer);
        glBufferData(GL_ARRAY_BUFFER, amount * sizeof(glm::mat4), &modelMatrices[0], GL_STATIC_DRAW);
        // Set attribute pointers for matrix (4 times vec4)
        glEnableVertexAttribArray(3); 
        glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (GLvoid*)0);
        glEnableVertexAttribArray(4); 
        glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (GLvoid*)(sizeof(glm::vec4)));
        glEnableVertexAttribArray(5); 
        glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (GLvoid*)(2 * sizeof(glm::vec4)));
        glEnableVertexAttribArray(6); 
        glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (GLvoid*)(3 * sizeof(glm::vec4)));

        glVertexAttribDivisor(3, 1);
        glVertexAttribDivisor(4, 1);
        glVertexAttribDivisor(5, 1);
        glVertexAttribDivisor(6, 1);

        glBindVertexArray(0);
    }

    // Game loop
    while(!glfwWindowShouldClose(window))
    {
        // Set frame time
        GLfloat currentFrame = glfwGetTime();
        deltaTime = currentFrame - lastFrame;
        lastFrame = currentFrame;

        // Check and call events
        glfwPollEvents();
        Do_Movement();

        // Clear buffers
        glClearColor(0.03f, 0.03f, 0.03f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // Add transformation matrices
        planetShader.Use();
        glUniformMatrix4fv(glGetUniformLocation(planetShader.Program, "view"), 1, GL_FALSE, glm::value_ptr(camera.GetViewMatrix()));	
        instanceShader.Use();
        glUniformMatrix4fv(glGetUniformLocation(instanceShader.Program, "view"), 1, GL_FALSE, glm::value_ptr(camera.GetViewMatrix()));	

        // Draw Planet
        planetShader.Use();
        glm::mat4 model;
        model = glm::translate(model, glm::vec3(0.0f, -5.0f, 0.0f));
        model = glm::scale(model, glm::vec3(4.0f, 4.0f, 4.0f));
        glUniformMatrix4fv(glGetUniformLocation(planetShader.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
        planet.Draw(planetShader);

        // Draw meteorites
        instanceShader.Use();
        glBindTexture(GL_TEXTURE_2D, rock.textures_loaded[0].id); // Note we also made the textures_loaded vector public (instead of private) from the model class.
        for(GLuint i = 0; i < rock.meshes.size(); i++)
        {
            glBindVertexArray(rock.meshes[i].VAO);
            glDrawElementsInstanced(GL_TRIANGLES, rock.meshes[i].vertices.size(), GL_UNSIGNED_INT, 0, amount);
            glBindVertexArray(0);
        }
        
        // Swap the buffers
        glfwSwapBuffers(window);
    }

    delete[] modelMatrices;

    glfwTerminate();
    return 0;
}
Beispiel #26
0
	//
	//Perturbation acceleration
	triple Force::force_pert()
	{
		triple acc = triple(.0, .0, .0);
		triple accp;

		SRP EFG;
		AtmosphericDrag HIJ;

		//ускорение от центрального тела
		if (Global::b_Cunn) acc = Global::GravField_CB.getAcceleration(Global::IDC, time, X);

		//Меркурий
		if (Global::b_1) { accp = planet(1); acc = acc + accp; }
		//Венера
		if (Global::b_2) { accp = planet(2); acc = acc + accp; }
		//Земля+Луна
		if (Global::b_3) { accp = planet(3); acc = acc + accp; }
		//Марс
		if (Global::b_4) { accp = planet(4); acc = acc + accp; }
		//Юпитер
		if (Global::b_5) { accp = planet(5); acc = acc + accp; }
		//Сатурн
		if (Global::b_6) { accp = planet(6); acc = acc + accp; }
		//Уран
		if (Global::b_7) { accp = planet(7); acc = acc + accp; }
		//Нептун
		if (Global::b_8) { accp = planet(8); acc = acc + accp; }
		//Плутон
		if (Global::b_9) { accp = planet(9); acc = acc + accp; }
		//Солнце
		if (Global::b_10) { accp = planet(10); acc = acc + accp; }

		//add
		if (Global::b_add1) { accp = planet(Global::ID1); acc = acc + accp; }
		if (Global::b_add2) { accp = planet(Global::ID2); acc = acc + accp; }
		if (Global::b_add3) { accp = planet(Global::ID3); acc = acc + accp; }
		if (Global::b_add4) { accp = planet(Global::ID4); acc = acc + accp; }

		if (Global::b_add5)
		{
			accp = acc5th_body();
			acc += accp;
		}

		//SRP
		if (Global::b_SRP) {

			EFG.setpos(X);
			triple acc_SRP = EFG.getAcceleration(time);
			acc = acc + acc_SRP;
		}
		//атмосферное торможение
		if (Global::b_atm) {

			HIJ.setPos(X);
			HIJ.setVel(V);
			acc = acc + HIJ.getAcc(time);
		}

		//Релятивистские возмущения в рамках задачи Шварцшильда(PPN=1)
		if (Global::b_rel) { triple accr = relativ(); acc = acc + accr; }
		if (Global::b_rel_LT) { triple accLT = L_T(); acc = acc + accLT; }

		return(acc);
	};
Beispiel #27
0
	void Force::force_w(double Ti)
	{
		ConstSpiceChar *pictur = "YYYY MM DD HR:MN:SC.####### ::UTC";

		triple acc, accp, accr, acc_SRP, accA;

		SRP EFG;
		AtmosphericDrag HIJ;

		SpiceChar        utcstr[100];
		//et2utc_c ( this->time,  "C", 10, 80, utcstr );
		timout_c(time, pictur, 50, utcstr);
		fprintf(facc, "%s", utcstr);
		fprintf(facc, et_F, time);
		triple acccb = force_cb();
		fprintf(facc, et_F, acccb.getAbs());

		//Central body + harmonic coefficients
		if (Global::b_Cunn)
		{
			triple accCunn = Global::GravField_CB.getAcceleration(Global::IDC, time, X);
			fprintf(facc, et_F, accCunn.getAbs());
		}
		else fprintf(facc, " 0");

		//Sun
		if (Global::b_10) { accp = planet(10); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }

		//Mercury 
		if (Global::b_1) { accp = planet(1); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }

		//Venus
		if (Global::b_2) { accp = planet(2); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }

		//Earth+Moon
		if (Global::b_3) { accp = planet(3); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//Mars
		if (Global::b_4) { accp = planet(4); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//Jupiter
		if (Global::b_5) { accp = planet(5); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//Saturn
		if (Global::b_6) { accp = planet(6); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//Uranus
		if (Global::b_7) { accp = planet(7); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//Neptune
		if (Global::b_8) { accp = planet(8); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//Pluto
		if (Global::b_9) { accp = planet(9); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }

		//add1
		if (Global::b_add1) { accp = planet(Global::ID1); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//add2
		if (Global::b_add2) { accp = planet(Global::ID2); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//add3
		if (Global::b_add3) { accp = planet(Global::ID3); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		//add4
		if (Global::b_add4) { accp = planet(Global::ID4); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }

		if (Global::b_add5) 
		{
			//add5's central gravity part 
			accp = planet(Global::ID5);
			// add5's non-central gravity part
			if (Global::b_add5_cun_on) {

				double pos[3], lt;
				spkgps_c(Global::IDC, time, "J2000", Global::ID5, pos, &lt);
				
				triple pos_CB(pos);
				triple Xbs = pos_CB + X;

				triple fs = Global::GravField_add5.getAcceleration(Global::ID5, time, Xbs);
				triple fcb = Global::GravField_add5.getAcceleration(Global::ID5, time, pos_CB);

				fprintf(facc, " %13.5e  %13.5e ", accp.getAbs(), (fs - fcb).getAbs());
			}
			else 
			{
				fprintf(facc, " %13.5e  0 ", accp.getAbs());
			}
		}
		else { fprintf(facc, " 0 0 "); }

		//SRP
		if (Global::b_SRP) {
			EFG.setpos(X);
			acc_SRP = EFG.getAcceleration(time);

			fprintf(facc, et_F, acc_SRP.getAbs());
		}
		else { fprintf(facc, " 0"); }

		//atmospheric drag
		if (Global::b_atm) {
			HIJ.setPos(X);
			HIJ.setVel(V);
			accA = HIJ.getAcc(time);

			fprintf(facc, et_F, accA.getAbs());
		}
		else { fprintf(facc, " 0"); }

		//General relativity effects (Swartsshild metric,PPN=1)
		if (Global::b_rel) { accp = relativ();  fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }

		//General relativity effects (L-T precession, PPN=1)
		if (Global::b_rel_LT) { accp = L_T(); fprintf(facc, et_F, accp.getAbs()); }
		else { fprintf(facc, " 0"); }
		fprintf(facc, "\n");
	}