unity3D技术之gl.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 usinggl.pushmatrixandgl.popmatrix.

改变模型视图矩阵和投影矩阵会覆盖当前的camera' 的参数,许多情况下你需要用到gl.pushmatrix和gl.popmatrix矩阵函数.来保存和恢复。 参见:popmatrix函数 c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{ publicmaterialmat; void onpostrender() { if (!mat) {

debug.logerror(\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(); } }

// draw a yellow line from the botton left to the // top right of the screen

//从屏幕左下角到右上角,绘制一条黄色的线 var mat :material;

function onpostrender() { if (!mat) {

debug.logerror(\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. 弹出改变 }

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4