本文整理汇总了C#中UnityEngine.Matrix4x4.MultiplyPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4.MultiplyPoint方法的具体用法?C# Matrix4x4.MultiplyPoint怎么用?C# Matrix4x4.MultiplyPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4.MultiplyPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawGizmos
public void DrawGizmos(MegaFFD ffd, Matrix4x4 tm)
{
Handles.color = Color.red;
int pc = ffd.GridSize();
for ( int i = 0; i < pc; i++ )
{
for ( int j = 0; j < pc; j++ )
{
for ( int k = 0; k < pc; k++ )
{
pp3[0] = tm.MultiplyPoint(ffd.GetPoint(i, j, k) + ffd.bcenter);
if ( i < pc - 1 )
{
pp3[1] = tm.MultiplyPoint(ffd.GetPoint(i + 1, j, k) + ffd.bcenter);
Handles.DrawLine(pp3[0], pp3[1]);
}
if ( j < pc - 1 )
{
pp3[1] = tm.MultiplyPoint(ffd.GetPoint(i, j + 1, k) + ffd.bcenter);
Handles.DrawLine(pp3[0], pp3[1]);
}
if ( k < pc - 1 )
{
pp3[1] = tm.MultiplyPoint(ffd.GetPoint(i, j, k + 1) + ffd.bcenter);
Handles.DrawLine(pp3[0], pp3[1]);
}
}
}
}
}
示例2: Draw
// dessine une edge d'une epaisseur thickness en appliquant les transformations
// de planMatrix
public static void Draw(Edge2 edge, Matrix4x4 planMatrix, int thickness = 10,
float offsetWidth=0, float offsetHeight=0)
{
Matrix4x4 matrix = GUI.matrix;
Vector2 nextPt = edge.GetNextPoint2 ();
nextPt.Set(nextPt.x+offsetWidth, nextPt.y+offsetHeight);
nextPt = planMatrix.MultiplyPoint (nextPt);
Vector2 prevPt = edge.GetPrevPoint2 ();
prevPt.Set(prevPt.x+offsetWidth, prevPt.y+offsetHeight);
prevPt = planMatrix.MultiplyPoint (prevPt);
float angle = Vector2.Angle(nextPt - prevPt, Vector2.right);
if (prevPt.y > nextPt.y)
{
angle = -angle;
}
GUIUtility.RotateAroundPivot (angle, prevPt);
GUI.DrawTexture(new Rect (prevPt.x, prevPt.y - thickness / 2 ,
(nextPt - prevPt).magnitude, thickness), SOLID_EDGE_TEXTURE);
GUI.matrix = matrix;
}
示例3: createCylinder
public void createCylinder(float radius, float height, int slices, GameObject go, Matrix4x4 matrix)
{
Mesh cylinderMesh = new Mesh();
vertices = new Vector3[(slices+1) * 4];
Vector3[] cylPoints1 = createCylinderPoints(radius, height, slices, true);
Vector3[] cylPoints2 = createCylinderPoints(radius, height, slices, false);
for (int i = 0; i <cylPoints1.Length; i++) {
vertices[i] = cylPoints1[i];
}
for (int k = 0; k < cylPoints2.Length; k++) {
vertices[k + cylPoints1.Length] = cylPoints2[k];
}
createCylinderNormals(vertices, radius);
for (int j = 0; j < vertices.Length; j++) {
vertices[j] = matrix.MultiplyPoint(vertices[j]);
normals[j] = matrix.MultiplyPoint(normals[j]);
}
trianglesIndex = 0;
createCylinderTriangles(slices+1);
cylinderMesh.vertices = vertices;
cylinderMesh.triangles = triangles;
cylinderMesh.normals = normals;
cylinderMesh.uv = uvs;
MeshFilter filter = (MeshFilter)go.GetComponent("MeshFilter");
filter.mesh = cylinderMesh;
}
示例4: AddQuad
public void AddQuad(bool reverse, Matrix4x4 quadTransform, bool merge)
{
this.AddTriangleStrip(reverse,
new Vertex[]{
VertAutoNormal(quadTransform.MultiplyPoint(new Vector3(0.5f, 0.5f, 0)), new Vector2(1,1), merge),
VertAutoNormal(quadTransform.MultiplyPoint(new Vector3(0.5f, -0.5f, 0)), new Vector2(1,0), merge),
VertAutoNormal(quadTransform.MultiplyPoint(new Vector3(-0.5f, 0.5f, 0)), new Vector2(0,1), merge),
VertAutoNormal(quadTransform.MultiplyPoint(new Vector3(-0.5f, -0.5f, 0)), new Vector2(0,0), merge),
});
}
示例5: drawAngleLine
void drawAngleLine(Matrix4x4 refMatrix, Color color)
{
Vector3 start = Vector3.zero;
Vector3 end = new Vector3 (-5, 0, 0);
Vector3 startInWorldCoord = refMatrix.MultiplyPoint (start);
Vector3 endInWorldCoord = refMatrix.MultiplyPoint (end);
Debug.DrawLine (startInWorldCoord, endInWorldCoord, color);
}
示例6: Transform
public void Transform( Matrix4x4 inMatrix )
{
for( int i = 0; i < vertices.Length; ++i )
{
vertices[i] = inMatrix.MultiplyPoint( vertices[i] );
}
}
示例7: AdjustMidpointHandleColor
private void AdjustMidpointHandleColor(Vector3 localPos, Vector3 localTangent, Vector3 localBinormal, Matrix4x4 transform, float alphaFactor)
{
float num;
Vector3 vector = transform.MultiplyPoint(localPos);
Vector3 lhs = transform.MultiplyVector(localTangent);
Vector3 rhs = transform.MultiplyVector(localBinormal);
Vector3 normalized = Vector3.Cross(lhs, rhs).normalized;
if (Camera.current.isOrthoGraphic)
{
num = Vector3.Dot(-Camera.current.transform.forward, normalized);
}
else
{
Vector3 vector6 = Camera.current.transform.position - vector;
num = Vector3.Dot(vector6.normalized, normalized);
}
if (num < -0.0001f)
{
alphaFactor *= 0.2f;
}
if (alphaFactor < 1f)
{
Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * alphaFactor);
}
}
示例8: Start
void Start () {
_menuRoots = GameObject.FindGameObjectsWithTag("MenuRoot");
_menus = GameObject.FindGameObjectsWithTag("Menu");
_currentState = MoverState.PASSIVE;
//Account for differing aspect ratios
Vector2 screenSize = new Vector2(Screen.width, Screen.height);
Vector2 screenDiff = _layoutOriginalAspectRatio - screenSize;
if(Mathf.Abs(screenDiff.x) < Mathf.Abs(screenDiff.y)) {
float amt = _layoutOriginalAspectRatio.x / screenSize.x;
screenSize *= amt;
}
else {
float amt = _layoutOriginalAspectRatio.y / screenSize.y;
screenSize *= amt;
}
float horizRatio = screenSize.x / (float)_layoutOriginalAspectRatio.x;
float vertRatio = screenSize.y / (float)_layoutOriginalAspectRatio.y;
_guiMatrix = Matrix4x4.TRS (new Vector3(0, 0, 0), Quaternion.identity, new Vector3 (horizRatio, vertRatio, 1));
foreach(GameObject menu in _menus)
{
MenuBehavior menuScript = menu.GetComponent(typeof(MenuBehavior)) as MenuBehavior;
menuScript.baseLocation = _guiMatrix.MultiplyPoint(menuScript.baseLocation);
}
}
示例9: DrawCylinder
/// <summary>
/// Draws a gizmo cylinder with the given TRS matrix and color
/// </summary>
/// <param name="trs"></param>
/// <param name="color"></param>
public static void DrawCylinder(Matrix4x4 trs, Color color)
{
if (cylVerts == null || cylTris == null)
{
GameObject cyl = GameObject.CreatePrimitive(
PrimitiveType.Cylinder);
MeshFilter filter = cyl.GetComponent<MeshFilter>();
cylVerts = filter.sharedMesh.vertices;
cylTris = filter.sharedMesh.triangles;
GameObject.DestroyImmediate(cyl);
}
Vector3[] verts = new Vector3[cylVerts.Length];
for (int i = 0; i < cylVerts.Length; i++)
verts[i] = trs.MultiplyPoint(cylVerts[i]);
Gizmos.color = color;
for (int i = 0; i < cylTris.Length / 3; i++)
{
int j = i * 3;
Gizmos.DrawLine(verts[cylTris[j]],
verts[cylTris[j + 1]]);
Gizmos.DrawLine(verts[cylTris[j + 1]],
verts[cylTris[j + 2]]);
Gizmos.DrawLine(verts[cylTris[j + 2]],
verts[cylTris[j]]);
}
}
示例10: CalcLineTranslation
// UnityEditor.HandleUtility
/// <summary>
/// <para>Map a mouse drag onto a movement along a line in 3D space.</para>
/// </summary>
/// <param name="src">The source point of the drag.</param>
/// <param name="dest">The destination point of the drag.</param>
/// <param name="srcPosition">The 3D position the dragged object had at src ray.</param>
/// <param name="constraintDir">3D direction of constrained movement.</param>
/// <returns>
/// <para>The distance travelled along constraintDir.</para>
/// </returns>
public static float CalcLineTranslation(Vector2 src, Vector2 dest, Vector3 srcPosition, Vector3 constraintDir, Matrix4x4 handleMatrix)
{
srcPosition = handleMatrix.MultiplyPoint(srcPosition);
constraintDir = handleMatrix.MultiplyVector(constraintDir);
float num = 1f;
Vector3 forward = Camera.main.transform.forward;
if(Vector3.Dot(constraintDir, forward) < 0f)
{
num = -1f;
}
Vector3 vector = constraintDir;
vector.y = -vector.y;
Camera current = Camera.main;
Vector2 vector2 = PixelsToPoints(current.WorldToScreenPoint(srcPosition));
Vector2 vector3 = PixelsToPoints(current.WorldToScreenPoint(srcPosition + constraintDir * num));
Vector2 x = dest;
Vector2 x2 = src;
if(vector2 == vector3)
{
return 0f;
}
//x.y = -x.y;
//x2.y = -x2.y;
float parametrization = GetParametrization(x2, vector2, vector3);
float parametrization2 = GetParametrization(x, vector2, vector3);
return (parametrization2 - parametrization) * num;
}
示例11: MapsTo
public void MapsTo(Matrix4x4 trMatrix)
{
for (int i = 0; i < length; i++ )
{
points[i] = trMatrix.MultiplyPoint(points[i]);
}
}
示例12: AdjustEdgeHandleColor
private void AdjustEdgeHandleColor(Vector3 handlePos, Vector3 slideDir1, Vector3 slideDir2, Matrix4x4 transform, float alphaFactor)
{
bool flag;
Vector3 inPoint = transform.MultiplyPoint(handlePos);
Vector3 normalized = transform.MultiplyVector(slideDir1).normalized;
Vector3 rhs = transform.MultiplyVector(slideDir2).normalized;
if (Camera.current.isOrthoGraphic)
{
flag = (Vector3.Dot(-Camera.current.transform.forward, normalized) < 0f) && (Vector3.Dot(-Camera.current.transform.forward, rhs) < 0f);
}
else
{
Plane plane = new Plane(normalized, inPoint);
Plane plane2 = new Plane(rhs, inPoint);
flag = !plane.GetSide(Camera.current.transform.position) && !plane2.GetSide(Camera.current.transform.position);
}
if (flag)
{
alphaFactor *= 0.2f;
}
if (alphaFactor < 1f)
{
Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * alphaFactor);
}
}
示例13: DirectionTo3DGridPosition
public Vector3 DirectionTo3DGridPosition(Vector3 observer, Vector3 direction, float yPlane)
{
direction = direction.normalized;
Matrix4x4 mat = new Matrix4x4();
float multiple = (yPlane - observer.y) / direction.y;
mat.SetTRS(direction * multiple, Quaternion.identity, Vector3.one);
Vector3 newPoint = mat.MultiplyPoint(observer);
return GetNearest3DGridPoint(newPoint);
}
示例14: SurfaceGrid
public Vector3[] SurfaceGrid()
{
var width = Mathf.CeilToInt((float)Screen.width / pitchPix);
var height = Mathf.CeilToInt((float)screenHeight / pitchPix);
var widthPlusOne = width + 1;
var heightPlusOne = height + 1;
var vertexCount = widthPlusOne * heightPlusOne;
if (vertexCount > VERTEX_LIMIT)
return null;
_triangleInvalidated = (width != _prevWidth || height != _prevHeight);
if (_triangleInvalidated) {
_mesh.Clear();
_prevWidth = width;
_prevHeight = height;
_vertices = new Vector3[vertexCount];
}
var m = new Matrix4x4();
m.SetTRS(new Vector3(-1f, -1f, 0f), Quaternion.identity, new Vector3(2f / Screen.width, 2f / Screen.height, 1f));
m = targetCamera.cameraToWorldMatrix * targetCamera.projectionMatrix.inverse * m;
var v = new Vector4(0f, 0f, 0f, 1f);
for (var y = 0; y <= height; y++) {
for (var x = 0; x <= width; x++) {
var i = y * widthPlusOne + x;
v.x = x * pitchPix;
v.y = screenHeight - y * pitchPix;
_vertices[i] = m.MultiplyPoint(v);
}
}
if (_triangleInvalidated) {
_triangles = new int[6 * width * height];
var counter = 0;
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var i = y * widthPlusOne + x;
_triangles[counter++] = i;
_triangles[counter++] = i + 1;
_triangles[counter++] = i + + widthPlusOne + 1;
_triangles[counter++] = i;
_triangles[counter++] = i + widthPlusOne + 1;
_triangles[counter++] = i + widthPlusOne;
}
}
}
return _vertices;
}
示例15: Transform
public void Transform(Matrix4x4 transform)
{
// Transform main polygon
for (int i = 0; i < this.Count; i++)
{
this[i] = transform.MultiplyPoint(this[i]);
}
// Transform holes
Vector2[] temp = null;
if (_holes != null && _holes.Count > 0)
{
for (int i = 0; i < _holes.Count; i++)
{
temp = _holes[i].ToArray();
for (int j = 0; j < temp.Length; j++)
{
temp[i] = transform.MultiplyPoint(temp[i]);
}
_holes[i] = new Vertices(temp);
}
}
}