local meshMat
= Material(
"concrete/concretefloor001a" )
local meshVertices
= {
{ pos
= Vector(
0,
0,
0 ), u0
= 0, v0
= 0, u1
= 0, v1
= 0, n
= Vector(
1,
0,
0 )
},
{ pos
= Vector(
0,
100,
0 ), u0
= 1, v0
= 0, u1
= 3, v1
= 0, n
= Vector(
1,
0,
0 )
},
{ pos
= Vector(
0,
100,
-100 ), u0
= 1, v0
= 1, u1
= 3, v1
= 3, n
= Vector(
1,
0,
0 )
},
{ pos
= Vector(
0,
0,
-100 ), u0
= 0, v0
= 1, u1
= 0, v1
= 3, n
= Vector(
1,
0,
0 )
},
}
concommand.
Add(
"meshtest",
function()
meshLightmap
= GetRenderTarget(
"test_mesh_lightmap",
128,
128,
false )
render.
PushRenderTarget( meshLightmap )
cam.
Start2D()
render.
Clear(
128,
128,
128,
255 )
render.
SetColorMaterial()
surface.
SetDrawColor(
80,
80,
80,
255 )
surface.
DrawRect(
32,
32,
64,
64 )
draw.
SimpleText(
"This is lightmap",
"DermaDefault",
64,
64,
Color(
255,
0,
0,
255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
cam.
End2D()
render.
PopRenderTarget()
myTestMesh
= Mesh( meshMat )
mesh.
Begin( myTestMesh, MATERIAL_QUADS,
1 )
for i, vertex
in pairs( meshVertices )
do
mesh.
Position( vertex.pos )
mesh.
TexCoord(
0, vertex.u0, vertex.v0 )
mesh.
TexCoord(
1, vertex.u1, vertex.v1 )
mesh.
Normal( vertex.n )
mesh.
AdvanceVertex()
end
mesh.
End()
end )
hook.
Add(
"PostDrawOpaqueRenderables",
"LightmappedMeshTest",
function()
if myTestMesh
and myTestMesh
~= NULL
then
render.
SetMaterial( meshMat )
render.
SetLightmapTexture( meshLightmap )
myTestMesh:
Draw()
end
end )