# cam.PushModelMatrix

- **Ortam:** İstemci
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/cam.PushModelMatrix
- **Çeviri tarihi:** 2026-04-13

```lua
cam.PushModelMatrix( VMatrix matrix, boolean multiply = false )
```

## Açıklama

Belirtilen matrisleri gösterim matrisi yığınına gönderir. [cam. PopModelMatrix](https://gmod.tr/wiki/cam.PopModelMatrix).

Kullanıldığında: [PANEL:Paint](https://gmod.tr/wiki/PANEL:Paint), Eğer panelin sol üst pozisyonuna güvenmek istiyorsanız, kullanmalısınız [VMatrix:Translate](https://gmod.tr/wiki/VMatrix:Translate) panelin ekrana göre (0, 0) konumuyla.

Eğer onunla kullanmaya çalışıyorsan... [cam. Start3D2D](https://gmod.tr/wiki/cam.Start3D2D), set `multiply` ...ya da `true`Çünkü... **cam. Start3D2D** Kendi model matrisini itiyor.

## Argümanlar

1.. [VMatrix](https://gmod.tr/wiki/VMatrix) **matris**: İtmek için matris.
2.. [Boolean](https://gmod.tr/wiki/boolean) **çoğaltmak** = yanlış: Eğer ayarlanırsa, verilen matrisin şu anda aktif olan ([cam. GetModelMatrix](https://gmod.tr/wiki/cam.GetModelMatrix)İtmeden önce.

### Örnek

Basit function to çevirilmiş ve/veya ölçeklendirilmiş metin çiz.

```lua
local vector_one = Vector( 1, 1, 1 )
function draw.RotatedText( text, font, x, y, color, ang, scale )
	render.PushFilterMag( TEXFILTER.ANISOTROPIC )
	render.PushFilterMin( TEXFILTER.ANISOTROPIC )

	local m = Matrix()
	m:Translate( Vector( x, y, 0 ) )
	m:Rotate( Angle( 0, ang, 0 ) )
	m:Scale( vector_one * ( scale or 1 ) )

	surface.SetFont( font )
	local w, h = surface.GetTextSize( text )

	m:Translate( Vector( -w / 2, -h / 2, 0 ) )

	cam.PushModelMatrix( m, true )
		draw.DrawText( text, font, 0, 0, color )
	cam.PopModelMatrix()

	render.PopFilterMag()
	render.PopFilterMin()
end

hook.Add("HUDPaint", "2d rotation test", function()
	local w, h = ScrW(), ScrH()
	local ang = RealTime() * 50
	local scale = ( math.sin( ang / 10 ) + 2 ) * 0.5
	draw.RotatedText( "My fancy Rotating Text", "DermaLarge", w / 2, h / 2, color_white, ang, scale )
end)
```

**Çıkış:**

[Video](https://gmod.tr/api/uploads/wiki/ca4ee0034458ca76102f.mp4)

### Örnek

Bir kutuyu dönerken, matris pozisyonunu panele göre tutar.

```lua
concommand.Add("test_matrix", function()
	local menu = vgui.Create( "DFrame" )
	menu:SetSize( 200, 200 )
	menu:SetTitle("Matrix rotation example")
	menu:SetPos( 200, 200 )

	local panel = menu:Add( "DPanel" )
	panel:SetSize( 100, 100 )
	panel:Center()

	local grin = Material("icon16/emoticon_evilgrin.png", "smooth noclamp")
	local angle = 0
	function panel:Paint(w, h)
		draw.RoundedBox( 8, 0, 0, w, h, color_white )

		- matrisimizi çizme zamanı.
		local m = Matrix()

		- matrisin ekranla ilişkisini korumak için, onun merkezini ekrana göre elde ediyoruz.
		local x, y = self:LocalToScreen( w / 2, h / 2 )
		local center = Vector( x, y, 0 )

		m:Translate( center )
		m:Rotate( Angle( 0, angle, 0 ) )
		m:Translate( -center )

		-- bir dahaki sefere çizimden sonra açıyı döndürün.
		angle = angle + FrameTime() * 60

		- Hırıltılılığı gidermek için bir filtre makinesine basın
		render.PushFilterMag( TEXFILTER.ANISOTROPIC )
		render.PushFilterMin( TEXFILTER.ANISOTROPIC )

			cam.PushModelMatrix( m )
				draw.RoundedBox( 8, 0, 0, w, h, color_black )
				surface.SetDrawColor( 255, 255, 255, 255 )
				surface.SetMaterial( grin )
				surface.DrawTexturedRect( w/2-16, h/2-16, 32, 32 )
			cam.PopModelMatrix()

		render.PopFilterMag()
		render.PopFilterMin()
	end

end)
```

**Çıkış:**

![gmod_UtOWgVrILW.gif](https://gmod.tr/api/uploads/wiki/50c9e0d9ca3985a5b22f.gif)

### Örnek

local player'un baktığı yere bir ağ çizer, her çerçeveyi yeniden oluşturmadan.

```lua
local mat = Material( "models/shadertest/shader5" ) - Malzeme.
local mat2 = Material( "models/wireframe" ) -- Malzeme (bir tel çerçeve)

local segCount = 18
local radius = 100

-- Basit trigonometri kullanarak bir daire ağı için zirveleri oluşturun.
- Ayrıca örgülerin dokusu için UV koordinatlarını da hesaplıyoruz.
local center = { pos = Vector( 0, 0, 0 ), u = 0.5, v = 0.5 }
local verts = {}
for j = 1, segCount do
	local angle1 = ( ( j - 1 ) / segCount ) * math.pi * -2
	local angle2 = ( j / segCount ) * math.pi * -2

	local v1 = {
		pos = Vector( math.cos( angle1 ) * radius, math.sin( angle1 ) * radius, 0 ),
		u = math.cos( angle1 ) * 0.5 + 0.5, v = math.sin( angle1 ) * 0.5 + 0.5
	}
	local v2 = {
		pos = Vector( math.cos( angle2 ) * radius, math.sin( angle2 ) * radius, 0 ),
		u = math.cos( angle2 ) * 0.5 + 0.5, v = math.sin( angle2 ) * 0.5 + 0.5
	}
	verts[#verts + 1] = center
	verts[#verts + 1] = v1
	verts[#verts + 1] = v2
end

local obj = Mesh() -- IMesh nesnesini oluştur
mesh.Begin( obj, MATERIAL_TRIANGLES, segCount ) -- Statik ağ yazmaya başlayın.
for i = 1, #verts do
	mesh.Position( verts[i].pos ) -- Konumu ayarla.
	mesh.TexCoord( 0, verts[i].u, verts[i].v ) -- doku UV koordinatlarını ayarlayın
	mesh.AdvanceVertex() -- Zirveyi yazın.
end
mesh.End() -- IMesh'e yazmayı bitirin.

hook.Add( "PostDrawOpaqueRenderables", "MeshLibTest", function()
	render.UpdateRefractTexture()
	render.SetMaterial( mat )

	local playerTrace = LocalPlayer():GetEyeTrace()

	local m = Matrix()
	m:Translate( playerTrace.HitPos + playerTrace.HitNormal * 10 )
	m:Rotate( playerTrace.HitNormal:Angle() )
	m:Rotate( Angle( 0, -90, -90 ) )

	render.ResetModelLighting( 1, 1, 1 )
	cam.PushModelMatrix( m )
	obj:Draw() Çizgiyi çekin.
	cam.PopModelMatrix()
end )
```

**Çıkış:**

![image.png](https://gmod.tr/api/uploads/wiki/0c19e7781f4a93865996.png)

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/cam.PushModelMatrix
