コード例 #1
0
void MapInfo::resetToDefaults()
{
    Definition::resetToDefaults();

    // Add all expected fields with their default values.
    def().addText  ("id", "");
    def().addText  ("title", "Untitled");
    def().addText  ("titleImage", "");
    def().addText  ("author", "Unknown");
    def().addNumber("flags", 0);
    def().addText  ("music", "");
    def().addNumber("parTime", -1); // unknown
    def().addArray ("fogColor", new ArrayValue(Vector3f(DEFAULT_FOG_COLOR_RED, DEFAULT_FOG_COLOR_GREEN, DEFAULT_FOG_COLOR_BLUE)));
    def().addNumber("fogStart", DEFAULT_FOG_START);
    def().addNumber("fogEnd", DEFAULT_FOG_END);
    def().addNumber("fogDensity", DEFAULT_FOG_DENSITY);
    def().addText  ("fadeTable", "");
    def().addNumber("ambient", 0);
    def().addNumber("gravity", 1);
    def().addText  ("skyId", "");
    def().addText  ("execute", "");

    QScopedPointer<Record> sky(new Record);
    Sky(*sky).resetToDefaults();
    def().add      ("sky", sky.take());
}
コード例 #2
0
ファイル: perlin.cpp プロジェクト: sdp0et/gtp
Vector PerlinGenerator::at( const Vector& pos )
{
  //return sky( pos.x,pos.y,pos.z, SKY_BLUE, CLOUD_WHITE ) ;
  Vector n = pos/worldNormalizer ;

  switch( noiseType )
  {
    case PerlinNoiseType::Sky:
      return sky( n.x, n.y, n.z, SKY_BLUE, CLOUD_WHITE ) ;
      
    case PerlinNoiseType::Wood:
      return wood( n.x, n.y, n.z ) ;
      
    case PerlinNoiseType::Marble:
    default:
      return marble( n.x,n.y,n.z, n.x ) ;

    case PerlinNoiseType::CustomLinear:
      return linearSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ;
      
    case PerlinNoiseType::CustomQuadratic:
      return quadraticSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ;

    case PerlinNoiseType::CustomCubic:
      return cubicSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ;

    case PerlinNoiseType::CustomQuartic:
      return quarticSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ;

    case PerlinNoiseType::CustomQuintic:
      return quinticSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ;

  }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: barchinsky/2d-world
int main()
{
 
	/*const int SIZE = 500;
	ColorScale gradient;
//	gradient.insert(0.0,sf::Color::Red);
	gradient.insert(2.0,sf::Color(150,0,100));
	gradient.insert(1.0,sf::Color(0,0,255,70));
//	gradient.insert(3.0,sf::Color::Cyan);
//	gradient.insert(4.0,sf::Color::Green);
//	gradient.insert(5.0,sf::Color::Yellow);
//	gradient.insert(6.0,sf::Color::Red);
 
 
	sf::Color* tab =new sf::Color[SIZE];
	gradient.fillTab(tab,SIZE);
 

    Sky sky(800);
*/
	/*sf::RenderWindow DisplayManager().getWindow()(sf::VideoMode(800, 800, 32), "Gradient");
	DisplayManager().getWindow().setFramerateLimit(30);
 
	sf::Image image;
    image.create(SIZE,SIZE);
	for(int i=0;i<SIZE;i++)
	{
		for(int j=0;j<SIZE;j++)
		{
			image.setPixel(i,j,tab[j]);
		}		
	}
    
    sf::Texture texture;
    texture.loadFromImage(image);
	sf::Sprite sprite(texture);
 */

    Sky sky(1000);
	while(DisplayManager().getWindow().isOpen())
	{
        sf::sleep(sf::seconds(1));
		sf::Event Event;
		while (DisplayManager().getWindow().pollEvent(Event)) 
		{
if (Event.type==sf::Event::Closed)
			{
				DisplayManager().getWindow().close();
			} 
		}
 
		DisplayManager().getWindow().clear();
        sky.update();
		DisplayManager().getWindow().display();
	}

	return 0;
}
コード例 #4
0
void
statistics(struct statisticsparams *p)
{
  int print_basic_info=1;

  /* Print the one-row numbers if the user asked for them. */
  if(p->singlevalue)
    {
      print_basic_info=0;
      if(p->ontile) statistics_on_tile(p);
      else          statistics_print_one_row(p);
    }

  /* Find the Sky value if called. */
  if(p->sky)
    {
      sky(p);
      print_basic_info=0;
    }

  /* Print the ASCII plots if requested. */
  if(p->asciihist || p->asciicfp)
    {
      ascii_plots(p);
      print_basic_info=0;
    }

  /* Save the histogram and CFP as tables if requested. */
  if(p->histogram || p->cumulative)
    {
      print_basic_info=0;
      save_hist_and_or_cfp(p);
    }

  /* Print the sigma-clipped results. */
  if( p->sigmaclip )
    {
      print_basic_info=0;
      print_sigma_clip(p);
    }

  /* Make the mirror table. */
  if( !isnan(p->mirror) )
    {
      print_basic_info=0;
      print_mirror_hist_cfp(p);
    }

  /* If nothing was requested print the simple statistics. */
  if(print_basic_info)
    print_basics(p);

}
コード例 #5
0
void PlayableState::draw()
{
    sky(100);
    playerControls.doEvents();
    if (auto spt = theWorld.lock())  // Has to be copied into a shared_ptr before usage
    {
        spt->stepWorld();
        spt->debugDraw();
        spt->draw();
        // spt->playerShip.fireDefaultWeapon();
    }
}
コード例 #6
0
ファイル: DrawingState.cpp プロジェクト: amcolash/cs559
DrawingState::DrawingState()
{
  // reasonable defaults for everything
  timeOfDay = 9;				// morning
  sky(.7f,.7f,1);					// blue sky
  ground(0,84,24);				// green grass
  camera = 0;
  fieldOfView = 45;
  backCull = 0;
  drGrTex = 0;
  counter = 0;
}
コード例 #7
0
void ProfileSelectState::draw()
{
    sky();

    title->display();

    highlightOption(selectedOption);

    highlight->display();

    for(int i = 0; i < selectableOptions.size(); ++i)
    {
        selectableOptions.at(i)->display();
    }
}
コード例 #8
0
ファイル: main.cpp プロジェクト: johannjc/Coding-Examples
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";
  }
}
コード例 #9
0
ファイル: gl_portal.cpp プロジェクト: milasudril/GZDoom-GPL
void GLEEHorizonPortal::DrawContents()
{
	PortalAll.Clock();
	sector_t *sector = portal->mOrigin;
	if (sector->GetTexture(sector_t::floor) == skyflatnum ||
		sector->GetTexture(sector_t::ceiling) == skyflatnum)
	{
		GLSkyInfo skyinfo;
		skyinfo.init(sector->sky, 0);
		GLSkyPortal sky(&skyinfo, true);
		sky.DrawContents();
	}
	if (sector->GetTexture(sector_t::ceiling) != skyflatnum)
	{
		GLHorizonInfo horz;
		horz.plane.GetFromSector(sector, true);
		horz.lightlevel = gl_ClampLight(sector->GetCeilingLight());
		horz.colormap = sector->ColorMap;
		if (portal->mType == PORTS_PLANE)
		{
			horz.plane.Texheight = ViewPos.Z + fabs(horz.plane.Texheight);
		}
		GLHorizonPortal ceil(&horz, true);
		ceil.DrawContents();
	}
	if (sector->GetTexture(sector_t::floor) != skyflatnum)
	{
		GLHorizonInfo horz;
		horz.plane.GetFromSector(sector, false);
		horz.lightlevel = gl_ClampLight(sector->GetFloorLight());
		horz.colormap = sector->ColorMap;
		if (portal->mType == PORTS_PLANE)
		{
			horz.plane.Texheight = ViewPos.Z - fabs(horz.plane.Texheight);
		}
		GLHorizonPortal floor(&horz, true);
		floor.DrawContents();
	}



}
コード例 #10
0
ファイル: hw_portal.cpp プロジェクト: usernameak/gzdoom
void HWEEHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
{
	auto &vp = di->Viewpoint;
	sector_t *sector = portal->mOrigin;
	if (sector->GetTexture(sector_t::floor) == skyflatnum ||
		sector->GetTexture(sector_t::ceiling) == skyflatnum)
	{
		GLSkyInfo skyinfo;
		skyinfo.init(di, sector->sky, 0);
		HWSkyPortal sky(screen->mSkyData, mState, &skyinfo, true);
		sky.DrawContents(di, state);
	}
	if (sector->GetTexture(sector_t::ceiling) != skyflatnum)
	{
		GLHorizonInfo horz;
		horz.plane.GetFromSector(sector, sector_t::ceiling);
		horz.lightlevel = hw_ClampLight(sector->GetCeilingLight());
		horz.colormap = sector->Colormap;
		horz.specialcolor = 0xffffffff;
		if (portal->mType == PORTS_PLANE)
		{
			horz.plane.Texheight = vp.Pos.Z + fabs(horz.plane.Texheight);
		}
		HWHorizonPortal ceil(mState, &horz, di->Viewpoint, true);
		ceil.DrawContents(di, state);
	}
	if (sector->GetTexture(sector_t::floor) != skyflatnum)
	{
		GLHorizonInfo horz;
		horz.plane.GetFromSector(sector, sector_t::floor);
		horz.lightlevel = hw_ClampLight(sector->GetFloorLight());
		horz.colormap = sector->Colormap;
		horz.specialcolor = 0xffffffff;
		if (portal->mType == PORTS_PLANE)
		{
			horz.plane.Texheight = vp.Pos.Z - fabs(horz.plane.Texheight);
		}
		HWHorizonPortal floor(mState, &horz, di->Viewpoint, true);
		floor.DrawContents(di, state);
	}
}
コード例 #11
0
ファイル: main.cpp プロジェクト: spacetime/kstars-hackfest
int main(int argc, char *argv[])
{
    KAboutData aboutData( "kstars", 0, ki18n("KStars"),
                          KSTARS_VERSION, ki18n(description), KAboutData::License_GPL,
                          ki18n("(c) 2001-2012, The KStars Team"), ki18n(notice), "http://edu.kde.org/kstars");
    aboutData.addAuthor(ki18n("Jason Harris"),KLocalizedString(), "*****@*****.**", "http://www.30doradus.org");
    aboutData.addAuthor(ki18n("Jasem Mutlaq"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("James Bowlin"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Pablo de Vicente"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Thomas Kabelmann"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Heiko Evermann"),KLocalizedString(), "*****@*****.**", "http://www.evermann.de");
    aboutData.addAuthor(ki18n("Carsten Niehaus"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Mark Hollomon"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Alexey Khudyakov"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("M&eacute;d&eacute;ric Boquien"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Akarsh Simha"), KLocalizedString(), "*****@*****.**", "http://www.ph.utexas.edu/~asimha");
    aboutData.addAuthor(ki18n("J&eacute;r&ocirc;me Sonrier"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Prakash Mohan"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Victor Cărbune"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Henry de Valence"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Samikshan Bairagya"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Rafał Kułaga"), KLocalizedString(), "*****@*****.**");
    aboutData.addAuthor(ki18n("Rishab Arora"), KLocalizedString(), "*****@*****.**");

    aboutData.addCredit(ki18n("Valery Kharitonov"), ki18n("Converted labels containing technical terms to links to documentation") );
    aboutData.addCredit(ki18n("Ana-Maria Constantin"), ki18n("Technical documentation on Astronomy and KStars") );
    aboutData.addCredit(ki18n("Andrew Stepanenko"), ki18n("Guiding code based on lin_guider") );
    aboutData.addCredit(ki18n("Nuno Pinheiro"), ki18n("Artwork") );

    KCmdLineArgs::init( argc, argv, &aboutData );

    KCmdLineOptions options;
    options.add("!dump", ki18n( "Dump sky image to file" ));
    options.add("script ", ki18n( "Script to execute" ));
    options.add("width ", ki18n( "Width of sky image" ), "640");
    options.add("height ", ki18n( "Height of sky image" ), "480");
    options.add("filename ", ki18n( "Filename for sky image" ), "kstars.png");
    options.add("date ", ki18n( "Date and time" ));
    options.add("!paused", ki18n( "Start with clock paused" ));
    KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    KApplication a;

    if ( args->isSet( "dump" ) ) {
        kDebug() << i18n( "Dumping sky image" );

        //parse filename and image format
        const char* format = "PNG";
        QString fname = args->getOption( "filename" );
        QString ext = fname.mid( fname.lastIndexOf(".")+1 );
        if ( ext.toLower() == "png" ) { format = "PNG"; }
        else if ( ext.toLower() == "jpg" || ext.toLower() == "jpeg" ) { format = "JPG"; }
        else if ( ext.toLower() == "gif" ) { format = "GIF"; }
        else if ( ext.toLower() == "pnm" ) { format = "PNM"; }
        else if ( ext.toLower() == "bmp" ) { format = "BMP"; }
        else { kWarning() << i18n( "Could not parse image format of %1; assuming PNG.", fname ) ; }

        //parse width and height
        bool ok(false);
        int w(0), h(0);
        w = args->getOption( "width" ).toInt( &ok );
        if ( ok ) h =  args->getOption( "height" ).toInt( &ok );
        if ( !ok ) {
            kWarning() << "Unable to parse arguments: " ;
            kWarning() << "Width: " << args->getOption( "width" )
            << "  Height: " << args->getOption( "height" ) << endl;
            return 1;
        }

        KStarsData *dat = KStarsData::Create();
        QObject::connect( dat, SIGNAL( progressText(QString) ), dat, SLOT( slotConsoleMessage(QString) ) );
        dat->initialize();

        //Set Geographic Location
        dat->setLocationFromOptions();

        //Set color scheme
        dat->colorScheme()->loadFromConfig();

        //set clock now that we have a location:
        //Check to see if user provided a date/time string.  If not, use current CPU time
        QString datestring = args->getOption( "date" );
        KStarsDateTime kdt;
        if ( ! datestring.isEmpty() ) {
            if ( datestring.contains( "-" ) ) { //assume ISODate format
                if ( datestring.contains( ":" ) ) { //also includes time
                    kdt = KDateTime::fromString( datestring, KDateTime::ISODate );
                } else { //string probably contains date only
                    kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) );
                    kdt.setTime( QTime( 0, 0, 0 ) );
                }
            } else { //assume Text format for date string
                kdt = dat->geo()->LTtoUT( KDateTime::fromString( datestring, KDateTime::QtTextDate ) );
            }

            if ( ! kdt.isValid() ) {
                kWarning() << i18n( "Using CPU date/time instead." ) ;

                kdt = KStarsDateTime::currentUtcDateTime();
            }
        } else {
            kdt = KStarsDateTime::currentUtcDateTime();
        }
        dat->clock()->setUTC( kdt );

        KSNumbers num( dat->ut().djd() );
        //		dat->initGuides(&num);

        SkyMap *map = SkyMap::Create();
        map->resize( w, h );
        QPixmap sky( w, h );

        dat->setFullTimeUpdate();
        dat->updateTime(dat->geo(), map );

        SkyPoint dest( Options::focusRA(), Options::focusDec() );
        map->setDestination( dest );
        map->destination()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() );
        map->setFocus( map->destination() );
        map->focus()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() );

        //Execute the specified script
        QString scriptfile = args->getOption( "script" );
        if ( ! scriptfile.isEmpty() ) {
            if ( dat->executeScript( scriptfile, map ) ) {
                std::cout << i18n( "Script executed." ).toUtf8().data() << std::endl;
            } else {
                kWarning() << i18n( "Could not execute script." ) ;
            }
        }

        qApp->processEvents();
        map->setupProjector();
        map->exportSkyImage( &sky );
        qApp->processEvents();

        if ( ! sky.save( fname, format ) ) kWarning() << i18n( "Unable to save image: %1 ", fname ) ;
        else kDebug() << i18n( "Saved to file: %1", fname );

        delete map;
        delete dat;
        return 0;
    }

    //start up normally in GUI mode

    //Try to parse the given date string
    QString datestring = args->getOption( "date" );
    //DEBUG
    kDebug() << "Date string: " << datestring;

    if ( ! datestring.isEmpty() && ! KStarsDateTime::fromString( datestring ).isValid() ) {
        kWarning() << i18n( "Using CPU date/time instead." ) ;
        datestring.clear();
    }

    KStars::createInstance( true, ! args->isSet( "paused" ), datestring );
    args->clear();
    QObject::connect(kapp, SIGNAL(lastWindowClosed()), kapp, SLOT(quit()));
    return a.exec();

}
コード例 #12
0
Scene * D3D::BuildScene(IDirect3DDevice9 *d3dDevice)
 {
	 // Setup some materials - we'll use these for 
	 // making the same mesh appear in multiple
	 // colors

	 D3DMATERIAL9 colors[8];
	 D3DUtil_InitMaterial( colors[0], 1.0f, 1.0f, 1.0f, 1.0f );	// white
	 D3DUtil_InitMaterial( colors[1], 0.0f, 1.0f, 1.0f, 1.0f );	// cyan
	 D3DUtil_InitMaterial( colors[2], 1.0f, 0.0f, 0.0f, 1.0f );	// red
	 D3DUtil_InitMaterial( colors[3], 0.0f, 1.0f, 0.0f, 1.0f );	// green
	 D3DUtil_InitMaterial( colors[4], 0.0f, 0.0f, 1.0f, 1.0f );	// blue
	 D3DUtil_InitMaterial( colors[5], 0.4f, 0.4f, 0.4f, 0.4f );	// 40% grey
	 D3DUtil_InitMaterial( colors[6], 0.25f, 0.25f, 0.25f, 0.25f );	// 25% grey
	 D3DUtil_InitMaterial( colors[7], 0.65f, 0.65f, 0.65f, 0.65f );	// 65% grey

	 // The identity matrix is always useful
	 D3DXMATRIX ident;
	 D3DXMatrixIdentity(&ident);

	 // We'll use these rotations for some teapots and grid objects
	 D3DXMATRIX rotateX, rotateY, rotateZ;

	 // Create the root, and the camera.
	 // Remeber how to use smart pointers?? I hope so!

	 boost::shared_ptr<TransformNode> root(new TransformNode(&ident));

	 boost::shared_ptr<CameraNode> camera(new CameraNode(&ident));
	 root->m_children.push_back(camera);



	 // We'll put the camera in the scene at (20,20,20) looking back at the Origin

	 D3DXMATRIX rotOnly, result, inverse;
	 float cameraYaw = - (3.0f * D3DX_PI) / 4.0f;
	 float cameraPitch = D3DX_PI / 4.0f;
	 D3DXQUATERNION q;
	 D3DXQuaternionIdentity(&q);
	 D3DXQuaternionRotationYawPitchRoll(&q, cameraYaw, cameraPitch, 0.0);
	 D3DXMatrixRotationQuaternion(&rotOnly, &q);

	 D3DXMATRIX trans;
	 D3DXMatrixTranslation(&trans, 15.0f, 15.0f, 15.0f);

	 D3DXMatrixMultiply(&result, &rotOnly, &trans);

	 D3DXMatrixInverse(&inverse, NULL, &result);
	 camera->VSetTransform(&result, &inverse);

	 D3DXMatrixRotationZ(&rotateZ, D3DX_PI / 2.0f);
	 D3DXMatrixRotationX(&rotateX, -D3DX_PI / 2.0f);
	 D3DXVECTOR3 target(30, 2, 15);

	 //

	

	 ID3DXMesh *teapot;
	 if( SUCCEEDED( D3DXCreateTeapot( d3dDevice, &teapot, NULL ) ) )
	 {
		 // Teapot #1 - a white one at (x=6,y=2,z=4)
		 D3DXMatrixTranslation(&trans,6,2,4);

		 boost::shared_ptr<SceneNode> mesh1(new MeshNode(teapot, &trans, colors[2]));
		 root->m_children.push_back(mesh1);

		 // Teapot #2 - a cyan one at (x=3,y=2,z=1)
		 //   with a 
		 D3DXMatrixTranslation(&trans, 3,2,1);
		 D3DXMATRIX result;
		 D3DXMatrixMultiply(&result, &rotateZ, &trans);

		 boost::shared_ptr<SceneNode> mesh2(new MeshNode(teapot, &result, colors[1]));
		 root->m_children.push_back(mesh2);

		 // Teapot #3 - another white one at (x=30, y=2, z=15)
		 D3DXMATRIX rotateY90;
		 D3DXMatrixRotationY(&rotateY90, D3DX_PI / 2.0f);
		 D3DXMatrixTranslation(&trans, target.x, target.y, target.z);
		 D3DXMatrixMultiply(&result, &rotateY90, &trans);
		 boost::shared_ptr<SceneNode> mesh3(new MeshNode(teapot, &result, colors[0]));
		 root->m_children.push_back(mesh3);

		 // We can release the teapot now, mesh1 and mesh2 AddRef'd it.
		 SAFE_RELEASE(teapot);
	 }

	 ID3DXMesh *sphere;
	 if ( SUCCEEDED( 
		 D3DXCreateSphere( 
		 d3dDevice, .25, 16, 16, &sphere, NULL) ) )
	 {
		 // We're going to create a spiral of spheres...
		 // starting at (x=3, y=0, z=3), and spiraling
		 // upward about a local Y axis.

		 D3DXMatrixTranslation(&trans, 3,0,3);

		 boost::shared_ptr<SceneNode> sphere1(new MeshNode(sphere, &trans, colors[4]) );
		 root->m_children.push_back(sphere1);

		 // Here's the local rotation and translation.
		 // We'll rotate about Y, and then translate
		 // up (along Y) and forward (along Z).
		 D3DXMatrixRotationY(&rotateY, D3DX_PI / 8.0f);
		 D3DXMATRIX trans2;
		 D3DXMatrixTranslation(&trans2, 0, 0.5, 0.5);
		 D3DXMatrixMultiply(&result, &trans2, &rotateY);

		 for (int i=0; i<25; i++)
		 {
			 // If you didn't think smart pointers were cool - 
			 // watch this! No leaked memory....

			 // Notice this is a heirarchy....
			 boost::shared_ptr<SceneNode> sphere2(new MeshNode(sphere, &result, colors[i%5]) );
			 sphere1->m_children.push_back(sphere2);
			 sphere1 = sphere2;
		 }

		 // We can release the sphere now, all the cylinders AddRef'd it.
		 SAFE_RELEASE(sphere);
	 }
	 

	 //
	 D3DXMatrixTranslation(&trans,-25,20,20);
	 //D3DXMatrixScaling(&trans, -10, -10, -10);
	 ScaleMtrl scale;
	 scale.x = -50.0f;
	 scale.y = -50.0f;
	 scale.z = -50.0f;
	 boost::shared_ptr<SceneNode> xmesh1(new XMeshNode(L"gf3.x", d3dDevice, &trans, &scale));
	 root->m_children.push_back(xmesh1);

	 
	  root->m_children.push_back(xmesh1);

	 /*D3DXMatrixTranslation(&trans,-45,20,20);
	 boost::shared_ptr<SceneNode> xmesh11(new XMeshNode(L"gf3.x", d3dDevice, &trans, &scale));
	 root->m_children.push_back(xmesh11);*/


	  XMeshNode *mm = new XMeshNode(L"gow_m1.x", d3dDevice, &trans, &scale);

	 D3DXMatrixTranslation(&trans,10,10,10);
	 //D3DXMatrixScaling(&trans, -10, -10, -10);
	 //ScaleMtrl scale;
	 scale.x = 100.0f;
	 scale.y = 100.0f;
	 scale.z = 100.0f;
	 boost::shared_ptr<SceneNode> xmesh2( new XMeshNode(L"gow_m1.x", d3dDevice, &trans, &scale));
	 root->m_children.push_back(xmesh2);

	 
	 
	 /*D3DXMatrixTranslation(&trans,20,20,20);
	 boost::shared_ptr<SceneNode> xmesh3(new XMeshNode(mm->m_mesh, mm->Mtrls, mm->Textures, &trans, 0));
	 root->m_children.push_back(xmesh3);*/

	 int col = 10;
	 int row= 10;
	 int zoom = 10;
	 const int COUNT = 13;
	 for(int i = 0; i < COUNT; i++)
	 {
		 for (int j = 0; j< COUNT; j++)
		 {
			 for(int z = 0; z< COUNT; z++)
			 {
				 D3DXMatrixTranslation(&trans, col + i, row + j , zoom + z);
				 boost::shared_ptr<SceneNode> xmeshNew(new XMeshNode(mm->m_mesh, mm->Mtrls, mm->Textures, &trans, 0));
				 root->m_children.push_back(xmeshNew);
			 }
		 }
	 }


	 //D3DXMatrixScaling(&trans, 10, 10, 10);

	 // Here are the grids...they make it easy for us to 
	 // see where the coordinates are in 3D space.
	 boost::shared_ptr<SceneNode> grid1(new Grid(40, 0x00404040, L"Textures\\grid.dds", &ident));
	 root->m_children.push_back(grid1);
	 boost::shared_ptr<SceneNode> grid2(new Grid(40, 0x00004000, L"Textures\\grid.dds", &rotateX));
	 root->m_children.push_back(grid2);
	 boost::shared_ptr<SceneNode> grid3(new Grid(40, 0x00000040, L"Textures\\grid.dds", &rotateZ));
	 root->m_children.push_back(grid3);

	 //  Here's the sky node that never worked!!!!
	 boost::shared_ptr<SkyNode> sky(new SkyNode(_T("Sky2"), camera));
	 root->m_children.push_back(sky);

	 D3DXMatrixTranslation(&trans,15,2,15);
	 D3DXMatrixRotationY(&rotateY, D3DX_PI / 4.0f);
	 D3DXMatrixMultiply(&result, &rotateY, &trans);

	 boost::shared_ptr<SceneNode> arrow1(new ArrowNode(2, &result, colors[0], d3dDevice));
	 root->m_children.push_back(arrow1);

	 D3DXMatrixRotationY(&rotateY, D3DX_PI / 2.0f);
	 D3DXMatrixMultiply(&result, &rotateY, &trans);
	 boost::shared_ptr<SceneNode> arrow2(new ArrowNode(2, &result, colors[5], d3dDevice));
	 root->m_children.push_back(arrow2);

	 D3DXMatrixMultiply(&result, &rotateX, &trans);
	 boost::shared_ptr<SceneNode> arrow3(new ArrowNode(2, &result, colors[0], d3dDevice));
	 root->m_children.push_back(arrow3);


	 // Everything has been attached to the root. Now
	 // we attach the root to the scene.

	 Scene *scene = new Scene(d3dDevice, root);
	 scene->Restore();

	 // A movement controller is going to control the camera, 
	 // but it could be constructed with any of the objects you see in this
	 // function. You can have your very own remote controlled sphere. What fun...
	 boost::shared_ptr<MovementController> m_pMovementController(new MovementController(camera, cameraYaw, cameraPitch));

	 scene->m_pMovementController = m_pMovementController;
	 return scene;
 }
コード例 #13
0
ファイル: raytracer.cpp プロジェクト: XBOOS/raytracing
int main(int argc, char* argv[])
{	
	// Build your scene and setup your camera here, by calling 
	// functions from Raytracer.  The code here sets up an example
	// scene and renders it from two different view points, DO NOT
	// change this if you're just implementing part one of the 
	// assignment.  
	Raytracer raytracer;
	int width = 320; 
	int height = 240; 

	if (argc == 3) {
		width = atoi(argv[1]);
		height = atoi(argv[2]);
	}
    
/***********************************************************Testing ********************************
    // Camera parameters.
    Point3D eye(0, 0, 1);
    Vector3D view(0, 0, -1);
    Vector3D up(0, 1, 0);
    double fov = 60;
    
    // Defines a material for shading.
    Material gold( Colour(0.3, 0.3, 0.3), Colour(0.75164, 0.60648, 0.22648),
                  Colour(0.628281, 0.555802, 0.366065),
                  51.2,0.3,0,NULL );
    Material jade( Colour(0, 0, 0), Colour(0.54, 0.89, 0.63),
                  Colour(0.316228, 0.316228, 0.316228),
                  12.8,0.3,0,NULL);
    
    // Defines a point light source.
    raytracer.addLightSource( new PointLight(Point3D(0.0, 0, 5),
                                             Colour(0.9, 0.9, 0.9) ) );
    
    // Add a unit square into the scene with material mat.
    SceneDagNode* sphere = raytracer.addObject( new UnitSphere(), &gold );
    SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &jade );
    
    // Apply some transformations to the unit square.
    double factor1[3] = { 1.0, 2.0, 1.0 };
    double factor2[3] = { 6.0, 6.0, 6.0 };
    raytracer.translate(sphere, Vector3D(0, 0, -5));
    raytracer.rotate(sphere, 'x', -45);
    raytracer.rotate(sphere, 'z', 45);
    raytracer.scale(sphere, Point3D(0, 0, 0), factor1);
    
    raytracer.translate(plane, Vector3D(0, 0, -7));
    raytracer.rotate(plane, 'z', 45);
    raytracer.scale(plane, Point3D(0, 0, 0), factor2);
    
    
    // Render the scene, feel free to make the image smaller for
    // testing purposes.
    raytracer.render(width, height, eye, view, up, fov, "view4.bmp");
    
    // Render it from a different point of view.
    Point3D eye2(4, 2, 1);
    Vector3D view2(-4, -2, -6);
    raytracer.render(width, height, eye2, view2, up, fov, "view5.bmp");
***********************************************************Testing ********************************/
/***********************************************************Final Scene********************************/
    // Camera parameters.
//	Point3D eye(0, 8, -3);
//	Vector3D view(0, -1,0);
    Point3D eye(0, 0, 1);
    Vector3D view(0, 0, -1);
    
	Vector3D up(0, 1, 0);
	double fov = 60;

	// Defines a material for shading.
	Material gold( Colour(0.3, 0.3, 0.3), Colour(0.75164, 0.60648, 0.22648), 
			Colour(0.628281, 0.555802, 0.366065), 
			51.2,0.2,NULL);
//	Material jade( Colour(0, 0, 0), Colour(0.54, 0.89, 0.63), 
//			Colour(0.316228, 0.316228, 0.316228), 
//			12.8,0.5,NULL);
    Material jade( Colour(0, 0, 0), Colour(0.47, 0.576, 0.859),
                  Colour(0.316228, 0.316228, 0.316228),
                  12.8,0.5,NULL);
    Material red( Colour(0.3, 0.3, 0.3), Colour(1, 0, 0),
                 Colour(0.628281, 0.555802, 0.366065),
                 51.2,0.2,NULL);
    
    Material white( Colour(0.3, 0.3, 0.3), Colour(1, 0.8549, 0.7255),
                 Colour(0.628281, 0.555802, 0.366065),
                 51.2,0.2,NULL);
    Material pink( Colour(0.3, 0.3, 0.3), Colour(0.9412, 0.502, 0.502),
                   Colour(0.628281, 0.555802, 0.366065),
                   51.2,0.2,NULL);
    
    Material mirror( Colour(0.0, 0.0, 0.0), Colour(0.0, 0.0, 0.0),
                 Colour(0.0, 0.0, 0.0),
                 51.2,1,NULL);
    
    Material glass( Colour(0.3, 0.3, 0.3), Colour(1, 1, 1),
                    Colour(0.628281, 0.555802, 0.366065),
                    51.2,0,1,NULL);
    glass.R_index = 1.3;
    glass.transparency_coef=1;
	// Defines a point light source.
	raytracer.addLightSource( new PointLight(Point3D(0, 0, 5),
				Colour(0.9, 0.9, 0.9) ) );

    raytracer.addLightSource( new PointLight(Point3D(0, 6, -1),
                                             Colour(0.9, 0.3, 0.1) ) );
    
    Material test( Colour(0.3, 0.3, 0.3), Colour(0.3, 0.60648, 0.22648),
                  Colour(0.628281, 0.555802, 0.366065),
                  51.2 ,0.1,NULL);
    
    Material test3( Colour(0.3, 0.3, 0.3), Colour(0.3, 0.5, 0.22648),
                  Colour(0.628281, 0.555802, 0.366065),
                  51.2,1,NULL );
    
    Material test2( Colour(0, 0, 0), Colour(0.3, 0.3, 0.3),
                   Colour(1.0, 1.0, 1.0),
                   51.2,0,NULL );
    Texture sky("/Users/bingxu/Documents/graphics/COMP3271_assignment_4_template/raytracerMacOS/sky.bmp");
    Texture board("/Users/bingxu/Documents/graphics/COMP3271_assignment_4_template/raytracerMacOS/board.bmp");
    Material starrysky(Colour(0, 0, 0),Colour(0, 0, 0),
                       Colour(0.1, 0.1, 0.1), 11.264, 0, &sky);
    
    Material board_mat(Colour(0, 0, 0),Colour(0, 0, 0),
                       Colour(0.1, 0.1, 0.1), 11.264, 1, &board);
    
   
    SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &jade );
    SceneDagNode* plane1 = raytracer.addObject( new UnitSquare(), &jade );
    SceneDagNode* plane2 = raytracer.addObject( new UnitSquare(), &board_mat );//the bottom
   
    
    SceneDagNode* sphere = raytracer.addObject( new UnitSphere(), &mirror);
    SceneDagNode* sphere1 = raytracer.addObject( new UnitSphere(), &white );
    SceneDagNode* mars = raytracer.addObject( new UnitSphere(), &glass );
    SceneDagNode* earth = raytracer.addObject( new UnitSphere(), &pink );
    
    SceneDagNode* cylinder1 = raytracer.addObject( new UnitFiniteCylinder(), &gold );
    SceneDagNode* cylinder2 = raytracer.addObject( new UnitFiniteCylinder(), &gold );
    SceneDagNode* cylinder3 = raytracer.addObject( new UnitFiniteCylinder(), &gold );
    SceneDagNode* cone = raytracer.addObject( new UnitFiniteCone(), &red );


        double factor1[3] = { 2.0, 2.0, 2.0 };
        double factor2[3] = {50,50,50};
        double factor3[3] = { 1.0, 1.0, 1.0};
        double factor4[3] = { 1.0, 2, 1.0};
        double factor5[3] = {0.5,0.5,0.5};
        double factor6[3] = {0.5,1.5,0.5};
        double factor7[3] = {1.0,4.0,1.0};
    //3 squares
    	raytracer.translate(plane, Vector3D(0, 0, -15));
    	raytracer.scale(plane, Point3D(0, 0, 0), factor2);
    
        raytracer.translate(plane1, Vector3D(-15, 0, 0));
        raytracer.rotate(plane1, 'y', 90);
        raytracer.scale(plane1, Point3D(0, 0, 0), factor2);
   
        raytracer.translate(plane2, Vector3D(0, -8, 0));
        raytracer.rotate(plane2, 'x', -90);
        raytracer.scale(plane2, Point3D(0, 0, 0), factor2);

    //four balls
    raytracer.translate(sphere, Vector3D(-1, -6, -2));
    raytracer.scale(sphere, Point3D(0, 0, 0), factor3);
    
    
    raytracer.translate(sphere1,Vector3D(-4.5, -6, 1));
    raytracer.scale(sphere1, Point3D(0, 0, 0), factor3);
    
    raytracer.translate(mars, Vector3D(3, -3, -1));
    raytracer.scale(mars, Point3D(0, 0, 0), factor3);

   
    raytracer.translate(earth, Vector3D(-8, -6, -2));
    raytracer.scale(earth, Point3D(0, 0, 0), factor3);
    
    
    raytracer.rotate(cylinder1, 'z', -30);
    //raytracer.rotate(cylinder1, 'x', -15);
    raytracer.translate(cylinder1, Vector3D(0, -4, -2));
    raytracer.scale(cylinder1, Point3D(0, 0, 0), factor7);
   
    raytracer.rotate(cylinder2, 'z', -30);
    raytracer.translate(cylinder2, Vector3D(1.5, -3, -2));
    raytracer.scale(cylinder2, Point3D(0, 0, 0), factor6);
    
    raytracer.rotate(cylinder3, 'z', -30);
    raytracer.translate(cylinder3, Vector3D(-1.5, -3, -2));
    raytracer.scale(cylinder3, Point3D(0, 0, 0), factor6);
    
     raytracer.rotate(cone, 'z', -30);
     raytracer.translate(cone, Vector3D(0, 2, -2));
     raytracer.scale(cone, Point3D(0, 0, 0), factor4);
    
    std::clock_t start;
    double duration;
    
    start = std::clock();
   // raytracer.render(width, height, eye, view, up, fov, "view4.bmp");
    duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
    
    //std::cout<<"The rendering duration 1 is .......: "<< duration <<'\n';
    // Render it from a different point of view.
    
    Point3D eye2(3, 1, 5);
    Vector3D view2(-10, -8, -15);

    
    std::clock_t start1;
    double duration1;
    
    start1 = std::clock();
    raytracer.render(width, height, eye2, view2, up, fov, "view5.bmp");
    duration1 = ( std::clock() - start1 ) / (double) CLOCKS_PER_SEC;
    
   // std::cout<<"The rendering duration 2 is .......: "<< duration1 <<'\n';
    
    
    /***********************************************************Final Scene********************************/

        return 0;
}
コード例 #14
0
ファイル: sample_sky.cpp プロジェクト: rjw57/mcvoxel
int main(int argc, char** argv)
{
	if(argc != 3)
	{
		std::cerr << "syntax: " << argv[0] << " input_sky.hdr output.ppm" << std::endl;
		return EXIT_FAILURE;
	}

	// Load the sky
	mcvoxel::sky sky(argv[1]);

	// Size of output
	const int w(850), h(480);

	// Create a camera
	mcvoxel::camera camera;
	camera.set_centre(Eigen::Vector3f(0.f, 128.f, 0.f));
	camera.set_focal_length(h);
	camera.yaw_left(190.f * (2.f * M_PI / 360.f));
	//camera.pitch_up(-20.f * (2.f * M_PI / 360.f));
	camera.pitch_up(20.f * (2.f * M_PI / 360.f));

	// What is the ray corresponding to (0,0)
	mcvoxel::ray origin_ray(camera.eye_ray(0.f,0.f));
	std::cout << "Camera origin: " << origin_ray.origin().transpose() << '\n';
	std::cout << "   Looking at: " << origin_ray.direction().transpose() << '\n';

	// Create a collection of pixel samples which is 3x(w*h)
	Eigen::ArrayXXf samples(3, w*h);

	// Get camera vectors
	Eigen::Vector3f centre, look_at, up, right;
	camera.get_frame(centre, look_at, up, right);

	// Draw samples from the sky.
	for(int j=0; j<15; ++j)
	{
		std::cout << "j: " << j << std::endl;
		for(int i=0; i<w*h; ++i)
		{
			Eigen::Vector3f direction, chrominance;
			sky.sample_direction(direction, chrominance);

			// Get the image-plane co-ordinates for that ray
			float x, y;
			if(!camera.pixel_coord(direction, x, y))
				continue;

			// convert to image pixel co-ordinate
			x = floor(x + 0.5f * w); y = floor(-y + 0.5f * h);

			if((x < 0.f) || (x >= w) || (y < 0.f) || (y >= h))
				continue;

			int idx = static_cast<int>(y) * w + static_cast<int>(x);
			samples.matrix().col(idx) += chrominance;
		}
	}

	std::cout << "Rendering done." << std::endl;

	// Poor-man's tone-mapping
	Eigen::ArrayXXf tone_mapped_samples((samples / std::max(1e-3f, samples.maxCoeff())).cwiseSqrt());

	std::vector<data::pixel<uint8_t> > pixels(w*h, data::pixel<uint8_t>(0,0,0));
	for(int i=0; i<w*h; ++i)
	{
		pixels[i].r = static_cast<uint8_t>(255.f * tone_mapped_samples(0,i));
		pixels[i].g = static_cast<uint8_t>(255.f * tone_mapped_samples(1,i));
		pixels[i].b = static_cast<uint8_t>(255.f * tone_mapped_samples(2,i));
	}
	std::ofstream output(argv[2]);
	io::write_ppm(output, &(pixels[0]), w, h);

	return EXIT_SUCCESS;
}
コード例 #15
0
void SceneObjectEntryPointSurf::onAdd() {
	// Physics

	std::shared_ptr<pge::SceneObjectPhysicsWorld> physicsWorld(new pge::SceneObjectPhysicsWorld());

	getRenderScene()->addNamed(physicsWorld, "physWrld");

	pge::SceneObjectRef lighting = getScene()->getNamed("lighting");

	pge::SceneObjectLighting* pLighting = static_cast<pge::SceneObjectLighting*>(lighting.get());

	pLighting->_ambientLight = pge::Vec3f(0.01f, 0.01f, 0.01f);

	/*std::shared_ptr<pge::SceneObjectDirectionalLightShadowed> light(new pge::SceneObjectDirectionalLightShadowed());

	getRenderScene()->add(light);

	light->create(pLighting, 2, 2048, 0.5f, 100.0f, 0.6f);

	light->setDirection(pge::Vec3f(-0.4f, -1.0f, 0.6f).normalized());

	light->setColor(pge::Vec3f(1.0f, 1.0f, 1.0f));*/

	// GUI

	/*std::shared_ptr<SceneObjectGUI> gui(new SceneObjectGUI());

	getRenderScene()->addNamed(gui, "gui", false);

	gui->_layer = 2.0f;*/

	// Control

	std::shared_ptr<SceneObjectOrbitCamera> camera(new SceneObjectOrbitCamera());

	getRenderScene()->add(camera, false);

	// Map

	/*std::shared_ptr<pge::Map3DWS> map(new pge::Map3DWS());

	map->_settings._pScene = getScene();

	map->createAsset("resources/maps/horrorMap.3dw");

	pge::addMapLights(*map, getScene());*/

	std::shared_ptr<SceneObjectProp> prop(new SceneObjectProp());

	getScene()->add(prop, true);

	prop->create("resources/models/BlockGame.obj");

	prop->calculateAABB();

	std::shared_ptr<SceneObjectSurf> cartPole(new SceneObjectSurf());

	getRenderScene()->add(cartPole, false);

	cartPole->create();

	cartPole->_layer = 100.0f;

	std::shared_ptr<SceneObjectProp> sky(new SceneObjectProp());

	getScene()->add(sky, true);

	sky->create("resources/models/skybox1.obj");

	sky->_transform = pge::Matrix4x4f::scaleMatrix(pge::Vec3f(100.0f, 100.0f, 100.0f));

	sky->calculateAABB();

	std::shared_ptr<pge::SceneObjectDirectionalLightShadowed> directionalLight(new pge::SceneObjectDirectionalLightShadowed());

	getScene()->add(directionalLight);

	directionalLight->create(pLighting, 3, 2048, 0.2f, 100.0f, 0.6f);

	directionalLight->setDirection(pge::Vec3f(-0.2523f, -0.9423f, -0.424f).normalized());

	directionalLight->setColor(pge::Vec3f(0.7f, 0.7f, 0.7f));

	// ------------------------------------------- Image Effects -------------------------------------------

	std::shared_ptr<pge::SceneObjectEffectBuffer> effectBuffer(new pge::SceneObjectEffectBuffer());

	getRenderScene()->addNamed(effectBuffer, "ebuf", false);

	effectBuffer->create(0.5f);

	std::shared_ptr<pge::Asset> assetBlurHorizontal;

	getScene()->getAssetManager("shader", pge::Shader::assetFactory)->getAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/blurHorizontal.frag", assetBlurHorizontal);

	std::shared_ptr<pge::Shader> blurShaderHorizontal = std::static_pointer_cast<pge::Shader>(assetBlurHorizontal);

	std::shared_ptr<pge::Asset> assetBlurVertical;

	getScene()->getAssetManager("shader", pge::Shader::assetFactory)->getAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/blurVertical.frag", assetBlurVertical);

	std::shared_ptr<pge::Shader> blurShaderVertical = std::static_pointer_cast<pge::Shader>(assetBlurVertical);

	std::shared_ptr<pge::Asset> assetRenderImage;

	getScene()->getAssetManager("shader", pge::Shader::assetFactory)->getAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/renderImage.frag", assetRenderImage);

	std::shared_ptr<pge::Shader> renderImageShader = std::static_pointer_cast<pge::Shader>(assetRenderImage);

	std::shared_ptr<pge::Asset> assetRenderMultImage;

	getScene()->getAssetManager("shader", pge::Shader::assetFactory)->getAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/renderImageMult.frag", assetRenderMultImage);

	std::shared_ptr<pge::Shader> renderImageMultShader = std::static_pointer_cast<pge::Shader>(assetRenderMultImage);

	std::shared_ptr<pge::Asset> assetNoise;

	getScene()->getAssetManager("tex2D", pge::Texture2D::assetFactory)->getAsset("resources/textures/noise.bmp", assetNoise);

	std::shared_ptr<pge::Texture2D> noiseMap = std::static_pointer_cast<pge::Texture2D>(assetNoise);

	noiseMap->bind();

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	std::shared_ptr<pge::Asset> assetBlurHorizontalEdgeAware;

	getScene()->getAssetManager("shader", pge::Shader::assetFactory)->getAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/blurHorizontalEdgeAware.frag", assetBlurHorizontalEdgeAware);

	std::shared_ptr<pge::Shader> blurShaderHorizontalEdgeAware = std::static_pointer_cast<pge::Shader>(assetBlurHorizontalEdgeAware);

	std::shared_ptr<pge::Asset> assetBlurVerticalEdgeAware;

	getScene()->getAssetManager("shader", pge::Shader::assetFactory)->getAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/blurVerticalEdgeAware.frag", assetBlurVerticalEdgeAware);

	std::shared_ptr<pge::Shader> blurShaderVerticalEdgeAware = std::static_pointer_cast<pge::Shader>(assetBlurVerticalEdgeAware);

	// SSAO

	/*std::shared_ptr<pge::Shader> ssaoShader(new pge::Shader());

	ssaoShader->createAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/imageeffects/ssao.frag");

	std::shared_ptr<pge::SceneObjectSSAO> ssao(new pge::SceneObjectSSAO());

	getRenderScene()->add(ssao, false);

	ssao->create(blurShaderHorizontal, blurShaderVertical, ssaoShader, renderImageShader, noiseMap);

	ssao->_ssaoRadius = 0.1f;
	ssao->_ssaoStrength = 1.0f;
	ssao->_blurRadius = 0.002f;
	ssao->_numBlurPasses = 1;*/

	// SSR

	std::shared_ptr<pge::TextureCube> cubeMap(new pge::TextureCube());

	cubeMap->createAsset(
		"resources/environmentmaps/skybox1/CloudyLightRaysLeft2048.png "
		"resources/environmentmaps/skybox1/CloudyLightRaysRight2048.png "
		"resources/environmentmaps/skybox1/CloudyLightRaysBack2048.png "
		"resources/environmentmaps/skybox1/CloudyLightRaysFront2048.png "
		"resources/environmentmaps/skybox1/CloudyLightRaysDown2048.png "
		"resources/environmentmaps/skybox1/CloudyLightRaysUp2048.png "
		);

	std::shared_ptr<pge::Shader> ssrShader(new pge::Shader());

	ssrShader->createAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/imageeffects/ssr.frag");

	std::shared_ptr<pge::SceneObjectSSR> ssr(new pge::SceneObjectSSR());

	getRenderScene()->add(ssr, false);

	ssr->create(blurShaderHorizontalEdgeAware, blurShaderVerticalEdgeAware, ssrShader, renderImageShader, cubeMap, noiseMap);

	ssr->_layer = 1.0f;

	// Light Scattering

	/*std::shared_ptr<pge::Shader> lightScatteringShader(new pge::Shader());

	lightScatteringShader->createAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/imageeffects/lightScattering.frag");

	std::shared_ptr<pge::SceneObjectLightScattering> lightScattering(new pge::SceneObjectLightScattering());

	getRenderScene()->add(lightScattering, false);

	lightScattering->create(blurShaderHorizontal, blurShaderVertical, lightScatteringShader, renderImageShader);

	lightScattering->_layer = 1.5f;

	lightScattering->_lightSourcePosition = -light->getDirection() * 200.0f;
	lightScattering->_lightSourceColor = pge::Vec3f(1.0f, 0.9f, 0.8f) * 0.5f;*/

	// Depth of field

	/*std::shared_ptr<pge::Shader> depthOfFieldBlurShaderHorizontal(new pge::Shader());

	depthOfFieldBlurShaderHorizontal->createAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/imageeffects/depthOfFieldBlurHorizontal.frag");

	std::shared_ptr<pge::Shader> depthOfFieldBlurShaderVertical(new pge::Shader());

	depthOfFieldBlurShaderVertical->createAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/imageeffects/depthOfFieldBlurVertical.frag");

	std::shared_ptr<pge::SceneObjectDepthOfField> depthOfField(new pge::SceneObjectDepthOfField());

	getRenderScene()->add(depthOfField, false);

	depthOfField->create(depthOfFieldBlurShaderHorizontal, depthOfFieldBlurShaderVertical, renderImageShader);

	depthOfField->_layer = 1.5f;

	depthOfField->_focalDistance = 9.0f;
	depthOfField->_focalRange = 0.4f;
	depthOfField->_blurRadius = 0.002f;
	depthOfField->_numBlurPasses = 1;*/

	// FXAA

	std::shared_ptr<pge::Shader> lumaShader(new pge::Shader());

	lumaShader->createAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/imageeffects/lumaRender.frag");

	std::shared_ptr<pge::Shader> fxaaShader(new pge::Shader());

	fxaaShader->createAsset("NONE resources/shaders/noTransformVertex.vert resources/shaders/imageeffects/fxaa.frag");

	std::shared_ptr<pge::SceneObjectFXAA> fxaa(new pge::SceneObjectFXAA());

	getRenderScene()->add(fxaa, false);

	fxaa->create(fxaaShader, lumaShader);

	destroy();
}
コード例 #16
0
ファイル: main.cpp プロジェクト: lupinix/kstars
int main(int argc, char *argv[])
{
#ifdef KSTARS_LITE
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
    QApplication app(argc, argv);

#ifdef Q_OS_OSX
    //Note, this function will return true on OS X if the data directories are good to go.  If not, quit with error code 1!
    if(!KSUtils::copyDataFolderFromAppBundleIfNeeded()){
        KMessageBox::sorry(0, i18n("Sorry, without a KStars Data Directory, KStars cannot operate. Exiting program now."));
        return 1;
    }
#endif
    app.setApplicationVersion(KSTARS_VERSION);
    /**
    * enable high dpi support
    */
     app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

    KLocalizedString::setApplicationDomain("kstars");    
#ifndef KSTARS_LITE
    KCrash::initialize();

    KAboutData aboutData( "kstars", i18n("KStars"), KSTARS_VERSION, i18n(description), KAboutLicense::GPL,
                          "2001-" + QString::number(QDate::currentDate().year()) + i18n("(c), The KStars Team"), i18n(notice), "http://edu.kde.org/kstars");
    aboutData.addAuthor(i18n("Jason Harris"), i18n("Original Author"), "*****@*****.**", "http://www.30doradus.org");
    aboutData.addAuthor(i18n("Jasem Mutlaq"), i18n("Current Maintainer"), "*****@*****.**", "http://www.indilib.org");

    // Active developers
    aboutData.addAuthor(i18n("Akarsh Simha"), QString(), "*****@*****.**", "http://www.ph.utexas.edu/~asimha");
    aboutData.addAuthor(i18n("Artem Fedoskin"), i18n("KStars Lite"), "*****@*****.**");
    aboutData.addAuthor(i18n("Robert Lancaster"), i18n("FITSViewer Improvements. KStars OSX Port"), "*****@*****.**");

    // Inactive developers
    aboutData.addAuthor(i18n("James Bowlin"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Pablo de Vicente"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Thomas Kabelmann"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Heiko Evermann"),QString(), "*****@*****.**", "http://www.evermann.de");
    aboutData.addAuthor(i18n("Carsten Niehaus"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Mark Hollomon"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Alexey Khudyakov"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("M&eacute;d&eacute;ric Boquien"), QString(), "*****@*****.**");    
    aboutData.addAuthor(i18n("J&eacute;r&ocirc;me Sonrier"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Prakash Mohan"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Victor Cărbune"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Henry de Valence"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Samikshan Bairagya"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Rafał Kułaga"), QString(), "*****@*****.**");
    aboutData.addAuthor(i18n("Rishab Arora"), QString(), "*****@*****.**");

    // Contributors
    aboutData.addCredit(i18n("Valery Kharitonov"), i18n("Converted labels containing technical terms to links to documentation") );
    aboutData.addCredit(i18n("Ana-Maria Constantin"), i18n("Technical documentation on Astronomy and KStars") );
    aboutData.addCredit(i18n("Andrew Stepanenko"), i18n("Guiding code based on lin_guider") );
    aboutData.addCredit(i18n("Nuno Pinheiro"), i18n("Artwork") );
    aboutData.addCredit(i18n("Utkarsh Simha"), i18n("Improvements to observation plan execution, star hopper etc.") );
    aboutData.addCredit(i18n("Daniel Holler"), i18n("Extensive testing and suggestions for Ekos/INDI.") );
    aboutData.addCredit(i18n("Stephane Lucas"), i18n("Extensive testing and suggestions for Ekos Scheduler.") );
    aboutData.addCredit(i18n("Yuri Fabirovsky"), i18n("Splash screen for both regular KStars and KStars Lite.") );

    KAboutData::setApplicationData(aboutData);

    QCommandLineParser parser;
    aboutData.setupCommandLine(&parser);
    parser.setApplicationDescription(aboutData.shortDescription());
    parser.addVersionOption();
    parser.addHelpOption();

    //parser.addHelpOption(INSERT_DESCRIPTION_HERE);
    parser.addOption(QCommandLineOption(QStringList() << "dump", i18n( "Dump sky image to file" )));
    parser.addOption(QCommandLineOption(QStringList() << "script ", i18n( "Script to execute" )));
    parser.addOption(QCommandLineOption(QStringList() << "width ", i18n( "Width of sky image" ),  "640"));
    parser.addOption(QCommandLineOption(QStringList() << "height ", i18n( "Height of sky image" ), "480"));
    parser.addOption(QCommandLineOption(QStringList() << "filename ", i18n( "Filename for sky image" ), "kstars.png"));
    parser.addOption(QCommandLineOption(QStringList() << "date", i18n( "Date and time" )));
    parser.addOption(QCommandLineOption(QStringList() << "paused", i18n( "Start with clock paused" )));

    // urls to open
    parser.addPositionalArgument(QStringLiteral("urls"), i18n("FITS file(s) to open."), QStringLiteral("[urls...]"));

    parser.process(app);
    aboutData.processCommandLine(&parser);

    if ( parser.isSet( "dump" ) )
    {
        qDebug() << "Dumping sky image";

        //parse filename and image format
        const char* format = "PNG";
        QString fname = parser.value( "filename" );
        QString ext = fname.mid( fname.lastIndexOf(".")+1 );
        if ( ext.toLower() == "png" ) { format = "PNG"; }
        else if ( ext.toLower() == "jpg" || ext.toLower() == "jpeg" ) { format = "JPG"; }
        else if ( ext.toLower() == "gif" ) { format = "GIF"; }
        else if ( ext.toLower() == "pnm" ) { format = "PNM"; }
        else if ( ext.toLower() == "bmp" ) { format = "BMP"; }
        else { qWarning() << i18n( "Could not parse image format of %1; assuming PNG.", fname ) ; }

        //parse width and height
        bool ok(false);
        int w(0), h(0);
        w = parser.value( "width" ).toInt( &ok );
        if ( ok ) h =  parser.value( "height" ).toInt( &ok );
        if ( !ok ) {
            qWarning() << "Unable to parse arguments: " ;
            qWarning() << "Width: " << parser.value( "width" )
                       << "  Height: " << parser.value( "height" ) << endl;
            return 1;
        }
        KStarsData *dat = KStarsData::Create();
        QObject::connect( dat, SIGNAL( progressText(QString) ), dat, SLOT( slotConsoleMessage(QString) ) );
        dat->initialize();

        //Set Geographic Location
        dat->setLocationFromOptions();

        //Set color scheme
        dat->colorScheme()->loadFromConfig();

        //set clock now that we have a location:
        //Check to see if user provided a date/time string.  If not, use current CPU time
        QString datestring = parser.value( "date" );
        KStarsDateTime kdt;
        if ( ! datestring.isEmpty() ) {
            if ( datestring.contains( "-" ) ) { //assume ISODate format
                if ( datestring.contains( ":" ) ) { //also includes time
                    //kdt = QDateTime::fromString( datestring, QDateTime::ISODate );
                    kdt = QDateTime::fromString( datestring, Qt::ISODate );
                } else { //string probably contains date only
                    //kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) );
                    kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) );
                    kdt.setTime( QTime( 0, 0, 0 ) );
                }
            } else { //assume Text format for date string
                kdt = dat->geo()->LTtoUT( QDateTime::fromString( datestring, Qt::TextDate ) );
            }

            if ( ! kdt.isValid() ) {
                qWarning() << i18n( "Using CPU date/time instead." ) ;

                kdt = KStarsDateTime::currentDateTimeUtc();
            }
        } else {
            kdt = KStarsDateTime::currentDateTimeUtc();
        }
        dat->clock()->setUTC( kdt );

        SkyMap *map = SkyMap::Create();
        map->resize( w, h );
        QPixmap sky( w, h );

        dat->setFullTimeUpdate();
        dat->updateTime(dat->geo(), map );

        SkyPoint dest( Options::focusRA(), Options::focusDec() );
        map->setDestination( dest );
        map->destination()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() );
        map->setFocus( map->destination() );
        map->focus()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() );

        //Execute the specified script
        QString scriptfile = parser.value( "script" );
        if ( ! scriptfile.isEmpty() ) {
            if ( dat->executeScript( scriptfile, map ) ) {
                std::cout << i18n( "Script executed." ).toUtf8().data() << std::endl;
            } else {
                qWarning() << i18n( "Could not execute script." ) ;
            }
        }

        qApp->processEvents();
        map->setupProjector();
        map->exportSkyImage( &sky );
        qApp->processEvents();

        if ( ! sky.save( fname, format ) )
            qWarning() << "Unable to save image: " << fname;
        else
            qDebug() << "Saved to file: %1" << fname;

        delete map;
        delete dat;
        return 0;
    }

    //Try to parse the given date string
    QString datestring = parser.value( "date" );

    if ( ! datestring.isEmpty() && ! KStarsDateTime::fromString( datestring ).isValid() )
    {
        qWarning() << i18n( "Using CPU date/time instead." ) ;
        datestring.clear();
    }

#endif
    // Create writable data dir if it does not exist
    QDir writableDir;
    writableDir.mkdir(KSPaths::writableLocation(QStandardPaths::GenericDataLocation));
#ifndef KSTARS_LITE

    KStars::createInstance( true, ! parser.isSet( "paused" ), datestring );

    // no session.. just start up normally
    const QStringList urls = parser.positionalArguments();

    // take arguments
    if( ! urls.isEmpty() )
    {
        foreach (const QString &url, urls) {
            const QUrl u = QUrl::fromUserInput(url, QDir::currentPath());
            KStars::Instance()->openFITS(u);
        }
    }
コード例 #17
0
void TRACKS()
{


		sky();

		tree_one();
		tree_one_body();
		tree_two();
		tree_two_body();
		wall();
		platform();
		//quad();
		woman();
        resting();
        home();

		/*body_one();
		window_one();
		c_one();

		body_two();
		window_two();
		door_one();
		c_two();

		body_three();
        window_three();
		door_two();
		c_three();

		body_four();
		window_four();
		door_three();*/

//
        glBegin(GL_LINES);// samner lomba line
		glColor3f(0.0,0.0,0.0);
		glVertex2f(0,85);
		glVertex2f(999,85);
		glVertex2f(999,84);
		glVertex2f(0,84);

        glVertex2f(0,82);
		glVertex2f(999,82);
		glVertex2f(999,78);
		glVertex2f(0,78);

		glVertex2f(0,147);
		glVertex2f(999,147);
		glVertex2f(999,148);
		glVertex2f(0,148);


		glVertex2f(0,152);
		glVertex2f(999,152);
		glVertex2f(0,150);
		glVertex2f(999,150);

	glEnd();
	quad();


		/** boundery strt **/
	/*	glBegin(GL_LINES);// samner boundery
		glColor3f(0.0,0.0,0.0);
		glVertex2f(0,300);
		glVertex2f(1000,300);
		glVertex2f(0,297);
		glVertex2f(1000,297);



		glColor3f(0.0,0.0,0.0);//boundery samner
		glVertex2f(0,295);
		glVertex2f(1000,295);
		glVertex2f(0,293);
		glVertex2f(1000,293);

		glColor3f(0.0,0.0,0.0);
		glVertex2f(0,400);
		glVertex2f(1000,400);
		glVertex2f(0,397);
		glVertex2f(1000,397);

        glColor3f(.1111,.10,.0);
		glVertex2f(0,395);
		glVertex2f(1000,395);
		glVertex2f(0,393);
		glVertex2f(1000,393);


        glColor3f(.1111,.10,.0);
		glVertex2f(0,304);
		glVertex2f(1000,304);

		glVertex2f(0,305);
		glVertex2f(1000,305);// samner railline shes


// sliper
		while(c!=1000)
		{
			glVertex2f(c,d);
			glVertex2f(c,d+120);
			c+=10;
		}
		glEnd();*/

		/** boundery finish **/


}
コード例 #18
0
ファイル: main.cpp プロジェクト: STyfy/flight_final_edition
int main()
{


    sf::RenderWindow window(sf::VideoMode(480,800), "SFML works!");

    sf::Texture sky_texture;
    if (!sky_texture.loadFromFile("background.png",sf::IntRect(0,0,480,800)))
        return EXIT_FAILURE;
    sf::Sprite sky(sky_texture);

    sf::Texture player_texture;
    if (!player_texture.loadFromFile("shoot.png",sf::IntRect(0,100,103,133)))
        return EXIT_FAILURE;
    sf::Sprite player_sprite(player_texture);
    player_sprite.setPosition(sf::Vector2f(200, 600));
    x=200;
    y=600;

    sf::Texture forpowerup;
    if (!forpowerup.loadFromFile("shoot.png",sf::IntRect(266,398,62,88)))
        return EXIT_FAILURE;
    sf::Sprite powerup(forpowerup);

    sf::Texture enemy_texture;
    if (!enemy_texture.loadFromFile("shoot.png",sf::IntRect(0,0,68,100)))
        return EXIT_FAILURE;
    sf::Sprite enemy_sprite(enemy_texture);

    sf::Texture destroy1;
    if (!destroy1.loadFromFile("shoot.png",sf::IntRect(532,650,68,100)))
        return EXIT_FAILURE;
    sf::Sprite spdestroy1(destroy1);

    sf::Texture destroy2;
    if (!destroy2.loadFromFile("shoot.png",sf::IntRect(605,650,68,100)))
        return EXIT_FAILURE;
    sf::Sprite spdestroy2(destroy2);

    sf::Texture destroy3;
    if (!destroy3.loadFromFile("shoot.png",sf::IntRect(670,650,68,100)))
        return EXIT_FAILURE;
    sf::Sprite spdestroy3(destroy3);

    sf::Texture destroy4;
    if (!destroy4.loadFromFile("shoot.png",sf::IntRect(740,650,68,100)))
        return EXIT_FAILURE;
    sf::Sprite spdestroy4(destroy4);

    sf::Texture you1;
    if (!you1.loadFromFile("shoot.png",sf::IntRect(166,236,103,120)))
        return EXIT_FAILURE;
    sf::Sprite dyou1(you1);

    sf::Texture you2;
    if (!you2.loadFromFile("shoot.png",sf::IntRect(330,626,103,120)))
        return EXIT_FAILURE;
    sf::Sprite dyou2(you2);

    sf::Texture you3;
    if (!you3.loadFromFile("shoot.png",sf::IntRect(330,500,103,120)))
        return EXIT_FAILURE;
    sf::Sprite dyou3(you3);


    sf::SoundBuffer bgm;
    if (!bgm.loadFromFile("game_music.ogg"))
        return -1;
    sf::Sound bgm1;
    bgm1.setBuffer(bgm);
    bgm1.play();

    sf::SoundBuffer enemydown;
    if (!enemydown.loadFromFile("enemy1_down.ogg"))
        return -1;
    sf::Sound enemydown1;
    enemydown1.setBuffer(enemydown);

    sf::SoundBuffer _player_down;
    if (!_player_down.loadFromFile("youdown.ogg"))
        return -1;
    sf::Sound player_down;
    player_down.setBuffer(_player_down);

    sf::Texture player_bullet_texture;
    if (!player_bullet_texture.loadFromFile("shoot.png",sf::IntRect(69,78,10,22)))
        return -1;
    sf::Sprite player_bullet_sprite(player_bullet_texture);

    sf::Texture enemy_bullet_texture;
    if (!enemy_bullet_texture.loadFromFile("shoot.png",sf::IntRect(1002,990,10,22)))
        return -1;
    sf::Sprite enemy_bullet_sprite(enemy_bullet_texture);

    //¼ÓÔØ×ÖÌåÎļþ
    sf::Font font;
    if (!font.loadFromFile("score.ttf"))
    return -1;

    sf::Text showscore;
    showscore.setFont(font);
    showscore.setString(scorestr);
    showscore.setCharacterSize(40);
    showscore.setColor(sf::Color::White);

    sf::Text text;
    text.setFont(font);
    text.setString("Score");
    text.setCharacterSize(40);
    text.setColor(sf::Color::White);

    sf::Text die;
    die.setFont(font);
    die.setCharacterSize(22);
    die.setString("You life:2/3,press Tab to continue");
    die.setColor(sf::Color::White);

    sf::Text gg;
    gg.setFont(font);
    gg.setCharacterSize(40);
    gg.setString("GAME  OVER");
    gg.setColor(sf::Color::Red);





    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.draw(sky);
        if (youlive>0)
        {
        if (destroyyou==0)
        {
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)&&x<380)
            {
                player_sprite.move(.5,0);
                x+=0.5;
            }
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)&&x>0)
            {
                player_sprite.move(-.5,0);
                x-=0.5;
            }
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)&&y>0)
            {
                player_sprite.move(0,-.5);
                y-=0.5;
            }
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)&&y<660)
            {
                player_sprite.move(0,.5);
                y+=0.5;
            }
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
            {
                bullet_f_control();

            }

                window.draw(player_sprite);
        }
        for (i=1;i<=100;i++)
                {
                    if (bullet_is[i]==1)
                    {
                            bullet_y[i]-=0.7;
                            bullet_x[i]+=bullet_limit[i]*0.3;
                            if (bullet_y[i]<0) bullet_is[i]=0;
                            else
                                {
                                    player_bullet_sprite.setPosition(bullet_x[i],bullet_y[i]);
                                    window.draw(player_bullet_sprite);
                                }
                    }
                }

        feplaneshot++;
        if (feplaneshot==enemy_occur_often(score))
        {
            if (enemy_bullet_is[o]==0)
                                {
                                    for (i=1;i<=100;i++)
                                    {
                                        if (enemy_exist[i]==1)
                                        {
                                            k++;
                                            if (k==3)
                                            {
                                            enemy_bullet_is[o]=1;
                                            enemy_bullet_x[o]=enemy_x[i]+32;
                                            enemy_bullet_y[o]=enemy_y[i]+100;
                                            enemy_bullet_length[o]=0;
                                            o++;
                                            k=1;
                                            }
                                        }
                                    }

                                }
            if (o>=500) o=1;
            feplaneshot=1;
        }
        for (i=1;i<=500;i++)
                {
                    if (enemy_bullet_is[i]==1)
                    {
                            enemy_bullet_y[i]+=0.4;
                            enemy_bullet_x[i]+=enemy_bullet_length[i]*0.5;
                            if (enemy_bullet_y[i]>800)
                                enemy_bullet_is[i]=0;
                            else
                                {
                                    enemy_bullet_sprite.setPosition(enemy_bullet_x[i],enemy_bullet_y[i]);
                                    window.draw(enemy_bullet_sprite);

                                }
                    }
                }

        tforplane++;
        if (tforplane==enemy_occur_often(score))
         {
            enemy_number++;
            if (enemy_exist[enemy_number]==0)
             {
                enemy_exist[enemy_number]=1;
                enemy_y[enemy_number]=0;
                enemy_x[enemy_number]=rand()%380;
                enemy_life[enemy_number]=1+score/100;
             }
            if (enemy_number==50) enemy_number=1;
                tforplane=1;
         }
        for (j=1;j<=50;j++)
        {
            if (enemy_exist[j]==1)
            {
               enemy_y[j]+=0.2;
               if (enemy_y[j]>800)
               enemy_exist[j]=0;
               else
               {
                  enemy_sprite.setPosition(enemy_x[j],enemy_y[j]);
                  window.draw(enemy_sprite);
               }
            }
        }
        for (i=1;i<=50;i++)
            for (j=1;j<=100;j++)
            {
                if (enemy_exist[i]==1&&bullet_is[j]==1&&enemy_y[i]<bullet_y[j]&&bullet_y[j]<enemy_y[i]+100&&enemy_x[i]<bullet_x[j]&&bullet_x[j]<enemy_x[i]+68)
                {
                    enemy_life[i]--;
                    bullet_is[j]=0;
                    if (enemy_life[i]==0)
                        {
                             enemy_exist[i]=0;
                             score+=10;
                             sprintf(scorestr,"%d",score+score2);
                             showscore.setString(scorestr);

                             if (destroy==0)
                             {
                             destroyx=enemy_x[i];
                             destroyy=enemy_y[i];
                             destroy=1;
                             }
                             else
                             {
                                 destroyxadd=enemy_x[i];
                                 destroyyadd=enemy_y[i];
                                 destroyadd=1;
                             }
                        }
                }
            }
        for (i=1;i<=50;i++)
        {
            if (enemy_exist[i]==1&&enemy_x[i]+18>x&&x+53>enemy_x[i]&&enemy_y[i]+70>y&&y+103>enemy_y[i]&&destroyyou==0)
            {
                youlive--;
                enemy_exist[i]=0;
                if (destroy==0)
                {
                    destroyx=enemy_x[i];
                    destroyy=enemy_y[i];
                    destroy=1;
                }
                else
                {
                    destroyxadd=enemy_x[i];
                    destroyyadd=enemy_y[i];
                    destroyadd=1;
                }
                destroyyou=1;
                destroyyoux=x;
                destroyyouy=y;

            }
        }
         for (i=1;i<=500;i++)
        {
            if (enemy_bullet_is[i]==1&&enemy_bullet_x[i]>x+31&&enemy_bullet_x[i]<x+71&&enemy_bullet_y[i]>y+37&&enemy_bullet_y[i]<y+97&&destroyyou==0)
            {
                youlive--;
                enemy_bullet_is[i]=0;
                destroyyou=1;
                destroyyoux=x;
                destroyyouy=y;

            }
        }
        if (destroyyou==1)
        {
            g++;
            if (g<=200)
                {
                    dyou1.setPosition(destroyyoux,destroyyouy);
                    window.draw(dyou1);
                    player_down.play();
                }
            if (g>200&&g<=400)
                {
                    dyou2.setPosition(destroyyoux,destroyyouy);
                    window.draw(dyou2);
                }
            if (g>400&&g<600)
                {
                    dyou3.setPosition(destroyyoux,destroyyouy);
                    window.draw(dyou3);
                }
            if (g>600)
            {
            die.setPosition(15,380);
            window.draw(die);
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Tab))
            {
            player_sprite.setPosition(sf::Vector2f(200, 600));x=200;y=600;
            fuckpower=1;
            destroyyou=0;
            g=1;
            }
            }
        }
        if (destroy==1)
        {
        d++;
        if (d<=200)
            {
                spdestroy1.setPosition(destroyx,destroyy);
                window.draw(spdestroy1);
                enemydown1.play();
            }
        if (d>200&&d<=400)
            {
                spdestroy2.setPosition(destroyx,destroyy);window.draw(spdestroy2);}
        if (d>400&&d<600) {spdestroy3.setPosition(destroyx,destroyy);window.draw(spdestroy3);}
        if (d>=600&&d<800) {spdestroy4.setPosition(destroyx,destroyy);window.draw(spdestroy4);}
        if (d==800) {d=1;destroy=0;}
        }
         if (destroyadd==1)
        {
           d2++;
           if (d2<=200)
            {
                spdestroy1.setPosition(destroyxadd,destroyyadd);
                window.draw(spdestroy1);
                enemydown1.play();
            }
           if (d2>200&&d2<=400)
           {
                spdestroy2.setPosition(destroyxadd,destroyyadd);
                window.draw(spdestroy2);
           }
           if (d2>400&&d2<600)
           {
               spdestroy3.setPosition(destroyxadd,destroyyadd);
               window.draw(spdestroy3);
           }
           if (d2>=600&&d2<800)
            {
                spdestroy4.setPosition(destroyxadd,destroyyadd);
                window.draw(spdestroy4);
           }
        if (d2==800)
            {
                d2=1;
                destroyadd=0;
            }
       }
         text.setPosition(20,20);
         showscore.setPosition(50,60);
         window.draw(text);
         window.draw(showscore);
      }
        else
            {
                gg.setPosition(145,320);
                window.draw(gg);
            }
    window.display();
    }
    return 0;
}