本文整理汇总了C#中UnityEngine.Matrix4x4.MultiplyVector方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4.MultiplyVector方法的具体用法?C# Matrix4x4.MultiplyVector怎么用?C# Matrix4x4.MultiplyVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4.MultiplyVector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: MatrixDeCompose
public static void MatrixDeCompose(Matrix4x4 m, out Vector3 pos, out Vector3 scale, out Quaternion quat)
{
//quat
Vector3 vf = m.MultiplyVector(Vector3.forward);
Vector3 vu = m.MultiplyVector(Vector3.up);
quat = Quaternion.LookRotation(vf, vu);
//pos
pos = new Vector3(m.m03, m.m13, m.m23);
//去掉旋转和偏移
m.m03 = 0; m.m13 = 0; m.m23 = 0;
Matrix4x4 im = Matrix4x4.TRS(Vector3.zero, quat, Vector3.one);
m *= im.inverse;
//scale
scale = new Vector3(m.m00, m.m11, m.m22);
}
示例7: OnWizardCreate
void OnWizardCreate()
{
Texture2D tmpTexture = SSBumpMap;
Matrix4x4 mat = new Matrix4x4();
mat.SetRow(0, basis[0]);
mat.SetRow(1, basis[1]);
mat.SetRow(2, basis[2]);
Matrix4x4 convMat = new Matrix4x4();
convMat.SetRow(0, (mat.MultiplyVector(new Vector3(1, 0, 0))));
convMat.SetRow(1, (mat.MultiplyVector(new Vector3(0, 1, 0))));
convMat.SetRow(2, (mat.MultiplyVector(new Vector3(0, 0, 1))));
TexturesSpaceConversions.ConvertTangentBasis(convMat, ref tmpTexture, recomputeZ);
string path = Application.dataPath + "/Converted Normal Maps";
FileSystemUtilities.CreateDirectory(path);
FileSystemUtilities.SavePNG(ref tmpTexture, path + "/" + SSBumpMap.name + "_normal.png");
}
示例8: AirbreathingEngineCrossSectonAdjuster
public AirbreathingEngineCrossSectonAdjuster(ModuleEngines engine, Matrix4x4 worldToVesselMatrix)
{
vehicleBasisForwardVector = Vector3.forward;
//for (int i = 0; i < engine.thrustTransforms.Count; i++)
// vehicleBasisForwardVector += engine.thrustTransforms[i].forward;
thisToVesselMatrix = worldToVesselMatrix * engine.thrustTransforms[0].localToWorldMatrix;
vehicleBasisForwardVector = thisToVesselMatrix.MultiplyVector(vehicleBasisForwardVector);
vehicleBasisForwardVector.Normalize();
vehicleBasisForwardVector *= -1f;
this.engine = engine;
this.part = engine.part;
Bounds partBounds = part.GetPartColliderBoundsInBasis(Matrix4x4.identity);
exitArea = partBounds.extents.x + partBounds.extents.z;
exitArea *= 0.5;
exitArea *= exitArea;
exitArea *= Math.PI;
exitArea *= -1; //make this negative to note that it is a removal of area
}
示例9: 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;
}
示例10: 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);
}
示例11: 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;
}
示例12: 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();
}
}
示例13: Update
// Update is called once per frame
void Update () {
if(m_time<= 0){
float angle = Random.value*360.0f;
m_time = (Random.value*3.0f)+2.0f;
Matrix4x4 rotMatrix = new Matrix4x4();
rotMatrix.SetTRS(new Vector3(), Quaternion.Euler(0.0f, angle, 0.0f), new Vector3(1.0f, 1.0f, 1.0f));
body.velocity = rotMatrix.MultiplyVector(Vector3.right);
body.velocity *= m_speed;
}else{
m_time-=Time.deltaTime;
}
}
示例14: shoot
void shoot(){
//Create Shot
Vector3 projectilePosition = this.transform.position;
projectilePosition += this.transform.right * 1.5f;
Transform clone = Instantiate(projectile, projectilePosition, Quaternion.identity) as Transform;
activeAbility.setShot(clone.GetComponent<Projectile>());
clone.RotateAround(this.transform.position, Vector3.up, m_angleToMouse);
//Shot Pattern
Matrix4x4 rotMatrix = new Matrix4x4();
rotMatrix.SetTRS(new Vector3(), Quaternion.Euler(0.0f, m_angleToMouse, 0.0f), new Vector3(1.0f, 1.0f, 1.0f));
clone.GetComponent<Rigidbody>().velocity = rotMatrix.MultiplyVector(Vector3.right);
clone.GetComponent<Rigidbody>().velocity *= shotSpeed;
}
示例15: shoot
void shoot(){
if(player!=null){
float angleToPlayer = -Mathf.Atan2(player.position.z-transform.position.z, player.position.x-transform.position.x)*Mathf.Rad2Deg;
Vector3 projectilePosition = this.transform.position;
projectilePosition += this.transform.right * 1.5f;
Transform clone = Instantiate(projectile, projectilePosition, Quaternion.identity) as Transform;
attack.setShot(clone.GetComponent<Projectile>());
clone.RotateAround(this.transform.position, Vector3.up, angleToPlayer);
Matrix4x4 rotMatrix = new Matrix4x4();
rotMatrix.SetTRS(new Vector3(), Quaternion.Euler(0.0f, angleToPlayer, 0.0f), new Vector3(1.0f, 1.0f, 1.0f));
clone.GetComponent<Rigidbody>().velocity = rotMatrix.MultiplyVector(Vector3.right);
clone.GetComponent<Rigidbody>().velocity *= speed;
}
}