This is solved, check my latest post

I’m probably doing something stupid but:

local mat = Material( “models/props_wasteland/wood_fence01a” )
local obj = Mesh()
local verts = {
{ pos = LocalPlayer():GetPos() + Vector( 0, 0, 0 ), u = 0, v = 0 },
{ pos = LocalPlayer():GetPos() + Vector( 100, 0, 0 ), u = 1, v = 0 },
{ pos = LocalPlayer():GetPos() + Vector( 100, 100, 0 ), u = 1, v = 1 }

obj:BuildFromTriangles( verts )

hook.Add( “PostDrawOpaqueRenderables”, “IMeshTest”, function()
render.SetMaterial( mat )
end )

Isn’t drawing for me, I’ve checked that the hooks are being called correctly, no errors as far as I can tell.
Followed from here, the original example wasn’t working for me either, but I just assumed that the co-ordinates of Vector(0,0,0) made it unreachable for me.

Don’t forget that it draws only one triangle, and you will only be able to see it from specific direction. ( Because culling, unless you use $nocull material )

I knew I’d done something stupid, thanks. You had to look underneath, which I hadn’t bothered to check.

Also solved, thanks again RobotBoy

I’m running with the issue of optimization, currently, I’m using this:

cam.PushModelMatrix( matrix );
mesh.Begin( MATERIAL_TRIANGLES, table.Count(model) )
for k, v in pairs(model) do
EasyVert(Vector(v[3][1], v[3][2], v[3][3]), vector_up )
EasyVert(Vector(v[2][1], v[2][2], v[2][3]), vector_up )
EasyVert(Vector(v[1][1], v[1][2], v[1][3]), vector_up )
mesh.End( )
cam.PopModelMatrix( )

Instead of IMesh’s to draw my object, but this is creating problems, a single teapot grinds my FPS from 150 to 50. I’m thinking this is because I’m essentially rebuilding it all through Lua, is there any way to make use of IMesh, but still use transformations to move the mesh’s location. I can’t seem to find the way of altering the vertexes position once set so that, for example, it follows an entity.

Uh, call obj:Draw() inside a model matrix?


Looks like I’ve found one more issue, after painlessly fixing a bunch of bugs, and rewriting my code. I finally got texturing to half work, I’m thinking this is something to do with meshes or how I’m texturing it.

Any ideas?


Textured /w Wireframe:


Test Code:

function ENT:Draw()
if not self.m_Model then
self.m_Model = NewmanModel.New(NEWMAN_WAVEFRONT, NEWMAN_FILE, “objmodels/t90.txt”)
self.m_Model:SetMaterial(“Gun”, Material(“tankObj/Gun.png”))
self.m_Model:SetMaterial(“Main_Body_2”, Material(“tankObj/Main Body 2.png”))
self.m_Model:SetMaterial(“Main_Body”, Material(“tankObj/Main Body.png”))
self.m_Model:SetMaterial(“Turret”, Material(“tankObj/Turret.png”))




Try playing with, if it doesn’t help, invert all your polygons.