Example #1
0
void GLLogic::RenderScene()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glRotatef(m_rotX, 1.f, 0.f, 0.f);
	glRotatef(m_rotY, 0.f, 1.f, 0.f);
	glTranslatef(0.f, 0.f, -100.f);
	
	//가운데공
	DrawPlanet(m_planets[EARTH_IDX], m_texIds[EARTH_IDX], 20);
	
	//오른공	
	glPushMatrix(); //가운데공에서 시작
	glRotatef(m_rotPlanet, 0.f, 1.f, 0.f); //오른쪽으로 회전
	glTranslatef(90.f, 0.f, 0.f); //회전한 상태에서 오른쪽으로 이동
	DrawPlanet(m_planets[VENUS_IDX], m_texIds[VENUS_IDX], 12);
	
	//위성 공
	glPushMatrix(); //오른공에서 시작
	glRotatef(m_rotPlanet, 0.f, 1.f, 1.f);
	glTranslatef(30.f, 0.f, 0.f);
	DrawPlanet(m_planets[SILVA_IDX], m_texIds[SILVA_IDX], 9);
	glPopMatrix();
	
	glPopMatrix();

	glutSwapBuffers();
}
Example #2
0
static void
DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode)
{
	RECT r;

	SetContext (SpaceContext);
	GetContextClipRect (&r);

	BatchGraphics ();
	
	if (Mode != DRAW_ORBITAL_UPDATE)
	{
		SetTransitionSource (NULL);

		DrawSISFrame ();
		DrawSISMessage (NULL);
		DrawSISTitle (GLOBAL_SIS (PlanetName));
		DrawStarBackGround ();
		DrawPlanetSurfaceBorder ();
	}

	if (Mode == DRAW_ORBITAL_WAIT)
	{
		STAMP s;

		SetContext (GetScanContext (NULL));
		s.frame = CaptureDrawable (LoadGraphic (ORBENTER_PMAP_ANIM));
		s.origin.x = -SAFE_X;
		s.origin.y = 0;
		DrawStamp (&s);
		DestroyDrawable (ReleaseDrawable (s.frame));
	}
	else if (Mode == DRAW_ORBITAL_FULL)
	{
		DrawDefaultPlanetSphere ();
	}

	if (Mode != DRAW_ORBITAL_WAIT)
	{
		SetContext (GetScanContext (NULL));
		DrawPlanet (0, BLACK_COLOR);
	}

	if (Mode != DRAW_ORBITAL_UPDATE)
	{
		ScreenTransition (3, &r);
	}

	UnbatchGraphics ();

	// for later RepairBackRect()
	// JMS_GFX
	if (RESOLUTION_FACTOR == 0)
		LoadIntoExtraScreen (&r);
	else
		LoadIntoExtraScreen_Fs (&r);
}
Example #3
0
static void
DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode)
{
    RECT r = { { SIS_ORG_X, SIS_ORG_Y },
        { SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT }
    };

    BatchGraphics ();

    if (Mode != DRAW_ORBITAL_UPDATE)
    {
        SetTransitionSource (NULL);

        DrawSISFrame ();
        DrawSISMessage (NULL_PTR);
        DrawSISTitle (GLOBAL_SIS (PlanetName));
        DrawStarBackGround (TRUE);
    }

    SetContext (SpaceContext);

    if (Mode == DRAW_ORBITAL_WAIT)
    {
        STAMP s;

        s.frame = CaptureDrawable (
                      LoadGraphic (ORBENTER_PMAP_ANIM));
        s.origin.x = -SAFE_X;
        s.origin.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT;
        DrawStamp (&s);
        DestroyDrawable (ReleaseDrawable (s.frame));
    }
    else
    {
        DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH,
                    SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0);
    }

    if (Mode != DRAW_ORBITAL_UPDATE)
    {
        ScreenTransition (3, &r);
    }

    UnbatchGraphics ();

    if (Mode != DRAW_ORBITAL_WAIT)
    {
        LoadIntoExtraScreen (&r);
    }
}
Example #4
0
DrawPlanets()
/*
 *  Draw all the planets
 */
{
	int p;

	/* Draw orbits */
	if (draw_orbits) DrawOrbits();

	for (p=0; p<NPLANETS; p++)
	{
		if (!planet[p].hidden) DrawPlanet (p);
	}
}
Example #5
0
void TWorldDisplay::Draw(QPainter& painter) {
    Ang += 1.0;

    if (World->RoundStartsAt != uint8_t(-1)) {
        DrawRoundRestart(painter, World->RoundStartsAt);
    } else if (World->WaitingPlayers) {
        DrawWaitingPlayers(painter);
    } else {
        for (size_t i = 0; i < World->Planets.size(); ++i) {
            DrawPlanet(painter, World->Planets[i]);
        }
        for (size_t i = 0; i < World->Ships.size(); ++i) {
            DrawShip(painter, World->Ships[i]);
        }
        DrawPower(painter);
        DrawSelection(painter);
    }
}
Example #6
0
void DrawUranus()
{
	DrawPlanet(urn);

	return;
}
Example #7
0
void DrawSaturn()
{
	DrawPlanet(sat);

	return;
}
Example #8
0
void DrawJupiter()
{
	DrawPlanet(jup);

	return;
}
Example #9
0
void DrawMars()
{
	DrawPlanet(mars);

	return;
}
Example #10
0
void DrawEarth()
{
	DrawPlanet(ear);

	return;
}
Example #11
0
void DrawVenus()
{
	DrawPlanet(ven);

	return;
}
Example #12
0
/*
 *  Draw the solar system
 */
static void SolarSystem()
{
   int k;

   //  Set up lighting
   float black[]   = {0.0 , 0.0 , 0.0 , 1.0};
   float white[]   = {1.0 , 1.0 , 1.0 , 1.0};
   float pos[]     = {0.0 , 0.0 , 0.0 , 1.0};
   glEnable(GL_NORMALIZE);
   glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
   glEnable(GL_COLOR_MATERIAL);
   glEnable(GL_LIGHT0);
   glLightModelfv(GL_LIGHT_MODEL_AMBIENT,black);
   glLightfv(GL_LIGHT0,GL_AMBIENT ,black);
   glLightfv(GL_LIGHT0,GL_DIFFUSE ,white);
   glLightfv(GL_LIGHT0,GL_SPECULAR,black);
   glLightfv(GL_LIGHT0,GL_POSITION,pos);

   //  Draw the sun and planets
   for (k=0;k<=9;k++)
   {
      //  Copy variables to simplify expresions
      double i = planet[k].i;  //  Inclination
      double o = planet[k].o;  //  Longitude of Ascending Node
      double p = planet[k].p;  //  Longitude of Perihelion
      double a = planet[k].a;  //  Mean distance (AU)
      double n = planet[k].n;  //  Daily modtion
      double e = planet[k].e;  //  Eccentricity
      double l = planet[k].l;  //  Mean longitude

      //  Radius of planet (AU)
      double r = 6.7e-9*planet[k].R;  //  Radius (km->AU)
      if (mode<0 && mag>0) r *= mag;  //  Magnification
      if (r>0.3) r = 0.3;             //  Limit maximum size

      //  Apply keplerian elements to determine orbit
      glPushMatrix();
      if (k>0)
      {
         //  Calculate true anomaly
         double M = fmod(day*n+l-p,TWOPI); //  Mean anomaly in radians
         double delta;
         double v = M;
         do
         {
            delta = v - e*sin(v) - M;
            v -= delta/(1-e*cos(v));
         } while (fabs(delta)>1e-12);
         //  True anomaly
         v = 2*atan(sqrt((1+e)/(1-e))*tan(0.5*v));
         double R = a*(1-e*e)/(1+e*cos(v)); //  Orbit radius (AU)
         double h = v + p - o;              //  Elliptical angle
         //  Compute and apply location
         double x = R * (cos(o)*cos(h) - sin(o)*sin(h)*cos(i));
         double y = R * (sin(o)*cos(h) + cos(o)*sin(h)*cos(i));
         double z = R *                        (sin(h)*sin(i));
         glTranslated(x,y,z);
      }

      //  Transform and draw planet
      glPushMatrix();
      glRotated(planet[k].th,1,0,0);           //  Declination
      glRotated(360*day/planet[k].rot,0,0,1);  //  Siderial rotation
      glScaled(r,r,r);                         //  Radius of planet
      if (k>0 && light) glEnable(GL_LIGHTING); //  Lighting for planets
      DrawPlanet(k);                           //  Draw planet
      glPopMatrix();

      //  Draw the moon relative to earth
      if (k==3)
      {
         double R = 1.5*r>planet[10].a ? 1.5*r : planet[10].a;
         glPushMatrix();
         glRotated(360*day/planet[10].rot,0,0,1); //  Siderial rotation and orbit is the same
         glTranslated(R,0,0);                     //  Orbital radius
         r *= planet[10].R/planet[k].R;           //  Adjust radius
         glScaled(r,r,r);
         DrawPlanet(10);                          //  Draw planet
         glPopMatrix();
      }
      glPopMatrix();
      glDisable(GL_LIGHTING);

      //  Draw orbit
      if (orbit)
      {
         double v;
         glColor3f(0.3,0.3,0.3);
         glBegin(GL_LINE_LOOP);
         for (v=0;v<TWOPI;v+=0.01)
         {
            double R = a*(1-e*e)/(1+e*cos(v));
            double h = v + p - o;
            double x = R * (cos(o)*cos(h) - sin(o)*sin(h)*cos(i));
            double y = R * (sin(o)*cos(h) + cos(o)*sin(h)*cos(i));
            double z = R *                        (sin(h)*sin(i));
            glVertex3d(x,y,z);
         }
         glEnd();
      }
   }
}
Example #13
0
//-----------------------------------------------------------------------------------
// レンダリング
//-----------------------------------------------------------------------------------
void display(void)
{
    // クロックの更新
    clock_pre = clock_now;
    clock_now = get_clock_now();

    // 1秒で1日分動くとする
    if( flg_play )
        day += (clock_now - clock_pre);

    // フレームバッファのクリア
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // 視点の設定
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0.0, 0.0, distance, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
    glRotatef( -pitch, 1.0, 0.0, 0.0 );
    glRotatef( -yaw, 0.0, 1.0, 0.0 );

    // 惑星の軌道を描く
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_default_color);
    glMaterialfv(GL_FRONT, GL_AMBIENT, mat_default_color);
    DrawCircle( orbit_radius_earth );
    //惑星を描く
    glPushMatrix();
    {
        // 太陽
        glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_sun);
        glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_sun);

        glPushMatrix();
        {
            // 太陽の自転の計算式
            glRotatef (  day * rot_vel_sun , 0.0, 1.0, 0.0);
            DrawPlanet( radius_sun );
        }
        glPopMatrix();

        // 水星
        glPushMatrix();
        {
            glRotatef (  day * rev_vel_mercury, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_mercury, 0.0, 0.0); 
            glRotatef (  day * rot_vel_mercury, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_mercury); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_mercury); 
            DrawPlanet( planet_radius_mercury );
        }
        glPopMatrix();

        // 金星
        glPushMatrix();
        {
            glRotatef (  day * rev_vel_venus, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_venus, 0.0, 0.0); 
            glRotatef (  day * rot_vel_venus, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_venus); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_venus); 
            DrawPlanet( planet_radius_venus );
        }
        glPopMatrix();

        // 地球
        glPushMatrix();
        {
            glRotatef (  day * rev_vel_earth, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_earth, 0.0, 0.0); 
            glRotatef (  day * rot_vel_earth, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_earth); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_earth); 
            DrawPlanet( planet_radius_earth );

            // 月
            glPushMatrix();
            {
                glRotatef (  day * rev_vel_moon, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_moon, 0.0, 0.0); 
                glRotatef (  day * rot_vel_moon, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_moon); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_moon); 
                DrawPlanet( planet_radius_moon );
            }
            glPopMatrix();
        }
        glPopMatrix();

        //火星
        glPushMatrix();
        {
            glRotatef (  day * rev_vel_mars, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_mars, 0.0, 0.0); 
            glRotatef (  day * rot_vel_mars, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_mars); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_mars); 
            DrawPlanet( planet_radius_mars );
        }
        glPopMatrix();
    }
    glPopMatrix();

    glutSwapBuffers();
}
Example #14
0
/*
 *  OpenGL (GLUT) calls this routine to display the scene
 */
void display()
{
   //  Length of axes
   const double len=1.2;
   //  Eye position
   double Ex = -2*dim*Cos(ph);
   double Ey = +2*dim*Sin(ph);
   double Ez = 0;
   //  Erase the window and the depth buffer
   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
   //  Set perspective
   glLoadIdentity();
   gluLookAt(Ex,Ey,Ez , 0,0,0 , 0,Cos(ph),0);
   //  Draw scene
   glEnable(GL_DEPTH_TEST);
   //  Rotate Z up
   glRotated(-90,1,0,0);

   /*
    * Draw solar system
    */
   if (mode<0)
   {
      glRotated(th,0,0,1);  //  View angle
      SolarSystem();
   }
   /*
    *  Draw planet
    */
   else
   {
      glRotated(th,1,0,0);  // Declination
      glRotated(zh,0,0,1);  // Spin around axes
      DrawPlanet(mode);
   }

   /*
    *  Draw axes - no textures from here
    */
   glColor3f(1,1,1);
   if (axes)
   {
      glBegin(GL_LINES);
      glVertex3d(0.0,0.0,0.0);
      glVertex3d(len,0.0,0.0);
      glVertex3d(0.0,0.0,0.0);
      glVertex3d(0.0,len,0.0);
      glVertex3d(0.0,0.0,0.0);
      glVertex3d(0.0,0.0,len);
      glEnd();
      //  Label axes
      glRasterPos3d(len,0.0,0.0);
      Print("X");
      glRasterPos3d(0.0,len,0.0);
      Print("Y");
      glRasterPos3d(0.0,0.0,len);
      Print("Z");
   }
   //  Display parameters
   glWindowPos2i(5,5);
   Print("Angle=%d,%d  Dim=%.1f Object=%s",th,ph,2*dim,mode<0?"Solar System":planet[mode].name);
   if (mode<0) Print(" Magnification %d Year %.1f",mag,2000+day/365.25);
   //  Render the scene and make it visible
   ErrCheck("display");
   glFlush();
   glutSwapBuffers();
}
Example #15
0
void DrawNeptune()
{
	DrawPlanet(nep);

	return;
}
Example #16
0
void DrawPluto()
{
	DrawPlanet(plu);

	return;
}
Example #17
0
void DrawMercury()
{
	DrawPlanet(merc);

	return;
}