本文整理汇总了C#中UnityEngine.Matrix4x4.GetRow方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4.GetRow方法的具体用法?C# Matrix4x4.GetRow怎么用?C# Matrix4x4.GetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4.GetRow方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawRows
public static Matrix4x4 DrawRows( Matrix4x4 matrix )
{
matrix.SetRow( 0, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetRow( 0 ) ) );
matrix.SetRow( 1, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetRow( 1 ) ) );
matrix.SetRow( 2, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetRow( 2 ) ) );
matrix.SetRow( 3, EditorGUI.Vector4Field( GetRekt(), "", matrix.GetRow( 3 ) ) );
return matrix;
}
示例2: Matrix4x4Field
static void Matrix4x4Field(string label, ref Matrix4x4 mat)
{
GUILayout.Label(label);
mat.SetRow(0, EditorGUILayout.Vector4Field("0", mat.GetRow(0)));
mat.SetRow(1, EditorGUILayout.Vector4Field("1", mat.GetRow(1)));
mat.SetRow(2, EditorGUILayout.Vector4Field("2", mat.GetRow(2)));
mat.SetRow(3, EditorGUILayout.Vector4Field("3", mat.GetRow(3)));
}
示例3: Mul
Vector4 Mul(Matrix4x4 matrix, Vector4 vec4)
{
var res = new Vector4();
res.x = Vector4.Dot(matrix.GetRow(0), vec4);
res.y = Vector4.Dot(matrix.GetRow(1), vec4);
res.z = Vector4.Dot(matrix.GetRow(2), vec4);
res.w = Vector4.Dot(matrix.GetRow(3), vec4);
return res;
}
示例4: Mul4
Vector4 Mul4(Matrix4x4 m, Vector4 v)
{
var res = new Vector4();
res.x = Vector4.Dot(m.GetRow(0), v);
res.y = Vector4.Dot(m.GetRow(1), v);
res.z = Vector4.Dot(m.GetRow(2), v);
res.w = Vector4.Dot(m.GetRow(3), v);
return res;
}
示例5: constructProjectionMatrix3x4
public static Matrix4x4 constructProjectionMatrix3x4(float[] projection, float width, float height, float near, float far)
{
float r = width;
float l = 0.0f;
float t = height;
float b = 0.0f;
Matrix4x4 m = new Matrix4x4();
m.m00 = projection[0];
m.m01 = projection[1];
m.m02 = projection[2];
m.m03 = projection[3];
m.m10 = projection[4];
m.m11 = projection[5];
m.m12 = projection[6];
m.m13 = projection[7];
m.m20 = projection[8];
m.m21 = projection[9];
m.m22 = projection[10];
m.m23 = projection[11];
Vector4 row2 = m.GetRow(2);
m.SetRow(3, row2);
float norm = Mathf.Sqrt(m.m20 * m.m20 + m.m21 * m.m21 + m.m22 * m.m22);
float add = far * near * norm;
row2 = row2 * (-far - near);
m.SetRow(2, row2);
m.m23 += add;
Matrix4x4 ortho = new Matrix4x4();
ortho.m00 = 2.0f / (r - l);
ortho.m01 = 0.0f;
ortho.m02 = 0.0f;
ortho.m03 = (r + l) / (l - r);
ortho.m10 = 0.0f;
ortho.m11 = 2.0f / (t - b);
ortho.m12 = 0.0f;
ortho.m13 = (t + b) / (b - t);
ortho.m20 = 0.0f;
ortho.m21 = 0.0f;
ortho.m22 = 2.0f / (near - far);
ortho.m23 = (far + near) / (near - far);
ortho.m30 = 0.0f;
ortho.m31 = 0.0f;
ortho.m32 = 0.0f;
ortho.m33 = 1.0f;
Matrix4x4 res = new Matrix4x4();
res = ortho * m;
return res;
}
示例6: ConvertMatrix4x4ToDouble16
//Convert Matrix4x4 to double16
public static double[] ConvertMatrix4x4ToDouble16(Matrix4x4 m)
{
double[] double16 = new double[16];
int factor = 0;
for (int i = 0; i < 4; i++)
{
double16[factor+i] = (double)m.GetRow(i).x;
double16[factor+i+1] = (double)m.GetRow(i).y;
double16[factor+i+2] = (double)m.GetRow(i).z;
double16[factor+i+3] = (double)m.GetRow(i).w;
factor += 3;
}
return double16;
}
示例7: Determinant
float Determinant(Matrix4x4 m)
{
Vector3 r0 = m.GetRow(0);
Vector3 r1 = m.GetRow(1);
Vector3 r2 = m.GetRow(2);
return -(r0.z * r1.y * r2.x) + (r0.y * r1.z * r2.x) + (r0.z * r1.x * r2.y) - (r0.x * r1.z * r2.y) - (r0.y * r1.x * r2.z) + (r0.x * r1.y * r2.z);
}
示例8: multiply
Vector4 multiply(Matrix4x4 mat, Vector4 point)
{
// Multiplies a 4x4 matrix by a vector4
Vector4 returnVal = new Vector4();
Vector4 row0 = mat.GetRow(0); Vector4 row1 = mat.GetRow(1); Vector4 row2 = mat.GetRow(2); Vector4 row3 = mat.GetRow(3);
returnVal.x = row0.x*point.x + row0.y*point.y + row0.z*point.z + row0.w*point.w;
returnVal.y = row1.x*point.x + row1.y*point.y + row1.z*point.z + row1.w*point.w;
returnVal.z = row2.x*point.x + row2.y*point.y + row2.z*point.z + row2.w*point.w;
returnVal.w = row3.x*point.x + row3.y*point.y + row3.z*point.z + row3.w*point.w;
return returnVal;
}
示例9: GetFrustumMax
/// <summary>
/// Calculates the max point of the frustum bound.
/// </summary>
private static Vector3 GetFrustumMax(Matrix4x4 frustumCorners)
{
Vector3 frustumMax = new Vector3(float.MinValue, float.MinValue, float.MinValue);
for (int i = 0; i < 4; ++i)
{
frustumMax = Vector3.Max(frustumMax, frustumCorners.GetRow(i));
}
return frustumMax;
}
示例10: GetMatrixAsCsv
// gets matrix values as csv line
public static string GetMatrixAsCsv(ref Matrix4x4 mat)
{
// create the output string
StringBuilder sbBuf = new StringBuilder();
const char delimiter = ',';
sbBuf.Append("km").Append(delimiter);
for(int i = 0; i < 4; i++)
{
Vector4 vRow = mat.GetRow(i);
sbBuf.AppendFormat("{0:F3}", vRow.x).Append(delimiter);
sbBuf.AppendFormat("{0:F3}", vRow.y).Append(delimiter);
sbBuf.AppendFormat("{0:F3}", vRow.z).Append(delimiter);
sbBuf.AppendFormat("{0:F3}", vRow.w).Append(delimiter);
}
// remove the last delimiter
if(sbBuf.Length > 0 && sbBuf[sbBuf.Length - 1] == delimiter)
{
sbBuf.Remove(sbBuf.Length - 1, 1);
}
return sbBuf.ToString();
}