Blur without derma.

Hey,

Quick question here, how do I draw a blurred RoundedBox?

Kind regards,
BremFM

[lua]local blur = Material(“pp/blurscreen”)

function surface.DrawBlurRect(x, y, w, h, amount, heavyness)
local X, Y = 0,0
local scrW, scrH = ScrW(), ScrH()

surface.SetDrawColor(255,255,255)
surface.SetMaterial(blur)

for i = 1, heavyness do
	blur:SetFloat("$blur", (i / 3) * (amount or 6))
	blur:Recompute()

	render.UpdateScreenEffectTexture()

	render.SetScissorRect(x, y, x+w, y+h, true)
		surface.DrawTexturedRect(X * -1, Y * -1, scrW, scrH)
	render.SetScissorRect(0, 0, 0, 0, false)
end

end[/lua]

Why thank you.

However, I have decided to be using DPanel.



local scrh = ScrH()
local scrw = ScrW()

	HUDF = vgui.Create("DPanel")
	HUDF:ParentToHUD()
	HUDF:SetSize(400,190)
	HUDF:SetPos(10,scrh - 200)
	HUDF:SetExpensiveShadow(10, Color(0,0,0,255))
        HUDF:SetBackgroundBlur("true")


Why is that not working?

DFrame:SetBackgroundBlur only works with DFrames.

Welcome :smiley:

Would this work then?



local scrh = ScrH()
local scrw = ScrW()

	HUDF = vgui.Create("DFrame")
	HUDF:SetSize(400,190)
	HUDF:SetPos(10,scrh - 200)
	HUDF:ParentToHUD()
	HUDF:SetExpensiveShadow(10, Color(0,0,0,255))
	HUDF:SetBackgroundBlur("true")
	HUDF:ShowCloseButton("false")


[editline]12th December 2016[/editline]

Okay nevermind, that just blurs out everything EXCEPT the frame. So, how do I get a blurred background on my DPanel? Sorry for asking so many questions, this is like my first HUD ever and am still kind of confused.

You shouldn’t have quotes around your boolean values. The string false is truthy value.



local b = "false"
if b then
    print("true")
else
    print("false")
end

That would print “true”

You can paint. Panels :smiley:

I found the solution and will post it tomorrow if anyone’s interested.

Next question though, how would I make the upper half of the current player’s player model appear inside of a DPanel? I probably know how to put it in the DPanel, but I can’t seem to find a function or anything that renders the upper half of the player model. If someone could help me out, that’d be great.

What have you tried already? Majority of these questions here are always “How to do this i want to do this.” and people never really try to figure it out on there own.

I searched on the wiki. When typing PlayerModel it only gives 2 results; none of which are the answer. When typing model alone it gives too many results too search through. As I mentioned earlier, this is my first HUD ever so I’m very new to basically anything.

With the model panel you’d need to change where the camera is focusing on.




local plymodel = vgui.Create("DModelPanel","HUDF")

plymodel:SetModel(LocalPlayer():GetModel())
plymodel:SetCamPos(idk??)



This is how far I came :frowning: Again I do apologize as this is my first HUD and pretty much script aswell. How do I find the a campos that shows pretty much the upper part of the body (starting somewhere from the bellybutton :P)

Thanks for the help so far!

The second argument of vgui.Create needs to be a panel. You’ve put a string.

Oh yeah my bad, I wrote that on my phone. Sorry.

Do you happen to know how to use the SetCamPos properly to achieve what I wish to achieve?

[editline]12th December 2016[/editline]

Crap, I accidentally rated your post Disagree. Dunno how to remove that, sorry

Can we just take a look at the wiki for more than a couple seconds? I’m aware the example in the Wiki is not spot on perfect for what you want however… If you just inputted some other values and messed with it you could of achieved your results. Heres the example FROM THE WIKI.

[lua]
BGPanel = vgui.Create( “DPanel” )
BGPanel:SetPos( 20, 20 )
BGPanel:SetSize( 200, 200 )
BGPanel:SetBackgroundColor( Color( 0, 0, 0, 255 ) )

local mdl = vgui.Create( “DModelPanel”, BGPanel )
mdl:SetSize( BGPanel:GetSize() )
mdl:SetModel( “models/player/gman_high.mdl” )

function mdl:LayoutEntity( ent )
ent:SetSequence( ent:LookupSequence( “menu_gman” ) )
mdl:RunAnimation()
return
end

local eyepos = mdl.Entity:GetBonePosition( mdl.Entity:LookupBone( “ValveBiped.Bip01_Head1” ) )

eyepos:Add( Vector( 0, 0, 2 ) ) – Move up slightly

mdl:SetLookAt( eyepos )

mdl:SetCamPos( eyepos-Vector( -12, 0, 0 ) ) – Move cam in front of eyes

mdl.Entity:SetEyeTarget( eyepos-Vector( -12, 0, 0 ) )
[/lua]

I checked that put but don’t understand how to use it. I don’t want to use the gman mdl, but the player model. I don’t understand how that script works so I was hoping that someone could explain it a little bit to me. I don’t wanna be using code that I don’t underdtand.

[editline]13th December 2016[/editline]

I think I’ve got it figured out (partially)

http://images.akamai.steamusercontent.com/ugc/177161519231044112/CAE7E7A99F653DE55C734CDE8300779FA3A6B33B/

Why is the character turning around constantly? I want to freeze his model at the position I set earlier.




// Top bar
local TBAR = vgui.Create("DPanel", HUDF)
TBAR:Dock(TOP)
TBAR:SetHeight(60)

function TBAR:Paint(w,h)
	surface.SetDrawColor(Color(50,50,50,250))
	surface.DrawRect(0,0,400,30)
end


// Left panel
local BGMDL = vgui.Create("DPanel", HUDF)
BGMDL:Dock(LEFT)
BGMDL:SetWidth(150)

function BGMDL:Paint(w,h)
	surface.SetDrawColor(Color(100,100,100,250))
	surface.DrawRect(0,0,150,130)
end

local PLYMDL = vgui.Create("DModelPanel", BGMDL)

PLYMDL:SetSize(150, 110)
PLYMDL:SetModel( LocalPlayer():GetModel() )
PLYMDL:SetFOV(50)
PLYMDL:SetCamPos( Vector( 25, -15, 60 ) )
PLYMDL:SetLookAt( Vector( 0, 0, 60 ) )


Thanks in advance.

Take a look at example 2 here http://wiki.garrysmod.com/page/Category:DModelPanel

The wiki lists every single function you would need, you need to start looking at it more and figuring it out.

LayoutEntity will do this for you.

I checked it out earlier but it says I really shouldn’t use it. I’m scared of breaking my game so maybe I should look for another solution?

[editline]13th December 2016[/editline]



// Playermodel

local PLYMDL = vgui.Create("DModelPanel", BGMDL)

PLYMDL:SetSize(150, 110)
PLYMDL:SetModel( LocalPlayer():GetModel() )
PLYMDL:SetFOV(50)
PLYMDL:SetCamPos( Vector( 25, -15, 60 ) )
PLYMDL:SetLookAt( Vector( 0, 0, 60 ) )

function PLYMDL:LayourEntity(PLYMDL)
end



still doesnt do anything? ugh this stuff is so confusing!

[editline]13th December 2016[/editline]

nvm, I’m retarded, typo in LayourEntity kek

(bold added by me)

The phrasing on the wiki is a little confusing but ‘shouldn’t use it’ is meaning you don’t/shouldn’t need to actually call the function ie. you should never need to call pnl:LayoutEntity() yourself, the engine will call it for you. However you can override the function, so the engine will call your new function for you.