当前位置: 首页>>代码示例>>C#>>正文


C# Matrix4x4.SetColumn方法代码示例

本文整理汇总了C#中UnityEngine.Matrix4x4.SetColumn方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4.SetColumn方法的具体用法?C# Matrix4x4.SetColumn怎么用?C# Matrix4x4.SetColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Matrix4x4的用法示例。


在下文中一共展示了Matrix4x4.SetColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    // Use this for initialization
    void Start ()
    {
        // Initialize some variables
        m_tangoRotation = Quaternion.Euler(90,0,0);
        m_tangoPosition = Vector3.zero;
        m_startPosition = transform.position;
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        if(m_tangoApplication != null)
        {
            // Request Tango permissions
            m_tangoApplication.RegisterPermissionsCallback(PermissionsCallback);
            m_tangoApplication.RequestNecessaryPermissionsAndConnect();
            m_tangoApplication.Register(this);
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }

        m_uwTss = new Matrix4x4();
        m_uwTss.SetColumn (0, new Vector4 (1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn (1, new Vector4 (0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn (2, new Vector4 (0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn (3, new Vector4 (0.0f, 0.0f, 0.0f, 1.0f));
        
        m_dTuc = new Matrix4x4();
        m_dTuc.SetColumn (0, new Vector4 (1.0f, 0.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn (1, new Vector4 (0.0f, 1.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn (2, new Vector4 (0.0f, 0.0f, -1.0f, 0.0f));
        m_dTuc.SetColumn (3, new Vector4 (0.0f, 0.0f, 0.0f, 1.0f));


        Application.targetFrameRate = 60;

    }
开发者ID:GulfstreamPD,项目名称:tango-examples-unity,代码行数:36,代码来源:PoseController.cs

示例2: StretchAlongAxis

  //Scale point along stretchAxis by stretchFactor
  public static Vector3 StretchAlongAxis( Vector3 point, Vector3 stretchAxis, float stretchFactor )
  {
    var upVector = Vector3.up;

    //Check if vectors are colliniar
    if( Vector3.Dot(upVector, stretchAxis) >= 1.0f - epsilon )
      upVector = Vector3.left;

    var right = Vector3.Cross(upVector, stretchAxis);
    var up = Vector3.Cross(stretchAxis, right);
    var forward = stretchAxis;

    right.Normalize();
    up.Normalize();
    forward.Normalize();

    Matrix4x4 rotate = new Matrix4x4();
    rotate.SetColumn(0, right);
    rotate.SetColumn(1, up);
    rotate.SetColumn(2, forward);
    rotate[3, 3] = 1.0F;

    Matrix4x4 scale = new Matrix4x4();
    scale[0, 0] = 1.0f;
    scale[1, 1] = 1.0f;
    scale[2, 2] = stretchFactor;
    scale[3, 3] = 1.0f;

    Matrix4x4 trans = rotate * scale * rotate.transpose;

    return trans.MultiplyPoint3x4( point );
  }
开发者ID:Auguraculums,项目名称:BirdFlock,代码行数:33,代码来源:MathTools.cs

示例3: DrawColumns

 public static Matrix4x4 DrawColumns( Matrix4x4 matrix )
 {
     matrix.SetColumn( 0, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetColumn( 0 ) ) );
     matrix.SetColumn( 1, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetColumn( 1 ) ) );
     matrix.SetColumn( 2, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetColumn( 2 ) ) );
     matrix.SetColumn( 3, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetColumn( 3 ) ) );
     return matrix;
 }
开发者ID:Thundernerd,项目名称:Unity3D-ExtendedEvent,代码行数:8,代码来源:MatrixWizard.cs

示例4: LookAt

    public static void LookAt(ref Matrix4x4 mat, Vector3 source_pos, Vector3 target_pos, Vector3 up)
    {
        Vector3 source_target_unit_vector = target_pos - source_pos;

        Vector3 ydir = Vector3.Normalize(target_pos - source_pos);
        Vector3 zdir = Vector3.Normalize(Vector3.Cross(up, ydir));

        mat = Matrix4x4.identity;
        mat.SetColumn(1, Vector3.Normalize(Vector3.Cross(ydir, zdir)));
        mat.SetColumn(2, Vector3.Normalize(source_target_unit_vector));
        mat.SetColumn(0, zdir);
    }
开发者ID:jsr2k1,项目名称:videojocjj,代码行数:12,代码来源:MegaMatrix.cs

示例5: Start

    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    private void Start()
    {
        // Constant matrix converting start of service frame to Unity world frame.
        m_uwTss = new Matrix4x4();
        m_uwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_cTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_cTuc.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        m_cTuc.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_cTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_tangoApplication = FindObjectOfType<TangoApplication>();

        if (m_tangoApplication != null)
        {
            if (AndroidHelper.IsTangoCorePresent())
            {
                // Request Tango permissions
                m_tangoApplication.RegisterPermissionsCallback(_OnTangoApplicationPermissionsEvent);
                m_tangoApplication.RequestNecessaryPermissionsAndConnect();
                m_tangoApplication.Register(this);
                m_renderCamera.clearFlags = CameraClearFlags.SolidColor;
            }
            else
            {
                // If no Tango Core is present let's tell the user to install it.
                Debug.Log("Tango Core is outdated.");
            }
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }
        if (m_tangoApplication != null)
        {
            m_textures = m_tangoApplication.GetVideoOverlayTextureYUV();

            // Pass YUV textures to shader for process.
            m_screenMaterial.SetTexture("_YTex", m_textures.m_videoOverlayTextureY);
            m_screenMaterial.SetTexture("_UTex", m_textures.m_videoOverlayTextureCb);
            m_screenMaterial.SetTexture("_VTex", m_textures.m_videoOverlayTextureCr);
        }

        m_tangoApplication.Register(this);
    }
开发者ID:BrendaManrique,项目名称:TangoProject,代码行数:52,代码来源:ARScreen.cs

示例6: MatrixToQuaternion

    public static Quaternion MatrixToQuaternion(ref Matrix4x4 source)
    {
        // adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm

        Matrix4x4 matrix = new Matrix4x4();
        matrix.SetColumn(0, source.GetColumn(0));
        matrix.SetColumn(1, source.GetColumn(1));
        matrix.SetColumn(2, source.GetColumn(2));
        matrix.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        float trace = Trace(ref matrix);
        if (trace > 0.0f)
        {
            float s = Mathf.Sqrt(trace + 1.0f) * 2.0f; // 4 * qw in Jon's equ
            return new Quaternion(
                (matrix[2,1] - matrix[1,2]) / s,
                (matrix[0,2] - matrix[2,0]) / s,
                (matrix[1,0] - matrix[0,1]) / s,
                0.25f * s);
        }
        else if (matrix[0,0] > matrix[1,1] && matrix[0,0] > matrix[2,2])
        {
            float s = Mathf.Sqrt(1.0f + matrix[0,0] - matrix[1,1] - matrix[2,2]) * 2.0f; // 4 * qx
            return new Quaternion(
                0.25f * s,
                (matrix[0,1] + matrix[1,0]) / s,
                (matrix[0,2] + matrix[2,0]) / s,
                (matrix[2,1] - matrix[1,2]) / s);
        }
        else if (matrix[1,1] > matrix[2,2])
        {
            float s = Mathf.Sqrt(1.0f + matrix[1,1] - matrix[0,0] - matrix[2,2]) * 2.0f; // 4 * qw
            return new Quaternion(
                (matrix[0,1] + matrix[1,0]) / s,
                0.25f * s,
                (matrix[1,2] + matrix[2,1]) / s,
                (matrix[0,2] - matrix[2,0]) / s);
        }
        else
        {
            float s = Mathf.Sqrt(1.0f + matrix[2,2] - matrix[0,0] - matrix[1,1]) * 2.0f; // 4 * qz
            return new Quaternion(
                (matrix[0,2] + matrix[2,0]) / s,
                (matrix[1,2] + matrix[2,1]) / s,
                0.25f * s,
                (matrix[1,0] - matrix[0,1]) / s);
        }
    }
开发者ID:nikhilJain17,项目名称:Sphero-AR-SDK,代码行数:48,代码来源:VisionUtils.cs

示例7: Set_Manual_MVP

    void Set_Manual_MVP()
    {
        if (!compass) MyDebug.LogError("Traget Object was not assigned",matrixPWD);

         inverseZ.SetTRS(Vector3.zero, Quaternion.identity, new Vector3(1, 1, -1));

         world2View.SetTRS(
             Vector3.zero,
             Camera.main.transform.localRotation,
             Vector3.one);

         world2View = world2View.transpose;

         Vector4 dp = world2View * Camera.main.transform.position;
         dp = new Vector4(dp.x, dp.y, dp.z, -1);

         world2View.SetColumn(3, -dp);
         world2View = inverseZ * world2View;

        manual_MVP=
                Camera.main.projectionMatrix
                *world2View
                *compass.localToWorldMatrix;
        Shader.SetGlobalMatrix("Manual_MVP",manual_MVP);
    }
开发者ID:trojanfoe,项目名称:UnityShader,代码行数:25,代码来源:SetMatrixs_8.cs

示例8: Start

 //public Transform projector;
 // Use this for initialization
 void Start()
 {
     correction = Matrix4x4.identity;
     correction.SetColumn(3,new Vector4(0.5f,0.5f,0.5f,1f));
     correction.m00 = 0.5f;
     correction.m11 = 0.5f;
     correction.m22 = 0.5f;
 }
开发者ID:vanCopper,项目名称:CGShader,代码行数:10,代码来源:Main.cs

示例9: Awake

    // Use this for initialization
    void Awake()
    {
        correction = Matrix4x4.identity;
        correction.SetColumn(3,new Vector4(0.5f,0.5f,0.5f,1f));
        correction.m00 = 0.5f;
        correction.m11 = 0.5f;
        correction.m22 = 0.5f;

        aspect=projCamera.aspect;
    }
开发者ID:trojanfoe,项目名称:UnityShader,代码行数:11,代码来源:Project_1.cs

示例10: HeadTrackingProcess

    IEnumerator HeadTrackingProcess()
    {
        yield return null;

        AndroidJavaClass jc = new AndroidJavaClass("com.limecolor.unity.card_board_for_unity.debris.UnityPlayerNativeActivity");
        Matrix4x4 matrix = new Matrix4x4();

        while( headTrackingOn )
        {

            float[] M = jc.CallStatic<float[]> ("getHeadMatrix");

            matrix.SetColumn(0, new Vector4(M[0], M[4], -M[8], M[12]) );
            matrix.SetColumn(1, new Vector4(M[1], M[5], -M[9], M[13]) );
            matrix.SetColumn(2, new Vector4(-M[2], -M[6], M[10], M[14]) );
            matrix.SetColumn(3, new Vector4(M[3], M[7], M[11], M[15]) );

            TransformFromMatrix (matrix, gameObject.transform);

            yield return new WaitForEndOfFrame();
        }
    }
开发者ID:sakshamkashyap,项目名称:Projects,代码行数:22,代码来源:CameraControl.cs

示例11: Awake

    /// <summary>
    /// Initialize the controller.
    /// </summary>
    public void Awake()
    {
        // Constant matrix converting start of service frame to Unity world frame.
        m_matrixuwTss = new Matrix4x4();
        m_matrixuwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_matrixuwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_matrixuwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_matrixuwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_matrixdTuc = new Matrix4x4();
        m_matrixdTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_matrixdTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_matrixdTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
        m_matrixdTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_frameDeltaTime = -1.0f;
        m_prevFrameTimestamp = -1.0f;
        m_frameCount = -1;
        m_status = TangoEnums.TangoPoseStatusType.NA;
        m_tangoRotation = Quaternion.identity;
        m_tangoPosition = Vector3.zero;
    }
开发者ID:gitunit,项目名称:project-tango-poc,代码行数:26,代码来源:TangoPoseController.cs

示例12: Start

    void Start()
    {
        if (mirCam) return;
        GameObject g = new GameObject("Mirror Camera");
        mirCam=g.AddComponent<Camera>();
        mirCam.enabled = false;

        refTex = new RenderTexture(800, 600,16);
        refTex.hideFlags = HideFlags.DontSave;
        mirCam.targetTexture = refTex;
        GetComponent<Renderer>().material.SetTexture("_RefTex", refTex);

        correction = Matrix4x4.identity;
        correction.SetColumn(3, new Vector4(0.5f, 0.5f, 0.5f, 1f));
        correction.m00 = 0.5f;
        correction.m11 = 0.5f;
        correction.m22 = 0.5f;
    }
开发者ID:trojanfoe,项目名称:UnityShader,代码行数:18,代码来源:Mirror_2.cs

示例13: SetUpRotation

    void SetUpRotation(Vector3 Q, Vector3 W, float Theta, ref Matrix4x4 Rq)
    {
        float ww1,ww2,ww3,w12,w13,w23,CosTheta,SinTheta,MinCosTheta;
        Vector3 temp = Vector3.zero;
        Matrix4x4 R = Matrix4x4.identity;

        ww1 = W[0] * W[0];
        ww2 = W[1] * W[1];
        ww3 = W[2] * W[2];
        w12 = W[0] * W[1];
        w13 = W[0] * W[2];
        w23 = W[1] * W[2];
        CosTheta = Mathf.Cos(Theta);
        MinCosTheta = 1.0f - CosTheta;
        SinTheta = Mathf.Sin(Theta);
        R[0, 0] = ww1 + (1.0f - ww1) * CosTheta;
        R[1, 0] = w12 * MinCosTheta + W[2] * SinTheta;
        R[2, 0] = w13 * MinCosTheta - W[1] * SinTheta;
        R[0, 1] = w12 * MinCosTheta - W[2] * SinTheta;
        R[1, 1] = ww2 + (1.0f - ww2) * CosTheta;
        R[2, 1] = w23 * MinCosTheta + W[0] * SinTheta;
        R[0, 2] = w13 * MinCosTheta + W[1] * SinTheta;
        R[1, 2] = w23 * MinCosTheta - W[0] * SinTheta;
        R[2, 2] = ww3 + (1.0f - ww3) * CosTheta;
        Mult1X3(Q, R, ref temp);

        Rq.SetColumn(0, R.GetColumn(0));
        Rq.SetColumn(1, R.GetColumn(1));
        Rq.SetColumn(2, R.GetColumn(2));
        Rq[0, 3] = Q[0] - temp.x;
        Rq[1, 3] = Q[1] - temp.y;
        Rq[2, 3] = Q[2] - temp.z;
        Rq[3, 0] = Rq[3, 1] = Rq[3, 2] = 0.0f;
        Rq[3, 3] = 1.0f;
    }
开发者ID:Morac,项目名称:Orca6,代码行数:35,代码来源:MegaHose.cs

示例14: BuildMesh

    // we only need to build the savevertex and uvs if mesh def changes, else we can keep the uvs
    void BuildMesh()
    {
        if ( !mesh )
        {
            mesh = GetComponent<MeshFilter>().sharedMesh;
            if ( mesh == null )
            {
                updatemesh = true;
                return;
            }
        }

        if ( hosespline.knots.Count == 0 )
        {
            hosespline.AddKnot(Vector3.zero, Vector3.zero, Vector3.zero);
            hosespline.AddKnot(Vector3.zero, Vector3.zero, Vector3.zero);
        }

        FixHoseFillet();

        bool createfree = freecreate;

        if ( (!createfree) && ((!custnode) || (!custnode2)) )
            createfree = true;

        if ( custnode && custnode2 )
            createfree = false;

        Matrix4x4 mat1,mat2;
        float Lf = 0.0f;
        Tlocal = Matrix4x4.identity;

        Vector3 startvec, endvec, startpoint, endpoint, endy;
        starty = Vector3.zero;
        roty = Vector3.zero;
        yangle = 0.0f;

        Vector3 RV = Vector3.zero;

        if ( createfree )
            Lf = noreflength;
        else
        {
            RV = up;	//new Vector3(xtmp, ytmp, ztmp);

            mat1 = custnode.transform.localToWorldMatrix;
            mat2 = custnode2.transform.localToWorldMatrix;

            Matrix4x4 mato1 = Matrix4x4.identity;
            Matrix4x4 mato2 = Matrix4x4.identity;
            mato1 = Matrix4x4.TRS(offset, Quaternion.Euler(rotate), scale);
            mato1 = mato1.inverse;

            mato2 = Matrix4x4.TRS(offset1, Quaternion.Euler(rotate1), scale1);
            mato2 = mato2.inverse;
            S = transform.localToWorldMatrix;

            Matrix4x4 mat1NT, mat2NT;

            mat1NT = mat1;
            mat2NT = mat2;
            MegaMatrix.NoTrans(ref mat1NT);
            MegaMatrix.NoTrans(ref mat2NT);
            Vector3 P1 = mat1.MultiplyPoint(mato1.GetColumn(3));
            Vector3 P2 = mat2.MultiplyPoint(mato2.GetColumn(3));

            startvec = mat1NT.MultiplyPoint(mato1.GetColumn(2));
            endvec = mat2NT.MultiplyPoint(mato2.GetColumn(2));
            starty = mat1NT.MultiplyPoint(mato1.GetColumn(1));
            endy = mat2NT.MultiplyPoint(mato2.GetColumn(1));

            Matrix4x4 SI = S.inverse;

            Vector3 P0 = SI.MultiplyPoint(P1);
            Matrix4x4 T1 = mat1;
            MegaMatrix.NoTrans(ref T1);

            Vector3 RVw = T1.MultiplyPoint(RV);
            Lf = (P2 - P1).magnitude;
            Vector3 Zw;
            if ( Lf < 0.01f )
                Zw = P1.normalized;
            else
                Zw = (P2 - P1).normalized;
            Vector3 Xw = Vector3.Cross(RVw, Zw).normalized;
            Vector3 Yw = Vector3.Cross(Zw, Xw).normalized;

            MegaMatrix.NoTrans(ref SI);

            Vector3 Xs = SI.MultiplyPoint(Xw);
            Vector3 Ys = SI.MultiplyPoint(Yw);
            Vector3 Zs = SI.MultiplyPoint(Zw);
            Tlocal.SetColumn(0, Xs);
            Tlocal.SetColumn(1, Ys);
            Tlocal.SetColumn(2, Zs);
            MegaMatrix.SetTrans(ref Tlocal, P0);

            // move z-axes of end transforms into local frame
            Matrix4x4 TlocalInvNT = Tlocal;
//.........这里部分代码省略.........
开发者ID:Morac,项目名称:Orca6,代码行数:101,代码来源:MegaHose.cs

示例15: TranslateMatrix

 public static void TranslateMatrix(ref Matrix4x4 m, Vector3 position)
 {
     m.SetColumn(3,(Vector3)(m.GetColumn(3))+position);
     m[3,3] = 1;
 }
开发者ID:newton64,项目名称:Dodecahedroads,代码行数:5,代码来源:Util.cs


注:本文中的UnityEngine.Matrix4x4.SetColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。