• unity, unity中GL.MultMatrix的一个超级bug


    GL.MultMatrix与OpenGL固定管线的glMultMatrix函数行为并不一致,不是累乘,而是覆盖。

    例如下面例子,本来预期是在(100,100)处画一个方块,而实际效果却是在(0,0)处画一个方块:

    GL.PushMatrix();
      GL.LoadPixelMatrix();
      {
       //mult matrix
       Matrix4x4 mat1 = Matrix4x4.TRS(new Vector3(100,100,0),Quaternion.identity,Vector3.one);
       GL.MultMatrix (mat1);
       //mult matrix
       Matrix4x4 mat2 = Matrix4x4.identity;
       GL.MultMatrix (mat2); 
       //draw quad
       {
        float m_left = -20;
        float m_top = -20;
        float m_right = 20;
        float m_bottom = 20;
        Vector2 LU = new Vector2 (m_left, m_top);
        Vector2 LD = new Vector2 (m_left, m_bottom);
        Vector2 RU = new Vector2 (m_right, m_top);
        Vector2 RD = new Vector2 (m_right, m_bottom);
        uiMat.getInstance ().m_dftUIMat.SetPass (0);
        GL.Begin (GL.QUADS);
        GL.Color (Color.red);
        GL.Vertex (new Vector3 (LU.x, LU.y, 0));
        GL.Vertex (new Vector3 (LD.x, LD.y, 0));
        GL.Vertex (new Vector3 (RD.x, RD.y, 0));
        GL.Vertex (new Vector3 (RU.x, RU.y, 0));
        GL.End ();
       }
      }
      GL.PopMatrix();

    参考:http://answers.unity3d.com/answers/1115934/view.html

  • 相关阅读:
    Android使用SO库时要注意的一些问题
    android studio 生成引用arr
    android studio 改包名
    P2P通信原理与实现(C++)
    unity3d各种OpenFileDialog操作
    使用ffmpeg编码时,如何设置恒定码率,并控制好关键帧I帧间隔
    ffmpeg h264转h265
    照片人脸建模
    自动减面
    Unity3d 5.3.5使用sqlite3
  • 原文地址:https://www.cnblogs.com/wantnon/p/5066203.html
Copyright © 2020-2023  润新知