本文整理汇总了C#中UnityEngine.Matrix4x4.MultiplyPoint3x4方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4.MultiplyPoint3x4方法的具体用法?C# Matrix4x4.MultiplyPoint3x4怎么用?C# Matrix4x4.MultiplyPoint3x4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4.MultiplyPoint3x4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawScatterBrush
public static void DrawScatterBrush(Vector3 point, Vector3 normal, z_BrushSettings settings, Matrix4x4 localToWorldMatrix)
{
Vector3 p = localToWorldMatrix.MultiplyPoint3x4(point);
Vector3 n = localToWorldMatrix.MultiplyVector(normal).normalized;
float r = settings.radius;
Vector3 a = Vector3.zero;
Quaternion rotation = Quaternion.LookRotation(normal, Vector3.up);
for(int i = 0; i < 10; i++)
{
a.x = Mathf.Cos(Random.Range(0f, 360f));
a.y = Mathf.Sin(Random.Range(0f, 360f));
a = a.normalized * Random.Range(0f, r);
Vector3 v = localToWorldMatrix.MultiplyPoint3x4(point + rotation * a);
Handles.DrawLine(v, v + (n * .5f));
Handles.CubeCap(i + 2302, v, Quaternion.identity, .01f);
}
/// radius
Handles.DrawWireDisc(p, n, settings.radius);
}
示例2: Rotate
public void Rotate(Matrix4x4 tm)
{
for ( int i = 0; i < Keys.Length; i++ )
{
Keys[i].val = tm.MultiplyPoint3x4(Keys[i].val);
Keys[i].intan = tm.MultiplyPoint3x4(Keys[i].intan);
Keys[i].outtan = tm.MultiplyPoint3x4(Keys[i].outtan);
}
InitKeys();
}
示例3: DrawBrush
public static void DrawBrush( Vector3 point,
Vector3 normal,
z_BrushSettings brushSettings,
Matrix4x4 matrix,
Color innerColor,
Color outerColor)
{
PushHandleColor();
Vector3 p = matrix.MultiplyPoint3x4(point);
Vector3 n = matrix.MultiplyVector(normal).normalized;
/// radius
Handles.color = outerColor;
Handles.DrawWireDisc(p, n, brushSettings.radius);
/// falloff
Handles.color = innerColor;
Handles.DrawWireDisc(p, n, brushSettings.radius * brushSettings.falloff);
Handles.color = new Color( Mathf.Abs(n.x),
Mathf.Abs(n.y),
Mathf.Abs(n.z),
1f);
Handles.DrawLine(p, p + n.normalized * HandleUtility.GetHandleSize(p));
PopHandleColor();
}
示例4: UpdateMinMax
/// <summary>
/// Update the min/max values based on the transformed bounding box.
/// </summary>
/// <param name="bounds"></param>
/// <param name="transform"></param>
/// <param name="maxPos"></param>
/// <param name="minPos"></param>
private void UpdateMinMax(Bounds bounds, Matrix4x4 transform, ref Vector3 maxPos, ref Vector3 minPos)
{
var tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.min.x, bounds.min.y, bounds.min.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.min.x, bounds.min.y, bounds.max.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.min.x, bounds.max.y, bounds.min.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.min.x, bounds.max.y, bounds.max.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.max.x, bounds.min.y, bounds.min.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.max.x, bounds.min.y, bounds.max.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.max.x, bounds.max.y, bounds.min.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
tmpVec = transform.MultiplyPoint3x4(new Vector3(bounds.max.x, bounds.max.y, bounds.max.z));
maxPos = Vector3.Max(maxPos, tmpVec);
minPos = Vector3.Min(minPos, tmpVec);
}
示例5: DrawPushPlane
private static void DrawPushPlane(Matrix4x4 trs, Vector3 point, Vector3 dir)
{
point = trs.MultiplyPoint3x4(point);
dir = trs.MultiplyVector(dir);
Vector3 vector3 = point + (dir.normalized * 0.1f);
Gizmos.DrawLine(point, vector3);
Matrix4x4 matrix4x4 = Gizmos.matrix;
Gizmos.matrix = matrix4x4 * Matrix4x4.TRS(point, Quaternion.LookRotation(dir), Vector3.one);
Gizmos.DrawWireCube(Vector3.zero, new Vector3(1f, 1f, 0.0001f));
Gizmos.matrix = matrix4x4;
}
示例6: DebugArch
/// <summary>
/// - Debugs a circle.
/// </summary>
/// <param name='position'>
/// - Where the center of the circle will be positioned.
/// </param>
/// <param name='up'>
/// - The direction perpendicular to the surface of the circle.
/// </param>
/// <param name='color'>
/// - The color of the circle.
/// </param>
/// <param name='radius'>
/// - The radius of the circle.
/// </param>
/// <param name='duration'>
/// - How long to draw the circle.
/// </param>
/// <param name='depthTest'>
/// - Whether or not the circle should be faded when behind other objects.
/// </param>
public static void DebugArch(Vector3 position, Color color, float start = 0, float end = 360, float radius = 1.0f, float duration = 0, bool depthTest = true)
{
Vector3 _up = Vector3.up.normalized * radius;
Vector3 _forward = Vector3.Slerp(_up, -_up, 0.5f);
Vector3 _right = Vector3.Cross(_up, _forward).normalized*radius;
Matrix4x4 matrix = new Matrix4x4();
matrix[0] = _right.x;
matrix[1] = _right.y;
matrix[2] = _right.z;
matrix[4] = _up.x;
matrix[5] = _up.y;
matrix[6] = _up.z;
matrix[8] = _forward.x;
matrix[9] = _forward.y;
matrix[10] = _forward.z;
Vector3 _lastPoint = position + matrix.MultiplyPoint3x4(new Vector3(Mathf.Cos(0), 0, Mathf.Sin(0)));
Vector3 _nextPoint = Vector3.zero;
color = (color == default(Color)) ? Color.white : color;
for(var i = 0; i < 91; i++)
{
_nextPoint.x = Mathf.Cos((i*4)*Mathf.Deg2Rad);
_nextPoint.z = Mathf.Sin((i*4)*Mathf.Deg2Rad);
_nextPoint.y = 0;
_nextPoint = position + matrix.MultiplyPoint3x4(_nextPoint);
if (i*4 >= start && i*4 <= end)
{
Debug.DrawLine(_lastPoint, _nextPoint, color, duration, depthTest);
}
_lastPoint = _nextPoint;
}
}
示例7: ApplyTransform
/// <summary>
/// Step 2: Transform the vertices by the provided matrix.
/// </summary>
public void ApplyTransform (Matrix4x4 widgetToPanel)
{
if (verts.size > 0)
{
mRtpVerts.Clear();
for (int i = 0, imax = verts.size; i < imax; ++i) mRtpVerts.Add(widgetToPanel.MultiplyPoint3x4(verts[i]));
// Calculate the widget's normal and tangent
mRtpNormal = widgetToPanel.MultiplyVector(Vector3.back).normalized;
Vector3 tangent = widgetToPanel.MultiplyVector(Vector3.right).normalized;
mRtpTan = new Vector4(tangent.x, tangent.y, tangent.z, -1f);
}
else mRtpVerts.Clear();
}
示例8: ApplyTransform
/// <summary>
/// Step 3: Transform the vertices by the provided matrix.
/// </summary>
public void ApplyTransform(Matrix4x4 widgetToPanel, bool normals)
{
if (verts.size > 0)
{
mRtpVerts.Clear();
foreach (Vector3 v in verts) mRtpVerts.Add(widgetToPanel.MultiplyPoint3x4(v));
// Calculate the widget's normal and tangent
mRtpNormal = widgetToPanel.MultiplyVector(Vector3.back).normalized;
Vector3 tangent = widgetToPanel.MultiplyVector(Vector3.right).normalized;
mRtpTan = new Vector4(tangent.x, tangent.y, tangent.z, -1f);
}
else mRtpVerts.Clear();
}
示例9: RGBtoCIELAB
public static Vector3 RGBtoCIELAB( Color color )
{
// a crude (s)rgb -> xyz -> l*a*b* transform
Matrix4x4 xyzmat = new Matrix4x4();
xyzmat.SetRow( 0, new Vector4( 0.412453f, 0.357580f, 0.180423f, 0.0f ) );
xyzmat.SetRow( 1, new Vector4( 0.212671f, 0.715160f, 0.072169f, 0.0f ) );
xyzmat.SetRow( 2, new Vector4( 0.019334f, 0.119193f, 0.950227f, 0.0f ) );
xyzmat.SetRow( 3, new Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
Vector3 rgb = new Vector3( color.r, color.g, color.b );
Vector3 xyz = xyzmat.MultiplyPoint3x4( rgb );
float epsilon = 0.008856f;
Vector3 white = new Vector3( 95.047f, 100.0f, 108.883f ); // D65 white point in XYZ
float L, a, b;
if( (xyz.y / white.y) > epsilon ) {
L = 116.0f * Mathf.Pow( (xyz.y / white.y), 1.0f/3.0f ) - 16.0f;
} else {
L = 903.3f * xyz.y / white.y;
}
Vector3 xyz_fact = new Vector3();
if( (xyz.x / white.x) > epsilon ) {
xyz_fact.x = Mathf.Pow( (xyz.x / white.x), 1.0f/3.0f );
} else {
xyz_fact.x = 7.787f * (xyz.x / white.x) + 16.0f / 116.0f;
}
if( (xyz.y / white.y) > epsilon ) {
xyz_fact.y = Mathf.Pow( (xyz.y / white.y), 1.0f/3.0f );
} else {
xyz_fact.y = 7.787f * (xyz.y / white.y) + 16.0f / 116.0f;
}
if( (xyz.z / white.z) > epsilon ) {
xyz_fact.z = Mathf.Pow( (xyz.z / white.z), 1.0f/3.0f );
} else {
xyz_fact.z = 7.787f * (xyz.z / white.z) + 16.0f / 116.0f;
}
a = 500.0f * (xyz_fact.x - xyz_fact.y);
b = 200.0f * (xyz_fact.y - xyz_fact.z);
return new Vector3( L, a, b );
}
示例10: Map
public override Vector3 Map(int i, Vector3 p)
{
p = tm.MultiplyPoint3x4(p); // Dont need either, so saving 3 vector mat mults but gaining a mat mult
float alpha;
if ( UseStretchCurve )
{
float str = stretchCurve.Evaluate(Mathf.Repeat(p.z * ovlen + usepercent, 1.0f)) * stretch;
alpha = (p.z * ovlen * str) + usepercent; //(percent / 100.0f); // can precalc this
}
else
alpha = (p.z * ovlen * stretch) + usepercent; //(percent / 100.0f); // can precalc this
Vector3 ps = path.InterpCurve3D(0, alpha, path.normalizedInterp); // - start;
Vector3 ps1 = path.InterpCurve3D(0, alpha + usetan, path.normalizedInterp); // - start;
if ( path.splines[0].closed )
alpha = Mathf.Repeat(alpha, 1.0f);
else
alpha = Mathf.Clamp01(alpha);
Quaternion tw = Quaternion.identity;
if ( UseTwistCurve )
{
float twst = twistCurve.Evaluate(alpha) * twist;
tw = Quaternion.AngleAxis(twst, Vector3.forward);
}
else
tw = Quaternion.AngleAxis(twist * alpha, Vector3.forward);
Vector3 relativePos = ps1 - ps;
Quaternion rotation = Quaternion.LookRotation(relativePos) * tw;
Matrix4x4 wtm = new Matrix4x4();
wtm.SetTRS(ps, rotation, Vector3.one);
wtm = mat * wtm;
p.z = 0.0f;
return wtm.MultiplyPoint3x4(p);
}
示例11: ApplyTransform
public void ApplyTransform(Matrix4x4 widgetToPanel)
{
if (this.verts.size > 0)
{
this.mRtpVerts.Clear();
int num = 0;
int size = this.verts.size;
while (num < size)
{
this.mRtpVerts.Add(widgetToPanel.MultiplyPoint3x4(this.verts[num]));
num++;
}
this.mRtpNormal = widgetToPanel.MultiplyVector(Vector3.back).normalized;
Vector3 normalized = widgetToPanel.MultiplyVector(Vector3.right).normalized;
this.mRtpTan = new Vector4(normalized.x, normalized.y, normalized.z, -1f);
}
else
{
this.mRtpVerts.Clear();
}
}
示例12: Line3DDiscrete
private void Line3DDiscrete (int start, int end, Matrix4x4 thisMatrix, bool useTransformMatrix) {
if (!cam3D) {
LogError ("The 3D camera no longer exists...if you have changed scenes, ensure that SetCamera3D is called in order to set it up.");
return;
}
if (m_1pixelLine) {
Vector3 p1;
for (int i = start; i <= end; i++) {
p1 = useTransformMatrix? cam3D.WorldToScreenPoint (thisMatrix.MultiplyPoint3x4 (points3[i])) :
cam3D.WorldToScreenPoint (points3[i]);
p1.z = p1.z < cutoff? -zDist : zDist;
m_lineVertices[i] = p1;
}
return;
}
Vector3 pos1, pos2, perpendicular;
float normalizedDistance = 0.0f;
int widthIdx = 0;
widthIdxAdd = 0;
if (m_lineWidths.Length > 1) {
widthIdx = start;
widthIdxAdd = 1;
}
int idx = start*2;
for (int i = start; i < end; i += 2) {
if (useTransformMatrix) {
pos1 = cam3D.WorldToScreenPoint (thisMatrix.MultiplyPoint3x4 (points3[i]));
pos2 = cam3D.WorldToScreenPoint (thisMatrix.MultiplyPoint3x4 (points3[i+1]));
}
else {
pos1 = cam3D.WorldToScreenPoint (points3[i]);
pos2 = cam3D.WorldToScreenPoint (points3[i+1]);
}
pos1.z = pos1.z < cutoff? -zDist : zDist;
if (pos1.x == pos2.x && pos1.y == pos2.y) {Skip (ref idx, ref widthIdx, ref pos1); continue;}
pos2.z = pos2.z < cutoff? -zDist : zDist;
v1.x = pos2.y; v1.y = pos1.x;
v2.x = pos1.y; v2.y = pos2.x;
perpendicular = v1 - v2;
normalizedDistance = 1.0f / Mathf.Sqrt((perpendicular.x * perpendicular.x) + (perpendicular.y * perpendicular.y));
perpendicular *= normalizedDistance * m_lineWidths[widthIdx];
m_lineVertices[idx] = pos1 - perpendicular;
m_lineVertices[idx+1] = pos1 + perpendicular;
if (smoothWidth && i < end-2) {
perpendicular = v1 - v2;
perpendicular *= normalizedDistance * m_lineWidths[widthIdx+1];
}
m_lineVertices[idx+2] = pos2 - perpendicular;
m_lineVertices[idx+3] = pos2 + perpendicular;
idx += 4;
widthIdx += widthIdxAdd;
}
if (m_joins == Joins.Weld) {
WeldJoinsDiscrete (start + 1, end, Approximately3 (points3[0], points3[points3.Length-1])
&& m_minDrawIndex == 0 && (m_maxDrawIndex == points3.Length-1 || m_maxDrawIndex == 0));
}
}
示例13: DrawLocalCube
/// <summary>
/// - Draws a local cube.
/// </summary>
/// <param name='space'>
/// - The space the cube will be local to.
/// </param>
/// <param name='size'>
/// - The local size of the cube.
/// </param>
/// <param name='center'>
/// - The local position of the cube.
/// </param>
/// <param name='color'>
/// - The color of the cube.
/// </param>
public static void DrawLocalCube(Matrix4x4 space, Vector3 size, Color color, Vector3 center = default(Vector3))
{
Color oldColor = Gizmos.color;
Gizmos.color = color;
Vector3 lbb = space.MultiplyPoint3x4(center+((-size)*0.5f));
Vector3 rbb = space.MultiplyPoint3x4(center+(new Vector3(size.x, -size.y, -size.z)*0.5f));
Vector3 lbf = space.MultiplyPoint3x4(center+(new Vector3(size.x, -size.y, size.z)*0.5f));
Vector3 rbf = space.MultiplyPoint3x4(center+(new Vector3(-size.x, -size.y, size.z)*0.5f));
Vector3 lub = space.MultiplyPoint3x4(center+(new Vector3(-size.x, size.y, -size.z)*0.5f));
Vector3 rub = space.MultiplyPoint3x4(center+(new Vector3(size.x, size.y, -size.z)*0.5f));
Vector3 luf = space.MultiplyPoint3x4(center+((size)*0.5f));
Vector3 ruf = space.MultiplyPoint3x4(center+(new Vector3(-size.x, size.y, size.z)*0.5f));
Gizmos.DrawLine(lbb, rbb);
Gizmos.DrawLine(rbb, lbf);
Gizmos.DrawLine(lbf, rbf);
Gizmos.DrawLine(rbf, lbb);
Gizmos.DrawLine(lub, rub);
Gizmos.DrawLine(rub, luf);
Gizmos.DrawLine(luf, ruf);
Gizmos.DrawLine(ruf, lub);
Gizmos.DrawLine(lbb, lub);
Gizmos.DrawLine(rbb, rub);
Gizmos.DrawLine(lbf, luf);
Gizmos.DrawLine(rbf, ruf);
Gizmos.color = oldColor;
}
示例14: DrawCircle
/// <summary>
/// - Draws a circle.
/// </summary>
/// <param name='position'>
/// - Where the center of the circle will be positioned.
/// </param>
/// <param name='up'>
/// - The direction perpendicular to the surface of the circle.
/// </param>
/// <param name='color'>
/// - The color of the circle.
/// </param>
/// <param name='radius'>
/// - The radius of the circle.
/// </param>
public static void DrawCircle(Vector3 position, Vector3 up, Color color, float radius = 1.0f)
{
up = ((up == Vector3.zero) ? Vector3.up : up).normalized * radius;
Vector3 _forward = Vector3.Slerp(up, -up, 0.5f);
Vector3 _right = Vector3.Cross(up, _forward).normalized*radius;
Matrix4x4 matrix = new Matrix4x4();
matrix[0] = _right.x;
matrix[1] = _right.y;
matrix[2] = _right.z;
matrix[4] = up.x;
matrix[5] = up.y;
matrix[6] = up.z;
matrix[8] = _forward.x;
matrix[9] = _forward.y;
matrix[10] = _forward.z;
Vector3 _lastPoint = position + matrix.MultiplyPoint3x4(new Vector3(Mathf.Cos(0), 0, Mathf.Sin(0)));
Vector3 _nextPoint = Vector3.zero;
Color oldColor = Gizmos.color;
Gizmos.color = (color == default(Color)) ? Color.white : color;
for(var i = 0; i < 91; i++){
_nextPoint.x = Mathf.Cos((i*4)*Mathf.Deg2Rad);
_nextPoint.z = Mathf.Sin((i*4)*Mathf.Deg2Rad);
_nextPoint.y = 0;
_nextPoint = position + matrix.MultiplyPoint3x4(_nextPoint);
Gizmos.DrawLine(_lastPoint, _nextPoint);
_lastPoint = _nextPoint;
}
Gizmos.color = oldColor;
}
示例15: CalculateRelativeWidgetBounds
static void CalculateRelativeWidgetBounds (Transform content, ConsiderActiveType considerActiveType, bool isRoot,
ref Matrix4x4 toLocal, ref Vector3 vMin, ref Vector3 vMax, ref bool isSet)
{
if (content == null) return;
if (considerActiveType == ConsiderActiveType.activeInHierarchy)
{
if (!NGUITools.GetActive(content.gameObject))
return;
}
else if (considerActiveType == ConsiderActiveType.activeSelf)
{
if (!NGUITools.GetActiveSelf(content.gameObject))
return;
}
if (content.GetComponent<UINoBounds>() != null) return;
// If this isn't a root node, check to see if there is a panel present
UIPanel p = isRoot ? null : content.GetComponent<UIPanel>();
// Ignore disabled panels as a disabled panel means invisible children
if (p != null && !p.enabled) return;
// If there is a clipped panel present simply include its dimensions
if (p != null && p.clipping != UIDrawCall.Clipping.None)
{
Vector3[] corners = p.worldCorners;
for (int j = 0; j < 4; ++j)
{
Vector3 v = toLocal.MultiplyPoint3x4(corners[j]);
if (v.x > vMax.x) vMax.x = v.x;
if (v.y > vMax.y) vMax.y = v.y;
if (v.z > vMax.z) vMax.z = v.z;
if (v.x < vMin.x) vMin.x = v.x;
if (v.y < vMin.y) vMin.y = v.y;
if (v.z < vMin.z) vMin.z = v.z;
isSet = true;
}
}
else // No panel present
{
// If there is a widget present, include its bounds
UIWidget w = content.GetComponent<UIWidget>();
if (w != null && w.enabled)
{
Vector3[] corners = w.worldCorners;
for (int j = 0; j < 4; ++j)
{
Vector3 v = toLocal.MultiplyPoint3x4(corners[j]);
if (v.x > vMax.x) vMax.x = v.x;
if (v.y > vMax.y) vMax.y = v.y;
if (v.z > vMax.z) vMax.z = v.z;
if (v.x < vMin.x) vMin.x = v.x;
if (v.y < vMin.y) vMin.y = v.y;
if (v.z < vMin.z) vMin.z = v.z;
isSet = true;
}
}
// Iterate through children including their bounds in turn
for (int i = 0, imax = content.childCount; i < imax; ++i)
CalculateRelativeWidgetBounds(content.GetChild(i), considerActiveType, false, ref toLocal, ref vMin, ref vMax, ref isSet);
}
}