My goal is to have a model on your HUD, that will animate, but also have text on it (it needs to be 3D). The text part is the only thing stopping me right now, and my trial and error attempts have gotten me nowhere.
[[url=http://luabin.foszor.com/code/addons/derma/lua/vgui/DModelPanel.lua]source[/url]]
Two suggestions: Either do something with the paint hook, or make it load a clientside SEnt rather than a ClientsideModel.
I can't get anything to work inside it's Paint hook. I tried doing a clientside entity which didn't work at all, but then a quick search led me to using an effect in place of a clientside SEnt. I can get the text to show up in the world under EFFECT:Render() but I'm not sure how to get that to show up in my panel.
I'm rather clueless when it comes to these cam functions so I appreciate the help.
You have to copy and edit the DModelPanel. Place your 3D2D stuff right after self.Entity:DrawModel and it should work.
[QUOTE=Nevec;19678192]You have to copy and edit the DModelPanel. Place your 3D2D stuff right after self.Entity:DrawModel and it should work.[/QUOTE]
Yea, that's what I've been working with since my last post. I haven't had any success in getting anything to show up.
[lua]//PANEL:Paint()
local x, y = self:LocalToScreen(0, 0);
local pos = Vector(50, 0, 10);
cam.Start3D(pos, (self.Entity:GetPos() - pos):Angle(), 85, x, y, self:GetWide(), self:GetTall())
cam.IgnoreZ(true);
render.SuppressEngineLighting(true);
render.SetLightingOrigin(self.Entity:GetPos());
render.ResetModelLighting(1, 1, 1);
render.SetColorModulation(1, 1, 1);
render.SetBlend(1);
self.Entity:DrawModel();
cam.Start3D2D(self.Entity:GetPos(), self.Entity:GetForward():Angle(), 1)
//self.Entity:DrawModel();
draw.SimpleText("TESTING", "ScoreboardText", 0, 0, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
cam.End3D2D()
render.SuppressEngineLighting(false);
cam.IgnoreZ(false);
cam.End3D()[/lua]
I've tried a variety of different positions and angles and I can't get anything to show up. I even set it up without my model there at all, and simply made the 3D and 3D2D cameras point at each other with no entity angles there that might screw it up, still nothing. :frown:
Am I just doing it incorrectly?
It works, your positions/angles are just wrong. Move the 3D camera away and the 3D2D camera up a bit.
I don't see how they could be wrong, I even set up this just to see if I could get any text to show up at all and I still get nothing.
[lua]cam.Start3D(Vector(0, 0, 50), Vector(0, 0, -1):Angle(), 85, x, y, self:GetWide(), self:GetTall())
cam.IgnoreZ(true);
render.SuppressEngineLighting(true);
render.SetLightingOrigin(self.Entity:GetPos());
render.ResetModelLighting(1, 1, 1);
render.SetColorModulation(1, 1, 1);
render.SetBlend(1);
cam.Start3D2D(Vector(0, 0, 0), Vector(0, 0, 1):Angle(), 1)
draw.SimpleText("TESTING", "ScoreboardText", 0, 0, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP);
cam.End3D2D()
render.SuppressEngineLighting(false);
cam.IgnoreZ(false);
cam.End3D()[/lua]
Camera facing down, text facing up. Something that simple should surely show up, no? Maybe I'm just way off base? :confused:
Hm, after doing some research, I've found that the 3D2D angle is actually rotated 90 degrees to the side. 0, 0, 1 now points to the side, 1, 0, 0 points upwards. You'll have to rotate your up facing angle -90 to the right for the text to show up, possibly even more for different angles.
Sorry, you need to Log In to post a reply to this thread.