本文整理汇总了C#中Face.GetNormal方法的典型用法代码示例。如果您正苦于以下问题:C# Face.GetNormal方法的具体用法?C# Face.GetNormal怎么用?C# Face.GetNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Face
的用法示例。
在下文中一共展示了Face.GetNormal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAxisBaseIndex
public int GetAxisBaseIndex(Face face)
{
Vector3 normal = face.GetNormal();
int bestIndex = 0;
float bestDot = 0.0f;
for (int i = 0; i < 6; i++)
{
float dot = 0.0f;
Vector3.Dot(ref normal, ref BaseAxes[i * 3], out dot);
if (dot > bestDot)
{ // no need to use -altaxis for qbsp
bestDot = dot;
bestIndex = i;
}
}
return bestIndex;
}
示例2: GetTextureCoordinate
public override Vector2 GetTextureCoordinate(Face face, Vector3 point)
{
Vector2 ret = new Vector2();
// Calculate coordinate axes if we don't have them (Quake, HalfLife/Valve200 will include them)
if (!face.XTexVector.HasValue || !face.YTexVector.HasValue)
{
Vector3 normal = face.GetNormal();
int bestIndex = GetAxisBaseIndex(face);
Vector3 xAxis = BaseAxes[bestIndex * 3 + 1];
Vector3 yAxis = BaseAxes[bestIndex * 3 + 2];
int planeNormIndex = (bestIndex / 2) * 6;
int faceNormIndex = bestIndex * 3;
float radAngle = face.Angle / 180.0f * 3.1415f;
Quaternion quat = new Quaternion(BaseAxes[planeNormIndex], planeNormIndex == 12 ? -radAngle : radAngle);
Quaternion con = quat;
con.Conjugate();
Quaternion xQuat = quat;
xQuat.Normalized();
xQuat = Quaternion.Multiply(Quaternion.Multiply(xQuat, new Quaternion(xAxis, 0)), con);
Quaternion yQuat = quat;
yQuat.Normalized();
yQuat = Quaternion.Multiply(Quaternion.Multiply(yQuat, new Quaternion(yAxis, 0)), con);
face.XTexVector = xQuat.Xyz;
face.YTexVector = yQuat.Xyz;
}
float XScale = face.Scale.X == 0.0f ? 1.0f : face.Scale.X;
float YScale = face.Scale.Y == 0.0f ? 1.0f : face.Scale.Y;
Vector3 scaledAxisX = Vector3.Divide(face.XTexVector.Value, XScale);
Vector3 scaledAxisY = Vector3.Divide(face.YTexVector.Value, YScale);
// Treyarch format includes the image basis, in Q1/Q2/Q3/HL this is based on texture width
ret.X = (Vector3.Dot(point, scaledAxisX) + face.Offset.X) / face.ImageBasis.Value.X;
ret.Y = (Vector3.Dot(point, scaledAxisY) + face.Offset.Y) / face.ImageBasis.Value.Y;
return ret;
}