void Layer::draw() { Electron* electron; for (auto it = electrons.begin(); it != electrons.end(); it++) { electron = &(*it); drawOrbit(electron->getOrbitAngle()); electron->draw(); } }
//최종 그리기 함수 void entireDrawing() { if(GridToggle) drawGrid(); if(OrbitToggle) drawOrbit(); drawSolarSystem(planets); }
void TleTraj::draw(const StelCore *core, StelPainter& painter) { Vec3d pos; satd2StelCoord(curData, pos); XYZ = core->altAzToJ2000(pos); Vec3d xy; if (painter.getProjector()->project(pos, xy)) { glEnable(GL_TEXTURE_2D); glColor3f(orbitColor->redF(), orbitColor->greenF(), orbitColor->blueF()); hintTexture->bind(); painter.drawSprite2dMode(xy[0], xy[1], 16); glDisable(GL_TEXTURE_2D); drawOrbit(painter); } }
void display( void ){ glutSetWindow(window); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor3f( 1.0, 1.0, 1.0 ); /* Set up where the projection */ setUserView( ); // Rotate glRotatef(angle, 0.0, 1.0, 0.0); /* Draw the scene into the back buffer */ drawScene( ); // Draw Revolver glPushMatrix(); glTranslatef(0.0, 0.0,-3.0); glScalef(0.3,0.3,0.3); drawOrbit( ); glPopMatrix(); /* Swap the front buffer with the back buffer - assumes double buffering */ glutSwapBuffers( ); }
void drawScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glLoadIdentity(); gluLookAt(camera.x, camera.y, camera.z, 0, 0, 0, 0, 1, 0); glMatrixMode(GL_MODELVIEW); drawStars(); glLightfv(GL_LIGHT0, GL_AMBIENT, light1_ambient); glLightfv(GL_LIGHT0, GL_SPECULAR, light1_specular); // Draw the sun glLightfv(GL_LIGHT0, GL_POSITION, spotPos); glDisable(GL_LIGHTING); glPushMatrix(); glColor3f(1, 1, 0.2); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, aMaterial); glutSolidSphere(2, 30, 30); glPopMatrix(); glEnable(GL_LIGHTING); // Draw Mercury glColor3f(0.8, 0.4, 0.0); drawOrbit(3, 7); glPushMatrix(); glRotatef(3, 1, 0, 0); glPushMatrix(); glColor3f(0.8, 0.4, 0.0); glRotatef(t * 0.047, 0,1, 0); glTranslatef(0, 0, 7); drawString(0, 0, 0, "Mercury"); glutSolidSphere(0.3, RES_PLANET, RES_PLANET); glPopMatrix(); glPopMatrix(); // Draw Venus glColor3f(0.28, 0.46, 1.0); drawOrbit(9, 10); glPushMatrix(); glRotatef(9,1, 0, 0); glPushMatrix(); glColor3f(0.28, 0.46, 1.0); glRotatef(t * 0.035, 0, 1, 0); glTranslatef(0, 0, 10); drawString(0, 0, 0, "Venus"); glutSolidSphere(0.7, RES_PLANET, RES_PLANET); glPopMatrix(); glPopMatrix(); // Draw The Earth glColor3f(0.15, 0.25, 0.54); drawOrbit(8, 13); glPushMatrix(); glRotatef(8, 1, 0, 0); glPushMatrix(); glColor3f(0.15, 0.25, 0.54); glRotatef(t * 0.029, 0, 1, 0); glTranslatef(0, 0, 13); drawString(0, 0, 0, "Earth"); glutSolidSphere(0.7, RES_PLANET, RES_PLANET); glPopMatrix(); glPopMatrix(); // Draw Mars glColor3f(1, 0.0, 0.0); drawOrbit(5, 16); glPushMatrix(); glRotatef(5, 1, 0, 0); glPushMatrix(); glColor3f(1, 0.0, 0.0); glRotatef(t * 0.024, 0, 1, 0); glTranslatef(0, 0, 16); drawString(0, 0, 0, "Mars"); glutSolidSphere(0.6, RES_PLANET, RES_PLANET); glPopMatrix(); glPopMatrix(); // Draw Jupiter glColor3f(0.8, 0.58, 0.047); drawOrbit(8, 24); glPushMatrix(); glRotatef(8, 1, 0, 0); glPushMatrix(); glColor3f(0.8, 0.58, 0.047); glRotatef(t * 0.013, 0, 1, 0); glTranslatef(0, 0, 24); drawString(0, 0, 0, "Jupiter"); glutSolidSphere(1.2, RES_PLANET,RES_PLANET); glPopMatrix(); glPopMatrix(); // Draw Saturn glColor3f(0.8, 0.58, 0.047); drawOrbit(5, 30); glPushMatrix(); glRotatef(5, 1, 0, 0); glPushMatrix(); glColor3f(0.6, 0.4, 0.030); glRotatef(t * 0.009, 0, 1, 0); glTranslatef(0, 0, 30); glRotatef(90, 1, 0.5, 0); glScalef(1, 1, 0.1); glutSolidTorus(0.6, 1.8, 5, 50); glPopMatrix(); glPushMatrix(); glColor3f(0.8, 0.58, 0.047); glRotatef(t * 0.009, 0, 1, 0); glTranslatef(0, 0, 30); drawString(0, 0, 0, "Saturn"); glutSolidSphere(1, RES_PLANET, RES_PLANET); glPopMatrix(); glPopMatrix(); // Draw Uranus glColor3f(0, 0.1, 1); drawOrbit(7, 40); glPushMatrix(); glRotatef(7, 1, 0, 0); glPushMatrix(); glColor3f(0, 0.1, 1); glRotatef(t * 0.006, 0, 1, 0); glTranslatef(0, 0, 40); glRotatef(3, 1, 0.5, 0); glScalef(1, 1, 0.1); glutSolidTorus(0.1, 1, 5, 50); glPopMatrix(); glPushMatrix(); glColor3f(0, 0.6, 0.8); glRotatef(t * 0.006, 0, 1, 0); glTranslatef(0, 0, 40); drawString(0, 0, 0, "Uranus"); glutSolidSphere(0.7, RES_PLANET, RES_PLANET); glPopMatrix(); glPopMatrix(); // Draw Neptune glColor3f(0.0, 0.89, 0.93); drawOrbit(8, 48); glPushMatrix(); glRotatef(8, 1, 0, 0); glPushMatrix(); glColor3f(0.0, 0.89, 0.93); glRotatef(t * 0.005, 0, 1, 0); glTranslatef(0, 0, 48); drawString(0, 0, 0, "Neptune"); glutSolidSphere(0.7, RES_PLANET, RES_PLANET); glPopMatrix(); glPopMatrix(); // Almost forgot, let's draw the Moon! glPushMatrix(); glRotatef(8,1,0,0); glPushMatrix(); glColor3f(0.7,0.8,0.8); glRotatef(t*0.029,0,1,0); glTranslatef(0,0,13); glPushMatrix(); glRotatef(t*0.348,0,1,0); glTranslatef(0,0,1.3); glutSolidSphere(0.1,RES_PLANET,10); glPopMatrix(); glPopMatrix(); glPopMatrix(); //Sorry Pluto, you're not a planet anymore :( // Meteors drawMeteors(); if (a < -500) { a = -20; } glutSwapBuffers(); }
// Draw the Comet and all the related infos : name, circle etc... GZ: Taken from Planet.cpp 2013-11-05 and extended void Comet::draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont) { if (hidden) return; if (getEnglishName() == core->getCurrentLocation().planetName) { // GZ moved this up. Maybe even don't do that? E.g., draw tail while riding the comet? Decide later. return; } // The CometOrbit is in fact available in userDataPtr! CometOrbit* orbit=(CometOrbit*)userDataPtr; Q_ASSERT(orbit); if (!orbit->objectDateValid(core->getJDay())) return; // out of useful date range. This allows having hundreds of comet elements. if (orbit->getUpdateTails()){ // Compute lengths and orientations from orbit object, but only if required. // TODO: This part should possibly be moved to another thread to keep draw() free from too much computation. Vec2f tailFactors=getComaDiameterAndTailLengthAU(); float gasTailEndRadius=qMax(tailFactors[0], 0.025f*tailFactors[1]) ; // This avoids too slim gas tails for bright comets like Hale-Bopp. float gasparameter=gasTailEndRadius*gasTailEndRadius/(2.0f*tailFactors[1]); // parabola formula: z=r²/2p, so p=r²/2z // The dust tail is thicker and usually shorter. The factors can be configured in the elements. float dustparameter=gasTailEndRadius*gasTailEndRadius*dustTailWidthFactor*dustTailWidthFactor/(2.0f*dustTailLengthFactor*tailFactors[1]); // Find valid parameters to create paraboloid vertex arrays: dustTail, gasTail. computeParabola(gasparameter, gasTailEndRadius, -0.5f*gasparameter, gastailVertexArr, gastailTexCoordArr, gastailIndices); // This was for a rotated straight parabola: //computeParabola(dustparameter, 2.0f*tailFactors[0], -0.5f*dustparameter, dusttailVertexArr, dusttailTexCoordArr, dusttailIndices); // Now we make a skewed parabola. Skew factor 15 (last arg) ad-hoc/empirical. TBD later: Find physically correct solution. computeParabola(dustparameter, dustTailWidthFactor*gasTailEndRadius, -0.5f*dustparameter, dusttailVertexArr, gastailTexCoordArr, gastailIndices, 25.0f*orbit->getVelocity().length()); // Note that we use a diameter larger than what the formula returns. A scale factor of 1.2 is ad-hoc/empirical (GZ), but may look better. computeComa(1.0f*tailFactors[0]); orbit->setUpdateTails(false); // don't update until position has been recalculated elsewhere } Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent; /* // We can remove that - a Comet has no parent except for the sun... PlanetP p = parent; while (p && p->parent) { mat = Mat4d::translation(p->eclipticPos) * mat * p->rotLocalToParent; p = p->parent; } */ // This removed totally the Planet shaking bug!!! StelProjector::ModelViewTranformP transfo = core->getHeliocentricEclipticModelViewTransform(); transfo->combine(mat); // Compute the 2D position and check if in the screen const StelProjectorP prj = core->getProjection(transfo); float screenSz = getAngularSize(core)*M_PI/180.*prj->getPixelPerRadAtCenter(); float viewport_left = prj->getViewportPosX(); float viewport_bottom = prj->getViewportPosY(); if (prj->project(Vec3d(0), screenPos) && screenPos[1]>viewport_bottom - screenSz && screenPos[1] < viewport_bottom + prj->getViewportHeight()+screenSz && screenPos[0]>viewport_left - screenSz && screenPos[0] < viewport_left + prj->getViewportWidth() + screenSz) { // Draw the name, and the circle if it's not too close from the body it's turning around // this prevents name overlapping (ie for jupiter satellites) float ang_dist = 300.f*atan(getEclipticPos().length()/getEquinoxEquatorialPos(core).length())/core->getMovementMgr()->getCurrentFov(); // if (ang_dist==0.f) ang_dist = 1.f; // if ang_dist == 0, the Planet is sun.. --> GZ: we can remove it. // by putting here, only draw orbit if Comet is visible for clarity drawOrbit(core); // TODO - fade in here also... if (flagLabels && ang_dist>0.25 && maxMagLabels>getVMagnitude(core)) { labelsFader=true; } else { labelsFader=false; } drawHints(core, planetNameFont); draw3dModel(core,transfo,screenSz); } // tails should also be drawn if core is off-screen... drawTail(core,transfo,true); // gas tail drawTail(core,transfo,false); // dust tail //Coma: this is just a fan disk tilted towards the observer;-) drawComa(core, transfo); return; }