用户工具

站点工具


侧边栏

script:unityengine:classes:gl:gl.pushmatrix

GL.PushMatrix 入栈矩阵

JavaScript ⇒ public static function PushMatrix(): void;
C# ⇒ public static void PushMatrix();

Description 描述

Saves both projection and modelview matrices to the matrix stack.

把投影视图矩阵和模型视图矩阵压入堆栈保存。

Changing modelview or projection matrices overrides current camera's parameters. These matrices can be saved and restored using GL.PushMatrix and GL.PopMatrix.

改变模型视图矩阵和投影矩阵会覆盖当前的camera的参数,许多情况下你需要用到GL.PushMatrix 和GL.PopMatrix矩阵函数来保存和恢复。

See Also: PopMatrix function.

JavaScript:

	// Draw a yellow line from the botton left to the
	// top right of the screen
	var mat : Material;
 
	function OnPostRender() {
		if (!mat) {
			Debug.LogError("Please Assign a material on the inspector");
			return;
		}
		GL.PushMatrix(); // Save the current state
		mat.SetPass(0);
		GL.LoadPixelMatrix();
		GL.Color(Color.yellow);
		GL.Begin(GL.LINES);
		GL.Vertex3(0,0,0);
		GL.Vertex3(Screen.width, Screen.height,0);
		GL.End();
		GL.PopMatrix(); // Pop changes.
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public Material mat;
    void OnPostRender(&
                    
                                    
script/unityengine/classes/gl/gl.pushmatrix.txt · 最后更改: 2016/08/02 05:24 (外部编辑)