Rendering in 3D2D help.

I’m trying to draw a translucent rectangle in the world that properly aligns with a nav area.

So what I have looks like this, the green outlined rectangles are what I’m wanting to ‘fill’ in with a solid color. The white rectangles are what I’ve figured out so far but they aren’t aligning properly as you can see. I tried using DrawPoly but it’s 2d only and I feel like theres a better way to go about this.

Here’s the current code from the picture above.



hook.Add( "PostDrawTranslucentRenderables", "FGT_DrawNavMesh", function( isSkybox )
    if( isSkybox or not IsValid( lPly ) ) then
        lPly = LocalPlayer()
        return
    end
    
    for id, nav in pairs( NearbyNavs ) do
        render.DrawLine( nav.corners[1], nav.corners[2], Color( 0, 255, 0 ), false )
        render.DrawLine( nav.corners[2], nav.corners[3], Color( 0, 255, 0 ), false )
        render.DrawLine( nav.corners[3], nav.corners[4], Color( 0, 255, 0 ), false )
        render.DrawLine( nav.corners[4], nav.corners[1], Color( 0, 255, 0 ), false )
        
        local ang = (nav.corners[3] - nav.corners[4]):Angle()
        cam.Start3D2D( nav.corners[4] + Vector(0,0,1), ang, 1 )
            surface.SetDrawColor( 255, 255, 255, 80 )
            
            surface.DrawRect( 0, 0, nav.width, nav.height )
        cam.End3D2D()
    end
end )


Basically the issue I’m having is I don’t know how to go about getting the angle for the Start3D2D.

If you want to continue to use 2D3D, you need to find the normal of the plane to find the angle.

Instead of 2d3d, you can use render.DrawQuad which is a 3D drawing function.
It takes vertices instead of origin/width/height.

[del]DrawQuad really doesn’t want to cooperate. It isn’t throwing errors but it seems to break auto-refresh for scripts and it doesn’t draw anything. I’ll give the normals a shot.[/del]

EDIT: Weird I have no clue what/how I broke but auto-refresh refuses to reload anything now. So probably not an issue with DrawQuad.

Here’s an example of drawing a cube: https://dl.dropboxusercontent.com/u/26074909/tutoring/render_lasers_rendering_cubes.lua.html - not solid though… BUT, I have noticed when drawing poly circles, if I don’t do something in particular, the alpha is ignored ( when full solid it appears transparent )…

Try adding: draw.NoTexture( );

Right before you draw / fill in and before you set the render color…

I got it partially working, issue now is that the material only draws on one side. And that side decides to face down.

Aaaand right as I posted this I though, ‘Well just try feeding it the verts backwards’. Lo and behold that works :v: