cam/PushModelMatrix

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=PushModelMatrix |Parent=cam |Description=Pushes the specified matrix onto the render matrix stack. |Realm=Client |IsClass=No }} {{Arg |type=VMatrix |name=...")
 
(Added example.)
Line 10: Line 10:
 
|name=matrix
 
|name=matrix
 
|desc=The matrix to push.
 
|desc=The matrix to push.
 +
}}
 +
{{Example
 +
|Description=Rotates and scales text in the center of the screen.
 +
|Code=hook.Add("HUDPaint", "2d rotation test", function()
 +
local w, h = ScrW(), ScrH()
 +
local t = RealTime()*50
 +
 +
local mat = Matrix()
 +
 +
mat:Translate(Vector(w/2, h/2))
 +
mat:Rotate(Angle(0,t,0))
 +
mat:Scale(Vector(1,1,1) * math.sin(t/100) *10)
 +
mat:Translate(-Vector(w/2, h/2))
 +
 +
cam.PushModelMatrix(mat)
 +
surface.SetFont("DermaDefault")
 +
surface.SetTextColor(255, 255, 255, 255)
 +
surface.SetTextPos(w/2, h/2)
 +
surface.DrawText("LOLLOLOLOL")
 +
cam.PopModelMatrix()
 +
end)
 
}}
 
}}

Revision as of 19:43, 18 August 2013

 cam.PushModelMatrix( )

Contents

Description

Pushes the specified matrix onto the render matrix stack.

Arguments

VMatrix matrix

The matrix to push.

Examples

Example

Rotates and scales text in the center of the screen.

hook.Add("HUDPaint", "2d rotation test", function()
	local w, h = ScrW(), ScrH()
	local t = RealTime()*50
	
	local mat = Matrix()

	mat:Translate(Vector(w/2, h/2))
	mat:Rotate(Angle(0,t,0))
	mat:Scale(Vector(1,1,1) * math.sin(t/100) *10)
	mat:Translate(-Vector(w/2, h/2))

	cam.PushModelMatrix(mat)
		surface.SetFont("DermaDefault")
		surface.SetTextColor(255, 255, 255, 255)
		surface.SetTextPos(w/2, h/2)
		surface.DrawText("LOLLOLOLOL")
	cam.PopModelMatrix()	
end)


Personal tools
Navigation