Hai,
Currently I want to draw a laser up to the Sky, but when the entity gets out of sight, the laser isn't drawed
[vid]http://johnnycrazy.de/public/videos/hl2.webm[/vid]
So i need to create a hook on PostDrawOpaqueRenderables?
BTW: It should be always visible
Thanks,
How are you drawing the laser?
Currently in the ENT:Draw hook:
[LUA]
function ENT:Draw()
self:DrawModel() --Draw model
local startpos = self:GetPos()
local spos = self:GetPos()
local ang = self:GetAngles()
ang:RotateAroundAxis(ang:Right(),90)
local epos = self:GetPos() + (ang:Forward()*16384 )
local tr = util.TraceLine({start=spos,endpos=epos ,filter= self,mask=MASK_SOLID})
local endpos = tr.HitPos
render.SetMaterial( laser )
render.DrawBeam( startpos, endpos, 5, 1, 1, Color( 255, 255, 255, 255 ) )
end
[/LUA]
You should probably use a hook, yeah.
Okay, now: Which one? It should be always visible, no excuses :D
PostDrawTranslucentRenderables = Only Displayed if you have free sight on it
PreDrawTranslucentRenderables = Same
PostDrawOpaqueRenderables = Same
PreDrawOpaqueRenderables = Same
It shoud be drawed always
No, that's caused by renderbounds. No need for hooks.
[url]http://wiki.garrysmod.com/page/Entity/SetRenderBounds[/url]
[QUOTE=Robotboy655;43099698]No, that's caused by renderbounds. No need for hooks.
[url]http://wiki.garrysmod.com/page/Entity/SetRenderBounds[/url][/QUOTE]
It feels like it's the wrong approach to the problem to just have a huge renderbound.
[editline]7th December 2013[/editline]
I mean, it works fine in this situation without making it huge because the laser is axis-aligned relative to the entity (and just scaling it according to the trace length), but if it wasn't it just seems wrong. I don't know, I guess I just really like universal solutions :v:
Okay, got it working now, but still, i dont see the laser through walls etc.
//EDIT:
Oh, i forgot to mention, that these lasers also can be placed on walls:
[IMG]http://i.imgur.com/vbDCqob.jpg[/IMG]
So this:
[LUA]
local min,max = self:GetRenderBounds()
self:SetRenderBounds(min,max + endpos)
[/LUA]
won't work
//EDIT2
A hook would be better in this situation would'nt it?
Just make it draw everywhere, it isn't going to impact performance unless you put hundreds of those.
[editline]7th December 2013[/editline]
If the hook works, use it.
Okay, but do you have any suggestions on how to achieve drawing it through walls?
Use a hook that is called after everything else is rendered.
Holy, i don't get it...
ATM i use PostDrawTranslucentRenderables, which should be the correct hook, but then this happens:
[vid]http://johnnycrazy.de/public/videos/hl3.webm[/vid]
It's getting called, but it's not drawn...
Try calling [b][url=http://gmodwiki.net/Lua/Libraries/render/ClearDepth]Lua/Libraries/render/ClearDepth[img]http://gmodwiki.net/favicon.ico[/img][/url][/b] after or before drawing it.
Thanks again, now its working, but:
[IMG]http://i.imgur.com/GKcfP4O.jpg[/IMG]
[b][url=http://gmodwiki.net/Lua/Libraries/render/OverrideDepthEnable]Lua/Libraries/render/OverrideDepthEnable[img]http://gmodwiki.net/favicon.ico[/img][/url][/b]
Try enabling that before drawing it and then disabling it immediately after.
[editline]7th December 2013[/editline]
So like this:
[lua]
render.OverrideDepthEnable( true, true )
render.DrawBeam()
render.OverrideDepthEnable( false, false )
[/lua]
So my current code:
[LUA]
render.SetMaterial( laser )
render.OverrideDepthEnable( true, true )
render.DrawBeam( startpos, endpos, 5, 1, 1, Color( 255, 255, 255, 255 ) )
render.OverrideDepthEnable( false, false )
--render.ClearDepth()
[/LUA]
ClearDepth before drawing = Laser visible, but also creepy lamps
ClearDepth after drawing = only creepy Lamps, no laser visible
no ClearDepth = no creepy lamps, no laser visible
Ow god,
edit:
Using PostDrawTranslucentRenderables
//push
a pretty simple question:
How to draw a Beam through Walls etc, without seeing lights/lamps through walls
Solved using surface.DrawLine in the HUDPaint Hook
Sorry, you need to Log In to post a reply to this thread.