用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:gl:gl.popmatrix

GL.PopMatrix 出栈矩阵

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

Description 描述

Restores both projection and modelview matrices off the top of 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: PushMatrix 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() {
        if (!mat) {
            Debug.LogError("Please Assign a material on the inspector");
            return;
        }
        GL.PushMatrix();
        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();
    }
}

GL

script/unityengine/classes/gl/gl.popmatrix.txt · 最后更改: 2016/08/02 05:24 (外部编辑)