当前位置: 首页>>代码示例>>C#>>正文


C# Face.GetNormal方法代码示例

本文整理汇总了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;
 }
开发者ID:JoshEngebretson,项目名称:QMapConverter,代码行数:17,代码来源:QuakeTextureStrategy.cs

示例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;
        }
开发者ID:JoshEngebretson,项目名称:QMapConverter,代码行数:45,代码来源:Quake3TextureStrategy.cs


注:本文中的Face.GetNormal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。