Need some help.
I need to render a cube with a texture .. tho it crashes when I try to run it under "PostDrawOpaqueRenderables".
[lua]
local function DrawCube(v,v2,mat,col,ang)
if !mat or type(mat)!="string" then mat = "models/shiny" end
if !ang then ang = Angle(0,0,0) end
if !col then col = {255,255,255,255} end
col = Color(col[1],col[2],col[3],col[4])
render.SetMaterial( Material(mat) );
--render.SetColorModulation(col)
local size = v2-v
local center = v+size/2
if size.x<0 then size.x = -size.x end
if size.y<0 then size.y = -size.y end
if size.z<0 then size.z = -size.z end
local matrix = Matrix( );
matrix:Translate( center );
matrix:Scale( size );
matrix:Rotate( ang );
local up = Vector( 0, 0, 1 );
local right = Vector( 1, 0, 0 );
local forward = Vector( 0, 1, 0 );
local down = up * -1;
local left = right * -1;
local backward = forward * -1;
cam.PushModelMatrix( matrix );
mesh.Begin( MATERIAL_QUADS, 6 );
mesh.QuadEasy( up / 2, up, 1, 1 );
mesh.QuadEasy( down / 2, down, 1, 1 );
mesh.QuadEasy( left / 2, left, 1, 1 );
mesh.QuadEasy( right / 2, right, 1, 1 );
mesh.QuadEasy( forward / 2, forward, 1, 1 );
mesh.QuadEasy( backward / 2, backward, 1, 1 );
mesh.End( );
cam.PopModelMatrix( );
end[/lua]
You need to change the mesh to the x y z and z7 coordinates. That way the engine doesn't ask the graphics card to export the vertex.vtf into png
[QUOTE=Sally;42951860]You need to change the mesh to the x y z and z7 coordinates. That way the engine doesn't ask the graphics card to export the vertex.vtf into png[/QUOTE]
I'll admit that i'm not familiar with how mesh's work and I kinda just pulled scripts together from the wiki.
Do you mean I should drop the cam.PushModelMatrix and instead put the position into the mesh?
Uh, why not use render.DrawBox?
[QUOTE=Robotboy655;42951970]Uh, why not use render.DrawBox?[/QUOTE]
Good question .. can be answered with another: "Should you do lua at nearly 2am"? :P
(Thx for the help btw)
Sorry, you need to Log In to post a reply to this thread.