当前位置: 首页>>代码示例>>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;未经允许,请勿转载。