Hey everyone, I was wondering if there was a way to draw a circle on the ground around an entity with a given radius and how one would go about doing such a thing?
look at 3D2D
Bad idea, you should rather look at either the mesh library or building an IMesh.
To expand on this; the steps you want to take is:
Start3D2D camera at position, angle and scale you desire ( scale is the scale of the 2d drawn objects in the world )
Draw 2d objects normally
Why is this?
Because you’d need to get the player angle, adjust it, fiddle with the position and all that.
When using a mesh you can just build this once and use it for every player.
Would I be able to make it conform to non flat surfaces?
Do you want it to morph with the terrain? Similar to how RPG games do it.
Oops, missed your last post.
Correct Drak_Thing, cam.3D2D works pretty well only it does not morph with the terrain and the circle goes bye bye when the entity goes off-screen probably because im doing it inside ENT:Draw()
EDIT: The bigger I set the circle the more spread out the pixels get which make the circle hard to see, is there any way to increase the thickness of the circle?
I’m trying to upload a screenshot but imgur is over capacity -_-*
See how the pixels are spread apart, I would ‘like’ a solid line
function ENT:Draw() self:DrawModel() cam.Start3D2D( self:GetPos()-Vector(0,0,80), Angle(0, 0, 0), 1 ) surface.DrawCircle( 0, 0, 256, Color(55,255,55,255) ) cam.End3D2D() end
Use a Material that has the shape of a solid outline of a circle and draw it using that?
That would force it to be flat though?
Can’t you use a projected texture or something?
I don’t know what that is unfortunately…
A google search of “gmod lua projected texture” did not produce any interesting results…
Actually, the dotted lines isn’t an issue its the not contouring to an unlevel surface and not drawling when the entity is not on screen, which would pose another issue of the circle going through walls
If you want it to draw when the entity is off screen, you should use PostDrawOpaqueRenderables
function ENT:PostDrawOpaqueRenderables() cam.Start3D2D( self:GetPos()-Vector(0,0,80), Angle(0, 0, 0), 1 ) surface.DrawCircle( 0, 0, 1024, Color(55,255,55,255) ) cam.End3D2D() end
No more green circle when the entity is on or off screen…
PostDrawOpaqueRenderables is a Gamemode hook…
Pretty sure I talked to you about this like half a year ago during BW2…
We did but here is the part I didn’t understand.
If it’s a GM hook its going to waste a lot of performance if I iterate through every entity to see if it’s class is that of which I am trying to put the circle around, right?
This worked without any noticeable drop in fps
function DayX.PostDrawOpaqueRenderables() for _,v in pairs(ents.GetAll()) do if ( v:GetClass() == "dx_command_main" ) then cam.Start3D2D( v:GetPos()-Vector(0,0,80), Angle(0, 0, 0), 1 ) surface.DrawCircle( 0, 0, 1024, Color(55,255,55,255) ) cam.End3D2D() end end end hook.Add("PostDrawOpaqueRenderables", "DayX.PostDrawOpaqueRenderables", DayX.PostDrawOpaqueRenderables)
edit:edit: Actually fps went down about 10% should be negligible
I think you should do ents.FindByClass, as that is shared as well (well, actually the only find function in the ents library that isn’t shared is ents.FindByName)
ents.FindByClass(_classname) returns all entities of that certain class.
On an unrelated note, I think I must’ve removed you from my friends list while I was clearing my huge ass friends list. Lol.
why don’t you just create a circle entity and attach it to the player? then you don’t have to loop over all the players and add circles to them every time.
Also what I meant about the projected texture was the same idea behind the lamp stool.
Tried looking at env_projectedtexture but can’t seem to get it to work right now.