• Panels on 3D2D surface?
    22 replies, posted
Doesn't seem to work, draws it on the screen, anyone want to help me? The hud_panel_1 was created outside the ENT:Draw function. Also, pos ang and self.HudMultiplyer are defined just for a heads up. I wanted to use panels so I could have press/click functions. and so the content inside the panel would disappear after the 1000 pixel boundary. [lua] cam.Start3D2D( pos, ang, 0.03187 * self.HudMultiplyer ); hud_panel_1.Paint = function( ) surface.SetDrawColor( 255, 0, 0, 255 ); surface.DrawRect( 0, 0, 1000, 1000 ); draw.DrawText( "Corn", "test_font2", 0, 0, Color( 255, 255, 255, 255 ), ALIGN_LEFT ); end; cam.End3D2D( ); [/lua]
You're starting 2D3D, setting up the panel's paint function and then ending 3D2D resulting into it drawing in 2D space. You have to start 3D2D mode inside the drawing function, doing it this way.
[QUOTE=Overv;17987323]You're starting 2D3D, setting up the panel's paint function and then ending 2D2D resulting into it drawing in 2D space. You have to start 3D2D mode inside the drawing function, doing it this way.[/QUOTE] Like this? [lua] hud_panel_1.Paint = function( ) cam.Start3D2D( pos, ang, 0.03187 * self.HudMultiplyer ); surface.SetDrawColor( 255, 0, 0, 255 ); surface.DrawRect( 0, 0, 1000, 1000 ); draw.DrawText( "Corn", "test_font2", 0, 0, Color( 255, 255, 255, 255 ), ALIGN_LEFT ); cam.End3D2D( ); end; [/lua]
Yes, like that. There was a thread with some code demonstrating how to do this. Let me look it up for you. [editline]06:45PM[/editline] Here it is: [url]http://www.facepunch.com/showpost.php?p=15011981&postcount=3[/url]
Does anyone have base_panel, because I guess his server is down for now from reading the thread.
I PM'd him a while ago asking for a re-upload. We'll just have to wait.
[QUOTE=Overv;17991986]I PM'd him a while ago asking for a re-upload. We'll just have to wait.[/QUOTE] Thanks, :D
[QUOTE=iRzilla;17992181]Nobody likes PANEL:PaintManual() these days?[/QUOTE] How would I implement that into my script? [lua] hud_panel_1.PaintManual = function( ) cam.Start3D2D( pos, ang, 0.03187 * self.HudMultiplyer ); surface.SetDrawColor( 255, 0, 0, 255 ); surface.DrawRect( 0, 0, 1000, 1000 ); draw.DrawText( "Corn", "test_font2", 0, 0, Color( 255, 255, 255, 255 ), ALIGN_LEFT ); cam.End3D2D( ); end; [/lua] Because when I try this: [lua] hud_panel_1.Paint = function( ) cam.Start3D2D( pos, ang, 0.03187 * self.HudMultiplyer ); surface.SetDrawColor( 255, 0, 0, 255 ); surface.DrawRect( 0, 0, 1000, 1000 ); draw.DrawText( "Corn", "test_font2", 0, 0, Color( 255, 255, 255, 255 ), ALIGN_LEFT ); cam.End3D2D( ); end; [/lua] nothing shows up on the sent.
[quote=irzilla;17992778][lua] hud_panel_1.paint = function( ) surface.setdrawcolor( 255, 0, 0, 255 ) surface.drawrect( 0, 0, 1000, 1000 ) draw.drawtext( "corn", "test_font2", 0, 0, color( 255, 255, 255, 255 ), align_left ) end hud_panel_1:setpaintedmanually(true) [/lua] [lua] function sent:draw() cam.start3d2d( self:getpos(), angle(0, 0, 0), 1 ) hud_panel_1:paintmanual() cam.end3d2d() end [/lua][/quote] Thank you :D Oh, and too the people who rated me dumb because I just wanted help. Go fuck yourself.
Everything seems to work, just not the boundary part. Even tried making another parent panel. Maybe add support Garry? Or, is it from the engine?
Sorry for my server being offline. I uploaded a mirror: [url]http://uploading.com/files/ad56m9bm/base_panel.zip/[/url] There is just one problem at the moment, that for a yet unknown reason the script itself seems not to work as expected anymore (the example "advert" SENT doesn't work). But the base_panel SENT should work and in the code, you'll see an example on how to realize what you wish. Good luck [editline]09:36PM[/editline] [QUOTE=iRzilla;17992181]Nobody likes PANEL:PaintManual() these days?[/QUOTE] That's actually what I do use in my base_panel SENT. And yes, that's what you need to use for this.
Im confused. I got the base_panel, and i pasted this code in the cl_init.lua [CODE] --################### Create the HTML Panel we want to draw on @aVoN function ENT:CreatePanel() local panel = vgui.Create("NewHTML"); if(not IsValid(panel)) then return end; panel:SetScrollBars(false); panel:SetLoading(true); panel:SetSize(0,0); return panel; end --################### Panel created successfully @aVoN function ENT:OnPanelCreated(panel) if(self.Data) then panel:OpenURL(self.Data[1]); self:SetSizes(panel,self.Data[2],self.Data[3],self.Data[4]); else RunConsoleCommand("__AdvertGetData",self.Entity:EntIndex()); -- Tell server to send us data about what to draw end end --################### Animation-Mode? @aVoN function ENT:PrePanelDraw(panel,w,h) if(self.Data and self.Data[5]) then panel:Animate(); end end --################### Draws an overlay @aVoN local overlay = surface.GetTextureID("Decals/light"); function ENT:PostPanelDraw(panel,w,h) if(self.Data and not self.Data[6]) then surface.SetDrawColor(0,0,0,60); surface.DrawRect(0,0,w,h); surface.SetTexture(overlay); surface.DrawTexturedRect(0,0,w,h); end end [/CODE] And whats next?
nvm xD but now i have another question. How do i make so e.g i have a html site with only a banner, how do i make so only the banner shows and not the white background, could i do it transparent?
Why only the banner? If you want to show a texture, make a VTF send it to the Client, and draw it trough there?
Banner ads can't be vtf'd on the fly.
can i even make a transparent bg? from the code.
No, use a texture.
Can you draw derma on 3D2D?
[QUOTE=Overv;21712756]No, use a texture.[/QUOTE] um, that sounds hard. Could you give any code for that? and do you mean this is insted of a HTML/URL?
Sorry, you need to Log In to post a reply to this thread.