當前位置: 首頁>>代碼示例>>C#>>正文


C# Matrix4x4.TransformPoint方法代碼示例

本文整理匯總了C#中UnityEngine.Matrix4x4.TransformPoint方法的典型用法代碼示例。如果您正苦於以下問題:C# Matrix4x4.TransformPoint方法的具體用法?C# Matrix4x4.TransformPoint怎麽用?C# Matrix4x4.TransformPoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Matrix4x4的用法示例。


在下文中一共展示了Matrix4x4.TransformPoint方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AssertExpectedPlane

        private static void AssertExpectedPlane(BoundedPlane plane, Vector3 bounds, Matrix4x4 vertDataTransform, Matrix4x4 meshTransform)
        {
            float expectedArea = 4.0f * bounds.x * bounds.y;
            Vector3 expectedPlaneNormal = meshTransform.TransformDirection(vertDataTransform.TransformDirection(new Vector3(0, 0, 1)));
            Vector3 expectedPlaneCenter = meshTransform.TransformPoint(vertDataTransform.TransformPoint(Vector3.zero));

            Assert.AreEqual(expectedArea, plane.Area, expectedArea * 0.01f);
            AssertAreEqual(expectedPlaneNormal, plane.Plane.normal, 0.01f, "Normal");
            AssertAreEqual(expectedPlaneCenter, plane.Bounds.Center, bounds.Length() * 0.01f, "Center");
        }
開發者ID:Microsoft,項目名稱:HoloToolkit,代碼行數:10,代碼來源:TestCases.cs

示例2: CreateSimpleMesh

    /// <summary>
    /// Helper function that creates a simple mesh for use in the PlaneFinding API. The mesh is built as tesselated
    /// quad spanning the x and y dimensions of the specified Bounds. Each vert in the mesh is randomly perturbed
    /// along the z axis with in the specified Bounds. This results in a somewhat more realistic noisy planar mesh
    /// that simulates the sort of data we might get from SR.
    /// </summary>
    ///
    public static PlaneFinding.MeshData CreateSimpleMesh(int dimension, Vector3 bounds, Matrix4x4 vertDataTransform, Matrix4x4 meshTransform)
    {
        System.Random r = new System.Random();
        Vector3[] vertices = Enumerable.Range(0, dimension + 1)
            .SelectMany(x => Enumerable.Range(0, dimension + 1)
                .Select(y => new Vector3(
                        bounds.x * (2.0f * (float)x / (float)(dimension) - 1.0f),
                        bounds.y * (2.0f * (float)y / (float)(dimension) - 1.0f),
                        bounds.z * (2.0f * (float)r.NextDouble() - 1.0f))
                )
            )
            .Select(p => vertDataTransform.TransformPoint(p))
            .ToArray();

        Vector3[] normals = Enumerable.Repeat(new Vector3(0, 0, 1), (dimension + 1) * (dimension + 1))
            .Select(n => vertDataTransform.TransformDirection(n))
            .ToArray();

        int[] indices = Enumerable.Range(0, dimension)
            .SelectMany(x => Enumerable.Range(0, dimension)
                .SelectMany(y => new int[]
                {
                    ((dimension + 1) * (x + 0) + (y + 0)),
                    ((dimension + 1) * (x + 1) + (y + 0)),
                    ((dimension + 1) * (x + 0) + (y + 1)),
                    ((dimension + 1) * (x + 0) + (y + 1)),
                    ((dimension + 1) * (x + 1) + (y + 0)),
                    ((dimension + 1) * (x + 1) + (y + 1)),
                })
            ).ToArray();
        
        PlaneFinding.MeshData mesh = new PlaneFinding.MeshData();
        mesh.Transform = meshTransform;
        mesh.Verts = vertices;
        mesh.Normals = normals;
        mesh.Indices = indices;
        return mesh;
    }
開發者ID:Microsoft,項目名稱:HoloToolkit,代碼行數:45,代碼來源:Util.cs


注:本文中的UnityEngine.Matrix4x4.TransformPoint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。