//----------------------------------------------------------------------------- // paint it! //----------------------------------------------------------------------------- void CMaterialViewPanel::Paint() { // Draw a background (translucent objects will appear that way) // FIXME: Draw the outline of this panel? if (!m_pMaterial) return; g_pMatSystemSurface->Begin3DPaint( 0, 0, m_iViewableWidth, m_iViewableHeight ); g_pMaterialSystem->MatrixMode( MATERIAL_PROJECTION ); g_pMaterialSystem->LoadIdentity(); g_pMaterialSystem->Scale( 1, -1, 1 ); g_pMaterialSystem->Ortho( 0, 0, m_iViewableWidth, m_iViewableHeight, 0, 1 ); g_pMaterialSystem->Bind( m_pMaterial ); IMesh *pMesh = g_pMaterialSystem->GetDynamicMesh(); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); if (!m_bUseActualSize) { DrawStretchedToPanel( meshBuilder ); } else { DrawActualSize( meshBuilder ); } meshBuilder.End(); pMesh->Draw(); g_pMatSystemSurface->End3DPaint( ); }
void CReplayRenderer::DrawResolvingQuad( int nWidth, int nHeight ) { CMatRenderContextPtr pRenderContext( g_pMaterialSystem ); IMesh *pMesh = pRenderContext->GetDynamicMesh(); CMeshBuilder meshBuilder; // Epsilons for 1:1 texel to pixel mapping float fWidthEpsilon = IsOSX() ? 0.0f : 0.5f / ((float) nWidth); float fHeightEpsilon = IsOSX() ? 0.0f : 0.5f / ((float) nHeight); meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( -1.0f, 1.0f, 0.5f ); // Upper left meshBuilder.TexCoord2f( 0, 0.0f + fWidthEpsilon, 0.0f + fHeightEpsilon ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( -1.0f, -1.0f, 0.5f ); // Lower left meshBuilder.TexCoord2f( 0, 0.0f + fWidthEpsilon, 1.0f + fHeightEpsilon ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( 1.0f, -1.0f, 0.5f ); // Lower right meshBuilder.TexCoord2f( 0, 1.0f + fWidthEpsilon, 1.0f + fHeightEpsilon ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( 1.0f, 1.0f, 0.5f ); // Upper right meshBuilder.TexCoord2f( 0, 1.0f + fWidthEpsilon, 0.0f + fHeightEpsilon ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
void OverlayCameraRenderTarget( const char *pszMaterialName, float flX, float flY, float w, float h ) { float offsetS = ( 0.5f / 256.0f ); float offsetT = ( 0.5f / 256.0f ); IMaterial *pMaterial; pMaterial = materials->FindMaterial( pszMaterialName, TEXTURE_GROUP_OTHER, true ); if( !IsErrorMaterial( pMaterial ) ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( pMaterial ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( flX, flY, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f + offsetS, 0.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( flX+w, flY, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f + offsetS, 0.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( flX+w, flY+h, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f + offsetS, 1.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( flX, flY+h, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f + offsetS, 1.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); } }
void CHoloShipComm::Draw( IMatRenderContext *pRenderContext ) { m_vecPanelWorldOffset.x = -m_flWidth * m_flScale; BaseClass::Draw( pRenderContext ); GetColorVar()->SetVecValue( HOLO_COLOR_HIGHLIGHT ); SetHoloAlpha( 1.0f ); const float flTriangleStart = -0.5f; const float flTriangleHeight = 0.03f; IMesh *pMesh = pRenderContext->GetDynamicMesh( true, 0, 0, GetMaterial() ); CreateSlantedRect( pMesh, 0, flTriangleStart, m_flWidth * -m_flScale, flTriangleHeight ); //CMeshBuilder builder; //builder.Begin( pMesh, MATERIAL_TRIANGLES, 1 ); //builder.Position3f( 0, 0, flTriangleStart ); //builder.AdvanceVertex(); //builder.Position3f( 0, 0, flTriangleStart + flTriangleHeight ); //builder.AdvanceVertex(); //builder.Position3f( 0, -m_flWidth * m_flScale, flTriangleStart ); //builder.AdvanceVertex(); //builder.End(); pMesh->Draw(); if ( m_flWaveVisibilityAmount > 0.0f ) { DrawWaveForm( pRenderContext ); } }
void DrawLightmapPage( int lightmapPageID ) { // assumes that we are already in ortho mode. int lightmapPageWidth, lightmapPageHeight; IMesh* pMesh = materialSystemInterface->GetDynamicMesh( true, NULL, NULL, g_materialDebugLightmap ); // materialSystemInterface->Bind( g_materialWireframe ); // IMesh* pMesh = materialSystemInterface->GetDynamicMesh( g_materialWireframe ); materialSystemInterface->GetLightmapPageSize( lightmapPageID, &lightmapPageWidth, &lightmapPageHeight ); materialSystemInterface->BindLightmapPage( lightmapPageID ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); // texcoord 1 is lightmaptexcoord for fixed function. meshBuilder.TexCoord2f( 1, 0.0f, 0.0f ); meshBuilder.Position3f( 0.0f, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.TexCoord2f( 1, 1.0f, 0.0f ); meshBuilder.Position3f( lightmapPageWidth, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.TexCoord2f( 1, 1.0f, 1.0f ); meshBuilder.Position3f( lightmapPageWidth, lightmapPageHeight, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.TexCoord2f( 1, 0.0f, 1.0f ); meshBuilder.Position3f( 0.0f, lightmapPageHeight, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Purpose: Renders a selection gizmo at our bounds center. // Input : pRender - Rendering interface. //----------------------------------------------------------------------------- void Marker3D::RenderTool3D(CRender3D *pRender) { if (!IsActiveTool()) { return; } Vector *pPos; if (IsTranslating()) { pPos = &m_vecTranslatePos; } else { if (IsEmpty()) { return; } pPos = &m_vecPos; } // // Setup the renderer. // pRender->SetRenderMode(RENDER_MODE_WIREFRAME); CMeshBuilder meshBuilder; IMesh* pMesh = MaterialSystemInterface()->GetDynamicMesh(); meshBuilder.Begin(pMesh, MATERIAL_LINES, 3); meshBuilder.Position3f(g_MIN_MAP_COORD, (*pPos)[1], (*pPos)[2]); meshBuilder.Color3ub(255, 0, 0); meshBuilder.AdvanceVertex(); meshBuilder.Position3f(g_MAX_MAP_COORD, (*pPos)[1], (*pPos)[2]); meshBuilder.Color3ub(255, 0, 0); meshBuilder.AdvanceVertex(); meshBuilder.Position3f((*pPos)[0], g_MIN_MAP_COORD, (*pPos)[2]); meshBuilder.Color3ub(0, 255, 0); meshBuilder.AdvanceVertex(); meshBuilder.Position3f((*pPos)[0], g_MAX_MAP_COORD, (*pPos)[2]); meshBuilder.Color3ub(0, 255, 0); meshBuilder.AdvanceVertex(); meshBuilder.Position3f((*pPos)[0], (*pPos)[1], g_MIN_MAP_COORD); meshBuilder.Color3ub(0, 0, 255); meshBuilder.AdvanceVertex(); meshBuilder.Position3f((*pPos)[0], (*pPos)[1], g_MAX_MAP_COORD); meshBuilder.Color3ub(0, 0, 255); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); pRender->SetRenderMode(RENDER_MODE_DEFAULT); }
void DrawSmokeFogOverlay() { if(g_SmokeFogOverlayAlpha == 0 || !g_pSmokeFogMaterial || !materials) return; // Hard-coded for now.. g_SmokeFogOverlayColor.Init( 0.3, 0.3, 0.3 ); CMatRenderContextPtr pRenderContext( materials ); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->LoadIdentity(); pRenderContext->Ortho( 0, 0, 1, 1, -99999, 99999 ); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->LoadIdentity(); pRenderContext->MatrixMode( MATERIAL_MODEL ); pRenderContext->LoadIdentity(); IMesh* pMesh = pRenderContext->GetDynamicMesh( false, NULL, NULL, g_pSmokeFogMaterial ); CMeshBuilder meshBuilder; static float dist = 10; Vector vColor = g_SmokeFogOverlayColor; vColor.x = MIN(MAX(vColor.x, 0), 1); vColor.y = MIN(MAX(vColor.y, 0), 1); vColor.z = MIN(MAX(vColor.z, 0), 1); float alpha = MIN(MAX(g_SmokeFogOverlayAlpha, 0), 1); meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( 0, 0, dist ); meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( 0, 1, dist ); meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( 1, 1, dist ); meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( 1, 0, dist ); meshBuilder.Color4f( vColor.x, vColor.y, vColor.z, alpha ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
static void DispInfo_DrawChainNormals( IDispInfo *pHead ) { #ifndef SWDS #ifdef _DEBUG // Only do it in debug because we're only storing the info then Vector p; materialSystemInterface->Bind( g_pMaterialWireframeVertexColor ); for( IDispInfo *pCur=pHead; pCur; pCur = pCur->GetNextInRenderChain() ) { CDispInfo *pDisp = static_cast<CDispInfo*>( pCur ); int nVerts = pDisp->NumVerts(); IMesh *pMesh = materialSystemInterface->GetDynamicMesh( ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_LINES, nVerts * 3 ); for( int iVert=0; iVert < nVerts; iVert++ ) { CDispRenderVert* pVert = pDisp->GetVertex(iVert); meshBuilder.Position3fv( pVert->m_vPos.Base() ); meshBuilder.Color3ub( 255, 0, 0 ); meshBuilder.AdvanceVertex(); VectorMA( pVert->m_vPos, 5.0f, pVert->m_vNormal, p ); meshBuilder.Position3fv( p.Base() ); meshBuilder.Color3ub( 255, 0, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( pVert->m_vPos.Base() ); meshBuilder.Color3ub( 0, 255, 0 ); meshBuilder.AdvanceVertex(); VectorMA( pVert->m_vPos, 5.0f, pVert->m_vSVector, p ); meshBuilder.Position3fv( p.Base() ); meshBuilder.Color3ub( 0, 255, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( pVert->m_vPos.Base() ); meshBuilder.Color3ub( 0, 0, 255 ); meshBuilder.AdvanceVertex(); VectorMA( pVert->m_vPos, 5.0f, pVert->m_vTVector, p ); meshBuilder.Position3fv( p.Base() ); meshBuilder.Color3ub( 0, 0, 255 ); meshBuilder.AdvanceVertex(); } meshBuilder.End(); pMesh->Draw(); } #endif #endif }
//----------------------------------------------------------------------------- // Purpose: // Input : pMaterial - // source - // color - //----------------------------------------------------------------------------- void DrawHaloOriented( const Vector& source, float scale, float const *color, float roll ) { Vector point, screen; CMatRenderContextPtr pRenderContext( materials ); IMesh* pMesh = pRenderContext->GetDynamicMesh(); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); // Transform source into screen space ScreenTransform( source, screen ); Vector right, up; float sr, cr; SinCos( roll, &sr, &cr ); for ( int i = 0; i < 3; i++ ) { right[i] = CurrentViewRight()[i] * cr + CurrentViewUp()[i] * sr; up[i] = CurrentViewRight()[i] * -sr + CurrentViewUp()[i] * cr; } meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 0, 1); VectorMA (source, -scale, up, point); VectorMA (point, -scale, right, point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 0, 0); VectorMA (source, scale, up, point); VectorMA (point, -scale, right, point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 1, 0); VectorMA (source, scale, up, point); VectorMA (point, scale, right, point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 1, 1); VectorMA (source, -scale, up, point); VectorMA (point, scale, right, point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Debugging aid to display a texture //----------------------------------------------------------------------------- static void OverlayShowTexture( const char* textureName, float scale ) { bool foundVar; IMaterial *pMaterial; IMaterialVar *BaseTextureVar; ITexture *pTex; float x, y, w, h; // ___error is created in code in CMaterialSystem::CreateDebugMaterials() pMaterial = materials->FindMaterial( "___error", TEXTURE_GROUP_OTHER, true ); BaseTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false ); if (!foundVar) return; CMatRenderContextPtr pRenderContext( materials ); if ( textureName && textureName[0] ) { pTex = materials->FindTexture( textureName, TEXTURE_GROUP_OTHER, false ); BaseTextureVar->SetTextureValue( pTex ); w = pTex->GetActualWidth() * scale; h = pTex->GetActualHeight() * scale; } else { w = h = 64.0f * scale; } // Center relative to current viewport int nViewportX, nViewportY, nViewportWidth, nViewportHeight; pRenderContext->GetViewport( nViewportX, nViewportY, nViewportWidth, nViewportHeight ); x = ( nViewportWidth - w ) * 0.5f; y = ( nViewportHeight - h ) * 0.5f; pRenderContext->Bind( pMaterial ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( x, y, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x+w, y, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x+w, y+h, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x, y+h, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Purpose: Draw the jetpack level //----------------------------------------------------------------------------- void CHudEMP::Paint() { // Rush label int iX, iY; GetPos( iX, iY ); int iWidth = XRES(16); int iHeight = YRES(16); if ( m_pFrameVar ) { float curtime = gpGlobals->curtime; if ( curtime >= m_flNextFrameChange ) { m_flNextFrameChange = curtime + ( 1.0f / HUDEMP_FRAMERATE ); int frame = m_pFrameVar->GetIntValue(); frame++; if ( frame >= m_nNumFrames ) { frame = 0; } m_pFrameVar->SetIntValue(frame); } } IMesh* pMesh = materials->GetDynamicMesh( true, NULL, NULL, m_pEMPIcon ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Color3f( 1.0, 1.0, 1.0 ); meshBuilder.TexCoord2f( 0,0,0 ); meshBuilder.Position3f( iX,iY,0 ); meshBuilder.AdvanceVertex(); meshBuilder.Color3f( 1.0, 1.0, 1.0 ); meshBuilder.TexCoord2f( 0,1,0 ); meshBuilder.Position3f( iX+iWidth, iY, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.Color3f( 1.0, 1.0, 1.0 ); meshBuilder.TexCoord2f( 0,1,1 ); meshBuilder.Position3f( iX+iWidth, iY+iHeight, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.Color3f( 1.0, 1.0, 1.0 ); meshBuilder.TexCoord2f( 0,0,1 ); meshBuilder.Position3f( iX, iY+iHeight, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Purpose: // Input : pMaterial - // source - // color - //----------------------------------------------------------------------------- void DrawHalo(IMaterial* pMaterial, const Vector& source, float scale, float const* color, float flHDRColorScale ) { static unsigned int nHDRColorScaleCache = 0; Vector point, screen; if( pMaterial ) { IMaterialVar *pHDRColorScaleVar = pMaterial->FindVarFast( "$hdrcolorscale", &nHDRColorScaleCache ); if( pHDRColorScaleVar ) { pHDRColorScaleVar->SetFloatValue( flHDRColorScale ); } } CMatRenderContextPtr pRenderContext( materials ); IMesh* pMesh = pRenderContext->GetDynamicMesh( ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); // Transform source into screen space ScreenTransform( source, screen ); meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 0, 1); VectorMA (source, -scale, CurrentViewUp(), point); VectorMA (point, -scale, CurrentViewRight(), point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 0, 0); VectorMA (source, scale, CurrentViewUp(), point); VectorMA (point, -scale, CurrentViewRight(), point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 1, 0); VectorMA (source, scale, CurrentViewUp(), point); VectorMA (point, scale, CurrentViewRight(), point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv (color); meshBuilder.TexCoord2f (0, 1, 1); VectorMA (source, -scale, CurrentViewUp(), point); VectorMA (point, scale, CurrentViewRight(), point); meshBuilder.Position3fv (point.Base()); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Purpose: Renders the connecting lines between the keyframes // Input : pRender - //----------------------------------------------------------------------------- void CMapKeyFrame::Render3D( CRender3D *pRender ) { if ( m_bRebuildPath ) { if (GetAnimator() != NULL) { GetAnimator()->RebuildPath(); } } // only draw if we have a valid connection if ( m_pNextKeyFrame && m_flSpeed > 0 ) { // only draw if we haven't already been drawn this frame if ( GetRenderFrame() != pRender->GetRenderFrame() ) { pRender->PushRenderMode( RENDER_MODE_WIREFRAME ); SetRenderFrame( pRender->GetRenderFrame() ); Vector o1, o2; GetOrigin( o1 ); m_pNextKeyFrame->GetOrigin( o2 ); CMeshBuilder meshBuilder; CMatRenderContextPtr pRenderContext( MaterialSystemInterface() ); IMesh *pMesh = pRenderContext->GetDynamicMesh(); // draw connecting line going from green to red meshBuilder.Begin( pMesh, MATERIAL_LINE_STRIP, MAX_LINE_POINTS ); // start point meshBuilder.Color3f( 0, 1.0f, 0 ); meshBuilder.Position3f( o1[0], o1[1], o1[2] ); meshBuilder.AdvanceVertex(); for ( int i = 0; i < MAX_LINE_POINTS; i++ ) { float red = (float)(i+1) / (float)MAX_LINE_POINTS; meshBuilder.Color3f( red, 1.0f - red, 0 ); meshBuilder.Position3f( m_LinePoints[i][0], m_LinePoints[i][1], m_LinePoints[i][2] ); meshBuilder.AdvanceVertex(); } meshBuilder.End(); pMesh->Draw(); pRender->PopRenderMode(); } } }
//----------------------------------------------------------------------------- // Debugging aid to display a texture //----------------------------------------------------------------------------- static void OverlayShowTexture( const char* textureName, float scale ) { bool foundVar; IMaterial *pMaterial; IMaterialVar *BaseTextureVar; ITexture *pTex; float x, y, w, h; // screen safe x = 32; y = 32; pMaterial = materials->FindMaterial( "___debug", TEXTURE_GROUP_OTHER, true ); BaseTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false ); if (!foundVar) return; CMatRenderContextPtr pRenderContext( materials ); if ( textureName && textureName[0] ) { pTex = materials->FindTexture( textureName, TEXTURE_GROUP_OTHER, false ); BaseTextureVar->SetTextureValue( pTex ); w = pTex->GetActualWidth() * scale; h = pTex->GetActualHeight() * scale; } else { w = h = 64.0f * scale; } pRenderContext->Bind( pMaterial ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( x, y, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x+w, y, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x+w, y+h, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x, y+h, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Purpose: // Input : frame - // x - // y - // *prcSubRect - //----------------------------------------------------------------------------- void CEngineSprite::DrawFrameOfSize( int frame, int x, int y, int iWidth, int iHeight, const wrect_t *prcSubRect ) { // FIXME: If we ever call this with AVIs, need to have it call GetTexCoordRange and make that work Assert( !IsAVI() && !IsBIK() ); float fLeft = 0; float fRight = 1; float fTop = 0; float fBottom = 1; if ( prcSubRect ) { AdjustSubRect( this, frame, &fLeft, &fRight, &fTop, &fBottom, &iWidth, &iHeight, prcSubRect ); } if ( giScissorTest && !Scissor( x, y, iWidth, iHeight, fLeft, fTop, fRight, fBottom ) ) return; SetFrame( frame ); CMatRenderContextPtr pRenderContext( materials ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, GetMaterial() ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); float color[3]; GetHUDSpriteColor( color ); meshBuilder.Color3fv( color ); meshBuilder.TexCoord2f( 0, fLeft, fTop ); meshBuilder.Position3f( x, y, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv( color ); meshBuilder.TexCoord2f( 0, fRight, fTop ); meshBuilder.Position3f( x + iWidth, y, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv( color ); meshBuilder.TexCoord2f( 0, fRight, fBottom ); meshBuilder.Position3f( x + iWidth, y + iHeight, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.Color3fv( color ); meshBuilder.TexCoord2f( 0, fLeft, fBottom ); meshBuilder.Position3f( x, y + iHeight, 0.0f ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Purpose: // Input : pRender - //----------------------------------------------------------------------------- void CMapLine::Render3D(CRender3D *pRender) { if ( (m_pStartEntity == NULL) || (m_pEndEntity == NULL) ) return; pRender->BeginRenderHitTarget(this); pRender->PushRenderMode(RENDER_MODE_WIREFRAME); Vector Start, End; m_pStartEntity->GetOrigin(Start); m_pEndEntity->GetOrigin(End); CMeshBuilder meshBuilder; CMatRenderContextPtr pRenderContext( MaterialSystemInterface() ); IMesh* pMesh = pRenderContext->GetDynamicMesh(); // FIXME: Can't do this...! glLineWidth(2); meshBuilder.Begin( pMesh, MATERIAL_LINES, 1 ); unsigned char color[3]; if (IsSelected()) { color[0] = SELECT_EDGE_RED; color[1] = SELECT_EDGE_GREEN; color[2] = SELECT_EDGE_BLUE; } else { color[0] = r; color[1] = g; color[2] = b; } meshBuilder.Color3ubv( color ); meshBuilder.Position3f(Start.x, Start.y, Start.z); meshBuilder.AdvanceVertex(); meshBuilder.Color3ubv( color ); meshBuilder.Position3f(End.x, End.y, End.z); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); pRender->EndRenderHitTarget(); pRender->PopRenderMode(); }
void FX_DrawLine( const Vector &start, const Vector &end, float scale, IMaterial *pMaterial, const color32 &color ) { Vector lineDir, viewDir; //Get the proper orientation for the line VectorSubtract( end, start, lineDir ); VectorSubtract( end, CurrentViewOrigin(), viewDir ); Vector cross = lineDir.Cross( viewDir ); VectorNormalize( cross ); CMatRenderContextPtr pRenderContext( materials ); //Bind the material IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, pMaterial ); CMeshBuilder meshBuilder; Vector tmp; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); VectorMA( start, -scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( start, scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( end, scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( end, -scale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4ub( color.r, color.g, color.b, color.a ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
void drawFloor () { float mTempModel[4][4]; float mTempView[4][4]; g_pMaterialSystem->Bind(g_materialFloor); g_pMaterialSystem->MatrixMode(MATERIAL_MODEL); g_pMaterialSystem->GetMatrix(MATERIAL_MODEL, (float*)mTempModel); g_pMaterialSystem->LoadIdentity(); g_pMaterialSystem->MatrixMode(MATERIAL_VIEW); g_pMaterialSystem->GetMatrix(MATERIAL_VIEW, (float*)mTempView); g_pMaterialSystem->LoadIdentity(); { IMesh* pMesh = g_pMaterialSystem->GetDynamicMesh(); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); float dist=-15000.0f; float tMin=0, tMax=1; meshBuilder.Position3f(-dist, dist, dist); meshBuilder.TexCoord2f( 0, tMin,tMax ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( dist, dist, dist); meshBuilder.TexCoord2f( 0, tMax,tMax ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( dist,-dist, dist); meshBuilder.TexCoord2f( 0, tMax,tMin ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f(-dist,-dist, dist); meshBuilder.TexCoord2f( 0, tMin,tMin ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); } g_pMaterialSystem->MatrixMode(MATERIAL_MODEL); g_pMaterialSystem->LoadMatrix((float*)mTempModel); g_pMaterialSystem->MatrixMode(MATERIAL_VIEW); g_pMaterialSystem->LoadMatrix((float*)mTempView); }
//----------------------------------------------------------------------------- // Draws a quad //----------------------------------------------------------------------------- void CAVITestApp::DrawStuff( AVIMaterial_t hMaterial ) { int iViewableWidth = GetWindowWidth(); int iViewableHeight = GetWindowHeight(); g_pAVI->SetTime( hMaterial, Sys_FloatTime() - m_flStartTime ); float flMaxU, flMaxV; g_pAVI->GetTexCoordRange( hMaterial, &flMaxU, &flMaxV ); IMaterial *pMaterial = g_pAVI->GetMaterial( hMaterial ); CMatRenderContextPtr pRenderContext( g_pMaterialSystem ); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->LoadIdentity(); pRenderContext->Ortho( 0, 0, iViewableWidth, iViewableHeight, 0, 1 ); pRenderContext->Bind( pMaterial ); IMesh *pMesh = pRenderContext->GetDynamicMesh(); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); // Draw a polygon the size of the panel meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Position3f( -0.5, iViewableHeight + 0.5, 0 ); meshBuilder.TexCoord2f( 0, 0, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Position3f( -0.5, 0.5, 0 ); meshBuilder.TexCoord2f( 0, 0, flMaxV ); meshBuilder.AdvanceVertex(); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Position3f( iViewableWidth - 0.5, 0.5, 0 ); meshBuilder.TexCoord2f( 0, flMaxU, flMaxV ); meshBuilder.AdvanceVertex(); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Position3f( iViewableWidth - 0.5, iViewableHeight + 0.5, 0 ); meshBuilder.TexCoord2f( 0, flMaxU, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
void CMoviePlayerPanel::Paint() { if ( m_pVideoMaterial == NULL ) return; // Get panel position/dimensions int x,y; int w,h; GetPosRelativeToAncestor( NULL, x, y ); GetSize( w,h ); CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( m_pMaterial ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); float flMinU = 0.0f, flMinV = 0.0f; float flMaxU, flMaxV; m_pVideoMaterial->GetVideoTexCoordRange( &flMaxU, &flMaxV ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( x, y, 0.0f ); meshBuilder.TexCoord2f( 0, flMinU, flMinV ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x + w, y, 0.0f ); meshBuilder.TexCoord2f( 0, flMaxU, flMinV ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x + w, y + h, 0.0f ); meshBuilder.TexCoord2f( 0, flMaxU, flMaxV ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x, y + h, 0.0f ); meshBuilder.TexCoord2f( 0, flMinU, flMaxV ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Draws the control points in wireframe //----------------------------------------------------------------------------- void C_Shield::DrawWireframeModel( Vector const** ppPositions ) { IMesh* pMesh = materials->GetDynamicMesh( true, NULL, NULL, m_pWireframe ); int numLines = (Height() - 1) * Width() + Height() * (Width() - 1); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_LINES, numLines ); Vector const* tmp; for (int i = 0; i < Height(); ++i) { for (int j = 0; j < Width(); ++j) { if ( i > 0 ) { tmp = ppPositions[j + Width() * i]; meshBuilder.Position3fv( tmp->Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); tmp = ppPositions[j + Width() * (i-1)]; meshBuilder.Position3fv( tmp->Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); } if (j > 0) { tmp = ppPositions[j + Width() * i]; meshBuilder.Position3fv( tmp->Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); tmp = ppPositions[j - 1 + Width() * i]; meshBuilder.Position3fv( tmp->Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); } } } meshBuilder.End(); pMesh->Draw(); }
void CHoloShipAimInfo::Draw( IMatRenderContext *pRenderContext ) { BaseClass::Draw( pRenderContext ); // Draw glow matrix3x4_t viewMatrixInv = CurrentHoloViewMatrixInverted(); MatrixSetTranslation( Vector( 0, 270 * m_flScale * 0.5f, -0.5f ), viewMatrixInv ); pRenderContext->MultMatrixLocal( viewMatrixInv ); GetColorVar( MATERIALTYPE_GLOW )->SetVecValue( HOLO_COLOR_DEFAULT ); SetHoloAlpha( 0.03f, MATERIALTYPE_GLOW ); const float flScale = 3.0f; const float flRatio = 3.0f; IMesh *pMeshGlow = pRenderContext->GetDynamicMesh( true, 0, 0, GetMaterial( MATERIALTYPE_GLOW ) ); CreateTexturedRect( pMeshGlow, flScale * -flRatio, -flScale, flScale * 2 * flRatio, flScale * 2 ); pMeshGlow->Draw(); }
//----------------------------------------------------------------------------- // Draw sprite-card based materials //----------------------------------------------------------------------------- void CVMTPreviewPanel::RenderSpriteCard( const Vector &vCenter, float flRadius ) { CMatRenderContextPtr pRenderContext( MaterialSystem() ); IMesh *pMesh = pRenderContext->GetDynamicMesh(); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); // Draw a polygon the size of the panel meshBuilder.Position3fv( vCenter.Base() ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.TexCoord4f( 0, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 1, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 2, 0.0f, 0.0f, flRadius, 0.0f ); meshBuilder.TexCoord2f( 3, 0, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( vCenter.Base() ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.TexCoord4f( 0, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 1, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 2, 0.0f, 0.0f, flRadius, 0.0f ); meshBuilder.TexCoord2f( 3, 0, 1 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( vCenter.Base() ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.TexCoord4f( 0, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 1, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 2, 0.0f, 0.0f, flRadius, 0.0f ); meshBuilder.TexCoord2f( 3, 1, 1 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( vCenter.Base() ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.TexCoord4f( 0, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 1, 0.0f, 0.0f, 1.0f, 1.0f ); meshBuilder.TexCoord4f( 2, 0.0f, 0.0f, flRadius, 0.0f ); meshBuilder.TexCoord2f( 3, 1, 0 ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); }
void C_EnergyWave::DrawWireframeModel( ) { IMesh* pMesh = materials->GetDynamicMesh( true, NULL, NULL, m_pWireframe ); int numLines = (EWAVE_NUM_VERTICAL_POINTS - 1) * EWAVE_NUM_HORIZONTAL_POINTS + EWAVE_NUM_VERTICAL_POINTS * (EWAVE_NUM_HORIZONTAL_POINTS - 1); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_LINES, numLines ); Vector tmp; for (int i = 0; i < EWAVE_NUM_VERTICAL_POINTS; ++i) { for (int j = 0; j < EWAVE_NUM_HORIZONTAL_POINTS; ++j) { if ( i > 0 ) { meshBuilder.Position3fv( m_EWaveEffect.GetPoint( j, i ).Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( m_EWaveEffect.GetPoint( j, i - 1 ).Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); } if (j > 0) { meshBuilder.Position3fv( m_EWaveEffect.GetPoint( j, i ).Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( m_EWaveEffect.GetPoint( j - 1, i ).Base() ); meshBuilder.Color4ub( 255, 255, 255, 128 ); meshBuilder.AdvanceVertex(); } } } meshBuilder.End(); pMesh->Draw(); }
//----------------------------------------------------------------------------- // Draws the grid under the MDL //----------------------------------------------------------------------------- void CMDLPanel::DrawGrid() { matrix3x4_t transform; SetIdentityMatrix( transform ); CMatRenderContextPtr pRenderContext( MaterialSystem() ); pRenderContext->MatrixMode( MATERIAL_MODEL ); pRenderContext->LoadMatrix( transform ); pRenderContext->Bind( m_Wireframe ); IMesh *pMesh = pRenderContext->GetDynamicMesh(); int nGridDim = 10; CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_LINES, 2 * nGridDim + 2 ); float bounds = 100.0f; float delta = 2 * bounds / nGridDim; for ( int i = 0; i < nGridDim + 1; ++i ) { float xy = -bounds + delta * i; meshBuilder.Position3f( xy, -bounds, 0 ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( xy, bounds, 0 ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( -bounds, xy, 0 ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( bounds, xy, 0 ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); } meshBuilder.End(); pMesh->Draw(); }
static void OverlayWaterTexture( IMaterial *pMaterial, int xOffset, int yOffset, bool bFlip ) { // screen safe float xBaseOffset = IsPC() ? 0 : 32; float yBaseOffset = IsPC() ? 0 : 32; float offsetS = ( 0.5f / 256.0f ); float offsetT = ( 0.5f / 256.0f ); float fFlip0 = bFlip ? 1.0f : 0.0f; float fFlip1 = bFlip ? 0.0f : 1.0f; if( !IsErrorMaterial( pMaterial ) ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( pMaterial ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); float w = mat_wateroverlaysize.GetFloat(); float h = mat_wateroverlaysize.GetFloat(); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( xBaseOffset + xOffset * w, yBaseOffset + yOffset * h, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f + offsetS, fFlip1 + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( xBaseOffset + ( xOffset + 1 ) * w, yBaseOffset + yOffset * h, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f + offsetS, fFlip1 + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( xBaseOffset + ( xOffset + 1 ) * w, yBaseOffset + ( yOffset + 1 ) * h, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f + offsetS, fFlip0 + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( xBaseOffset + xOffset * w, yBaseOffset + ( yOffset + 1 ) * h, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f + offsetS, fFlip0 + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); } }
int C_TestTraceline::DrawModel( int flags ) { trace_t tr; Vector forward, right, up, endpos, hitpos; AngleVectors (GetAbsAngles(), &forward, &right, &up); endpos = GetAbsOrigin() + forward * MAX_TRACE_LENGTH; UTIL_TraceLine( GetAbsOrigin(), endpos, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr ); CMatRenderContextPtr pRenderContext( materials ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_pWireframe ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_LINES, 1 ); meshBuilder.Position3fv( GetAbsOrigin().Base() ); meshBuilder.Color3ub( 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3fv( tr.endpos.Base() ); meshBuilder.Color3ub( 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); // Didn't hit anything if ( tr.fraction != 1.0 ) { unsigned char color[] = { 0, 255, 0 }; DrawCube( tr.endpos, color ); } if ( (!tr.allsolid) && (tr.fractionleftsolid != 0.0) ) { unsigned char color[] = { 255, 0, 0 }; DrawCube( tr.startpos, color ); } return 1; }
//----------------------------------------------------------------------------- // Renders a material orthographically to screen... //----------------------------------------------------------------------------- static void RenderMaterial( const char *pMaterialName ) { // So it's not in the very top left float x = 100.0f, y = 100.0f; // float x = 0.0f, y = 0.0f; IMaterial *pMaterial = materials->FindMaterial( pMaterialName, TEXTURE_GROUP_OTHER, false ); if ( !IsErrorMaterial( pMaterial ) ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( pMaterial ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( x, y, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x + pMaterial->GetMappingWidth(), y, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x + pMaterial->GetMappingWidth(), y + pMaterial->GetMappingHeight(), 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( x, y + pMaterial->GetMappingHeight(), 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); } }
static void OverlayFrameBufferTexture( int nFrameBufferIndex ) { float offsetS = ( 0.5f / 256.0f ); float offsetT = ( 0.5f / 256.0f ); IMaterial *pMaterial; char buf[MAX_PATH]; Q_snprintf( buf, MAX_PATH, "debug/debugfbtexture%d", nFrameBufferIndex ); pMaterial = materials->FindMaterial( buf, TEXTURE_GROUP_OTHER, true ); if( !IsErrorMaterial( pMaterial ) ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( pMaterial ); IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); float w = mat_framebuffercopyoverlaysize.GetFloat(); float h = mat_framebuffercopyoverlaysize.GetFloat(); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( w * nFrameBufferIndex, 0.0f, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f + offsetS, 0.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( w * ( nFrameBufferIndex + 1 ), 0.0f, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f + offsetS, 0.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( w * ( nFrameBufferIndex + 1 ), h, 0.0f ); meshBuilder.TexCoord2f( 0, 1.0f + offsetS, 1.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( w * nFrameBufferIndex, h, 0.0f ); meshBuilder.TexCoord2f( 0, 0.0f + offsetS, 1.0f + offsetT ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); } }
//----------------------------------------------------------------------------- // Purpose: Renders us in the 3D view. // Input : pRender - Interface to use for rendering. //----------------------------------------------------------------------------- void CMapSideList::Render3D(CRender3D *pRender) { if (Parent->IsSelected()) { // // Draw lines from us to the center of all faces in the list. // pRender->SetRenderMode(RENDER_MODE_WIREFRAME); CMeshBuilder meshBuilder; IMesh *pMesh = MaterialSystemInterface()->GetDynamicMesh(); meshBuilder.Begin(pMesh, MATERIAL_LINES, m_Faces.Count()); for (int i = 0; i < m_Faces.Count(); i++) { CMapFace *pFace = m_Faces.Element(i); Vector Center; pFace->GetCenter(Center); unsigned char color[3]; color[0] = SELECT_EDGE_RED; color[1] = SELECT_EDGE_GREEN; color[2] = SELECT_EDGE_BLUE; meshBuilder.Color3ubv( color ); meshBuilder.Position3f(m_Origin.x, m_Origin.y, m_Origin.z); meshBuilder.AdvanceVertex(); meshBuilder.Color3ubv( color ); meshBuilder.Position3f(Center.x, Center.y, Center.z); meshBuilder.AdvanceVertex(); } meshBuilder.End(); pMesh->Draw(); } }