//----------------------------------------------------------------------------- // Purpose: Draw the team's base icon at either end of the icon panel //----------------------------------------------------------------------------- bool CHudControlPointIcons::PaintTeamBaseIcon( int index, float flXPos, float flYPos, float flIconSize ) { float uv1 = 0.0f; float uv2 = 1.0f; // Find out which team owns the far left for ( int i = 0; i < MAX_TEAMS; i++ ) { if ( ObjectiveResource()->GetBaseControlPointForTeam(i) == index ) { int iTeamBaseIcon = ObjectiveResource()->GetBaseIconForTeam(i); if ( iTeamBaseIcon ) { // Draw the Team's Base texture const char *szMatName = GetMaterialNameFromIndex( iTeamBaseIcon ); vgui::surface()->DrawSetTextureFile( m_iTeamBaseTextures[i], szMatName, true, false ); Vector2D uv11( uv1, uv1 ); Vector2D uv21( uv2, uv1 ); Vector2D uv22( uv2, uv2 ); Vector2D uv12( uv1, uv2 ); vgui::Vertex_t vert[4]; vert[0].Init( Vector2D( flXPos, flYPos ), uv11 ); vert[1].Init( Vector2D( flXPos + flIconSize, flYPos ), uv21 ); vert[2].Init( Vector2D( flXPos + flIconSize, flYPos + flIconSize ), uv22 ); vert[3].Init( Vector2D( flXPos, flYPos + flIconSize ), uv12 ); vgui::surface()->DrawSetColor( Color(255,255,255,255) ); vgui::surface()->DrawTexturedPolygon( 4, vert ); return true; } } } return false; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CDoDHudHealthBar::Paint( void ) { BaseClass::Paint(); int x, y, w, h; GetBounds( x, y, w, h ); int xpos = 0, ypos = 0; float flDamageY = h * ( 1.0f - m_flPercentage ); Color *pclrHealth; if ( m_flPercentage > m_flFirstWarningLevel ) { pclrHealth = &m_clrHealthHigh; } else if ( m_flPercentage > m_flSecondWarningLevel ) { pclrHealth = &m_clrHealthMed; } else { pclrHealth = &m_clrHealthLow; } // blend in the red "damage" part float uv1 = 0.0f; float uv2 = 1.0f; vgui::surface()->DrawSetTexture( m_iMaterialIndex ); Vector2D uv11( uv1, uv1 ); Vector2D uv21( uv2, uv1 ); Vector2D uv22( uv2, uv2 ); Vector2D uv12( uv1, uv2 ); vgui::Vertex_t vert[4]; // background vert[0].Init( Vector2D( xpos, ypos ), uv11 ); vert[1].Init( Vector2D( xpos + w, ypos ), uv21 ); vert[2].Init( Vector2D( xpos + w, ypos + h ), uv22 ); vert[3].Init( Vector2D( xpos, ypos + h ), uv12 ); vgui::surface()->DrawSetColor( m_clrBackground ); vgui::surface()->DrawTexturedPolygon( 4, vert ); // damage part vert[0].Init( Vector2D( xpos, flDamageY ), uv11 ); vert[1].Init( Vector2D( xpos + w, flDamageY ), uv21 ); vert[2].Init( Vector2D( xpos + w, ypos + h ), uv22 ); vert[3].Init( Vector2D( xpos, ypos + h ), uv12 ); vgui::surface()->DrawSetColor( *pclrHealth ); vgui::surface()->DrawTexturedPolygon( 4, vert ); // outline vert[0].Init( Vector2D( xpos, ypos ), uv11 ); vert[1].Init( Vector2D( xpos + w - 1, ypos ), uv21 ); vert[2].Init( Vector2D( xpos + w - 1, ypos + h - 1 ), uv22 ); vert[3].Init( Vector2D( xpos, ypos + h - 1 ), uv12 ); vgui::surface()->DrawSetColor( m_clrBorder ); vgui::surface()->DrawTexturedPolyLine( vert, 4 ); }
void CHudTexture::DrawSelfScalableCorners( int drawX, int drawY, int w, int h, int iSrcCornerW, int iSrcCornerH, int iDrawCornerW, int iDrawCornerH, Color clr ) const { if ( bRenderUsingFont ) { Assert( !"DrawSelfScalableCorners does not support drawing a font" ); return; } if ( textureId == -1 ) return; float fw = (float)Width(); float fh = (float)Height(); float flCornerWidthPercent = ( fw > 0 ) ? ( (float)iSrcCornerW / fw ) : 0; float flCornerHeightPercent = ( fh > 0 ) ? ( (float)iSrcCornerH / fh ) : 0; vgui::surface()->DrawSetColor( clr ); vgui::surface()->DrawSetTexture( textureId ); float uvx = 0; float uvy = 0; float uvw, uvh; float drawW, drawH; int x = drawX; int y = drawY; int row, col; for ( row=0;row<3;row++ ) { x = drawX; uvx = 0; if ( row == 0 || row == 2 ) { //uvh - row 0 or 2, is src_corner_height uvh = flCornerHeightPercent; drawH = iDrawCornerH; } else { //uvh - row 1, is tall - ( 2 * src_corner_height ) ( min 0 ) uvh = MAX( 1.0 - 2 * flCornerHeightPercent, 0.0f ); drawH = MAX( 0, ( h - 2 * iDrawCornerH ) ); } for ( col=0;col<3;col++ ) { if ( col == 0 || col == 2 ) { //uvw - col 0 or 2, is src_corner_width uvw = flCornerWidthPercent; drawW = iDrawCornerW; } else { //uvw - col 1, is wide - ( 2 * src_corner_width ) ( min 0 ) uvw = MAX( 1.0 - 2 * flCornerWidthPercent, 0.0f ); drawW = MAX( 0, ( w - 2 * iDrawCornerW ) ); } Vector2D uv11( uvx, uvy ); Vector2D uv21( uvx+uvw, uvy ); Vector2D uv22( uvx+uvw, uvy+uvh ); Vector2D uv12( uvx, uvy+uvh ); vgui::Vertex_t verts[4]; verts[0].Init( Vector2D( x, y ), uv11 ); verts[1].Init( Vector2D( x+drawW, y ), uv21 ); verts[2].Init( Vector2D( x+drawW, y+drawH ), uv22 ); verts[3].Init( Vector2D( x, y+drawH ), uv12 ); vgui::surface()->DrawTexturedPolygon( 4, verts, false ); x += drawW; uvx += uvw; } y += drawH; uvy += uvh; } vgui::surface()->DrawSetTexture(0); }
OIDataList COI_T3::read() { // Read in the common data: vector<int> target_ids; vector<double> times; vector<double> MJDs; vector<double> int_times; vector< valarray<int> > sta_indicies; vector< valarray<bool> > flags; COI_DATA_TABLE::ReadCommon(target_ids, times, MJDs, int_times, sta_indicies, flags); // Now read in the T3-specific columns: int n_rows = mTable.rows(); vector< valarray<double> > t3_amp = ReadArray<double>("T3AMP"); vector< valarray<double> > t3_phi = ReadArray<double>("T3PHI"); vector< valarray<double> > t3_amp_err = ReadArray<double>("T3AMPERR"); vector< valarray<double> > t3_phi_err = ReadArray<double>("T3PHIERR"); // Copy the data into valarrays of complex doubles for storage in the COIT3Row class; vector< valarray< complex<double> > > data; vector< valarray< pair<double,double> > > data_err; int n_cols = 0; if(n_rows > 0) // This could be false if someone created a OI_T3 table with no data in it. n_cols = t3_amp[0].size(); // Now copy the data into complex data fields double real = 0; double imag = 0; for(int i = 0; i < n_rows; i++) { // Create a new valarray to store the data values: valarray< complex<double> > temp(n_cols); valarray< pair<double,double> > temp_err(n_cols); // Fill in the data for(int j = 0; j < n_cols; j++) { // If the phase has not been calibrated, the amplitude will be NULL. // In this case, we still form the data products, but set the amplitude // error to infinity. if(std::isnan(t3_amp[i][j])) { // Set T3 amp = 1, use phase only. real = cos(t3_phi[i][j] * PI/180); imag = sin(t3_phi[i][j] * PI/180); temp[j] = complex<double>(real, imag); temp_err[j] = pair<double,double>(numeric_limits<double>::max(), t3_phi_err[i][j] * PI/180); } else { real = t3_amp[i][j] * cos(t3_phi[i][j] * PI/180); imag = t3_amp[i][j] * sin(t3_phi[i][j] * PI/180); temp[j] = complex<double>(real, imag); temp_err[j] = pair<double,double>(t3_amp_err[i][j], t3_phi_err[i][j] * PI/180); } } // Push them onto the vector. data.push_back(temp); data_err.push_back(temp_err); } // Read in the UV points (UV 31 is implicitly defined) vector<double> ucoord1 = ReadColumn<double>("U1COORD"); vector<double> vcoord1 = ReadColumn<double>("V1COORD"); vector<double> ucoord2 = ReadColumn<double>("U2COORD"); vector<double> vcoord2 = ReadColumn<double>("V2COORD"); // Now create and store T3 objects: vector<OIDataRowPtr> output; OIArrayPtr array = mParent->GetArray(this->GetArrayName()); OIWavelengthPtr wave = mParent->GetWavelength(this->GetInstrumentName()); for(int i = 0; i < n_rows; i++) { OITargetPtr target = mParent->GetTarget(target_ids[i]); OIUVPtr uv12( new COIUV(ucoord1[i], vcoord1[i])); OIUVPtr uv23( new COIUV(ucoord2[i], vcoord2[i])); OIDataRowPtr tmp( new COIT3Row(target, array, wave, times[i], MJDs[i], int_times[i], sta_indicies[i], flags[i], uv12, uv23, data[i], data_err[i]) ); output.push_back(tmp); } return output; }