void DrawSquare(float left,float right, float top, float bot) { GFXBegin (GFXQUAD); GFXVertex3f(left,top,0); GFXVertex3f(left,bot,0); GFXVertex3f(right,bot,0); GFXVertex3f(right,top,0); GFXVertex3f(right,top,0); GFXVertex3f(right,bot,0); GFXVertex3f(left,bot,0); GFXVertex3f(left,top,0); GFXEnd (); }
void SphereDisplay::DrawTargetMarker(const Vector& position, float trackSize) { // Crosshair const float crossSize = 8.0; const float xcross = crossSize / g_game.x_resolution; const float ycross = crossSize / g_game.y_resolution; // The crosshair wiggles as it moves around. The wiggling is less noticable // when the crosshair is drawn with the smooth option. GFXEnable(SMOOTH); GFXLineWidth(trackSize); GFXBegin(GFXLINE); GFXVertex3f(position.x + xcross, position.y, 0.0f); GFXVertex3f(position.x - xcross, position.y, 0.0f); GFXVertex3f(position.x, position.y - ycross, 0.0f); GFXVertex3f(position.x, position.y + ycross, 0.0f); GFXEnd(); GFXDisable(SMOOTH); }
void SphereDisplay::DrawBackground(const Sensor& sensor, const ViewArea& radarView) { // Split crosshair if (!radarView.IsActive()) return; GFXColor groundColor = radarView.GetColor(); float velocity = sensor.GetPlayer()->GetWarpVelocity().Magnitude(); float logvelocity = 3.0; // std::log10(1000.0); if (velocity > 1000.0) { // Max logvelocity is log10(speed_of_light) = 10.46 logvelocity = std::log10(velocity); } const float size = 3.0 * logvelocity; // [9; 31] const float xground = size / g_game.x_resolution; const float yground = size / g_game.y_resolution; Vector center = radarView.Scale(Vector(0.0, 0.0, 0.0)); GFXEnable(SMOOTH); GFXLineWidth(1); GFXColorf(groundColor); GFXBegin(GFXLINE); GFXVertexf(Vector(center.x - 2.0 * xground, center.y, center.z)); GFXVertexf(Vector(center.x - xground, center.y, center.z)); GFXVertexf(Vector(center.x + 2.0 * xground, center.y, center.z)); GFXVertexf(Vector(center.x + xground, center.y, center.z)); GFXVertexf(Vector(center.x, center.y - 2.0 * yground, center.z)); GFXVertexf(Vector(center.x, center.y - yground, center.z)); GFXVertexf(Vector(center.x, center.y + 2.0 * yground, center.z)); GFXVertexf(Vector(center.x, center.y + yground, center.z)); GFXEnd(); GFXDisable(SMOOTH); }
void SphereDisplay::DrawTrack(const Sensor& sensor, const ViewArea& radarView, const Track& track, bool negate_z) { if (!radarView.IsActive()) return; GFXColor color = sensor.GetColor(track); Vector position = track.GetPosition(); if (negate_z) position.z=-position.z; if (position.z < 0){ static bool negate_z = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "show_negative_blips_as_positive", "true" )); if (negate_z) position.z=-position.z; else position.z = .125; } const float trackSize = 2.0; // FIXME: Jitter only on boundary, not in center if (sensor.InsideNebula()) { Jitter(0.02, 0.04, position); } else { const bool isNebula = (track.GetType() == Track::Type::Nebula); const bool isEcmActive = track.HasActiveECM(); if (isNebula || isEcmActive) { float error = 0.02 * trackSize; Jitter(error, error, position); } } // The magnitude is used to calculate the unit vector. With subtle scaling // of the magnitude we generate a unit vector whose length will vary from // innerSphere to 1.0, depending on the distance to the object. Combined // with the OpenGL z-buffering, this will ensure that close tracks are drawn // on top of distant tracks. float magnitude = position.Magnitude(); float scaleFactor = 0.0; // [0; 1] where 0 = border, 1 = center const float maxRange = sensor.GetMaxRange(); if (magnitude <= maxRange) { // [innerSphere; 1] scaleFactor = (1.0 - innerSphere) * (maxRange - magnitude) / maxRange; magnitude /= (1.0 - scaleFactor); } Vector scaledPosition = Vector(-position.x, position.y, position.z) / magnitude; Vector head = radarView.Scale(scaledPosition); GFXColor headColor = color; if (sensor.UseThreatAssessment()) { float dangerRate = GetDangerRate(sensor.IdentifyThreat(track)); if (dangerRate > 0.0) { // Blinking track headColor.a *= cosf(dangerRate * radarTime); } } // Fade out dying ships if (track.IsExploding()) { headColor.a *= (1.0 - track.ExplodingProgress()); } GFXColorf(headColor); if (sensor.IsTracking(track)) { DrawTargetMarker(head, trackSize); } GFXPointSize(trackSize); GFXBegin(GFXPOINT); GFXVertexf(head); GFXEnd(); }
void Box::ProcessDrawQueue( int ) { if ( !draw_queue[0].size() ) return; GFXBlendMode( SRCALPHA, INVSRCALPHA ); GFXColor( 0.0, .90, .3, .4 ); GFXDisable( LIGHTING ); GFXDisable( TEXTURE0 ); GFXDisable( TEXTURE1 ); GFXDisable( DEPTHWRITE ); GFXDisable( CULLFACE ); //GFXBlendMode(ONE, ONE); while ( draw_queue[0].size() ) { GFXLoadMatrixModel( draw_queue[0].back().mat ); draw_queue[0].pop_back(); GFXBegin( GFXQUAD ); GFXColor4f( 0.0, 1.0, 0.0, 0.2 ); GFXVertex3f( corner_max.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_max.k ); GFXColor4f( 0.0, 1.0, 0.0, 0.2 ); GFXVertex3f( corner_min.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_min.k ); GFXColor4f( 0.0, .70, 0.0, 0.2 ); GFXVertex3f( corner_max.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_min.k ); GFXColor4f( 0.0, .70, 0.0, 0.2 ); GFXVertex3f( corner_max.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_max.k ); GFXColor4f( 0.0, .90, .3, 0.2 ); GFXVertex3f( corner_max.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_min.k ); GFXColor4f( 0.0, .90, .3, 0.2 ); GFXVertex3f( corner_min.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_max.k ); GFXEnd(); /* * vlist->Draw(); * if(quadstrips!=NULL) { * for(int a=0; a<numQuadstrips; a++) * quadstrips[a]->Draw() * ; * } */ } GFXEnable( DEPTHWRITE ); }