• Static drawing after viewmodel.
    5 replies, posted
I'm currently working on a 3d hud for darkrp.. to render this I decided to use PostDrawViewModel, since this offers me the possibility to use 3d2d to draw in front of the viewmodel of the weapon. This works good, except one problem: The distance to the 3d projection differs, depending on the weapon. Is there anyway to normalize the distance between the 3d projection and the camera, independent of the weapon, the user is holding ? Or is there a better hook that offers a static drawing environment after the viewmodel has been drawn ? [URL=http://www7.pic-upload.de/15.12.13/us6ozvj7aw82.jpg][IMG]http://www7.pic-upload.de/thumb/15.12.13/us6ozvj7aw82.jpg[/IMG][/URL] [URL=http://www7.pic-upload.de/15.12.13/44xo46zygi8k.jpg][IMG]http://www7.pic-upload.de/thumb/15.12.13/44xo46zygi8k.jpg[/IMG][/URL] [URL=http://www7.pic-upload.de/15.12.13/pmgt8uxvl9.jpg][IMG]http://www7.pic-upload.de/thumb/15.12.13/pmgt8uxvl9.jpg[/IMG][/URL] Example code for the ammobox in the right corner: [CODE]local function AmmoBox() local x,y = 30,0 local localplayer = LocalPlayer() if(localplayer:Alive() and localplayer:GetActiveWeapon())then local ang = LocalPlayer():EyeAngles() local pos = LocalPlayer():EyePos() + LocalPlayer():GetAimVector( )*rightDistance + ang:Right() * 7.5 + ang:Up() * -5 ang:RotateAroundAxis( ang:Forward(), 0 ) ang:RotateAroundAxis( ang:Right(), 0 ) ang:RotateAroundAxis(ang:Up(), 55+180) cam.Start3D2D(pos, Angle( ang.p, ang.yaw, ang.r-270 ), 0.02) cam.IgnoreZ(true) local mag_left = localplayer:GetActiveWeapon():Clip1() local mag_extra = localplayer:GetAmmoCount(localplayer:GetActiveWeapon():GetPrimaryAmmoType()) draw.RoundedBox(0, x + 4, y, 200 - 8, 20, Color(0,0,0,200)) draw.SimpleTextOutlined(localplayer:GetActiveWeapon():GetPrintName(), "DarkRPHUD1", x + 4 + (200 - 8)/2, y+2, Color(255,255,255,200), 1, 0, 1, Color(0,0,0,255)) y = y + 20 if(mag_left >= 0)then draw.RoundedBox(0, x + 4, y, 200 - 8, 20, Color(0,0,0,200)) draw.SimpleTextOutlined(mag_left .. "/" .. mag_extra, "DarkRPHUD1", x + 4 + (200 - 8)/2, y+2, Color(255,255,255,200), 1, 0, 1, Color(0,0,0,255)) end cam.IgnoreZ(false) cam.End3D2D() end end hook.Add("PostDrawViewModel", "ZEDHud_Draw", AmmoBox)[/CODE]
Check this out: [url]http://wiki.garrysmod.com/page/Render_Order[/url]
[QUOTE=Robotboy655;43190493]Check this out: [url]http://wiki.garrysmod.com/page/Render_Order[/url][/QUOTE] Most of them don't support 3D2D drawing and 3D2D doesn't seem to work anymore in HUDPaint. [QUOTE=Handsome Matt;43190666]You need to take into account the FOV for different weapons. (maybe) Check the Player:GetFOV( ) for the different weapons to see if I'm right.[/QUOTE] The idea is good, but sadly it stays the same.
[QUOTE=IZED;43190717]Most of them don't support 3D2D drawing and 3D2D doesn't seem to work anymore in HUDPaint. The idea is good, but sadly it stays the same.[/QUOTE] In 2D drawing hooks, like HUDPaint, you must start a 3D cam before you can draw any 3D stuff, like 3D2D stuff.
[QUOTE=Robotboy655;43190733]In 2D drawing hooks, like HUDPaint, you must start a 3D cam before you can draw any 3D stuff, like 3D2D stuff.[/QUOTE] Sorry for the late answer. It worked, thanks.
Sorry, you need to Log In to post a reply to this thread.