I have a textured ground quad consisting of a small 64 x 64 pixel texture drawn on the ground as a metal spot. I'd like to rotate this randomly 0 - 360 degrees to get some variety.
Code: Select all
function drawPatches()
local mSpots = WG.metalSpots
-- Set Matrix
gl.MatrixMode(GL.TEXTURE)
gl.PushMatrix()
gl.PolygonOffset(-25, -2)
gl.Culling(GL.BACK)
gl.DepthTest(true)
gl.Texture("maps/metal_high.png" )
gl.Color(1, 1, 1) -- fix color from other widgets
for i = 1, #mSpots do
gl.LoadIdentity()
gl.Translate(metalSpotWidth/2, metalSpotHeight/2, 0)
gl.Rotate( math.random(0, 360), 0, 1, 0)
gl.DrawGroundQuad( mSpots[i].x - metalSpotWidth/2, mSpots[i].z - metalSpotHeight/2, mSpots[i].x + metalSpotWidth/2, mSpots[i].z + metalSpotHeight/2, false, 0, 0, 1, 1)
gl.Translate(-metalSpotWidth/2, -metalSpotHeight/2, 0)
end
gl.Texture(false)
gl.DepthTest(false)
gl.Culling(false)
gl.PolygonOffset(false)
-- Restore Matrix
gl.PopMatrix()
gl.MatrixMode(GL.MODELVIEW)
end