本文整理汇总了C#中UnityEngine.Matrix4x4.TransformDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4.TransformDirection方法的具体用法?C# Matrix4x4.TransformDirection怎么用?C# Matrix4x4.TransformDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4.TransformDirection方法的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");
}
示例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;
}