Example #1
0
        public RawVertex Clone()
        {
            RawVertex ret = new RawVertex(position, texCoord, normal, tangent);

            ret.blendIndex1  = blendIndex1;
            ret.blendIndex2  = blendIndex2;
            ret.blendIndex3  = blendIndex3;
            ret.blendIndex4  = blendIndex4;
            ret.blendWeight1 = blendWeight1;
            ret.blendWeight2 = blendWeight2;
            ret.blendWeight3 = blendWeight3;
            ret.blendWeight4 = blendWeight4;
            return(ret);
        }
Example #2
0
 /// <summary>
 /// Returns true if two vertices are nearly equal. For example the
 /// tangent or normal data does not have to match 100%.
 /// Used to optimize vertex buffers and to generate indices.
 /// </summary>
 /// <param name="a">A</param>
 /// <param name="b">B</param>
 /// <returns>Bool</returns>
 public static bool NearlyEquals(RawVertex a, RawVertex b)
 {
     //SkinningWithColladaModelsInXna.Helpers.Log.Write("Compare a=" + a.pos + ", " + a.uv + ", "+a.normal+
     //  " with b=" + b.pos + ", " + b.uv+ ", "+b.normal);
     //return false;
     // Position has to match, else it is just different vertex
     return(a.position == b.position &&
            // Ignore blend indices and blend weights, they are the same
            // anyway, because they are calculated from the bone distances.
            Math.Abs(a.texCoord.X - b.texCoord.X) < 0.001f &&
            Math.Abs(a.texCoord.Y - b.texCoord.Y) < 0.001f &&
            // Normals and tangents do not have to be very close, we can't see
            // any difference between small variations here, but by optimizing
            // similar vertices we can improve the overall rendering performance.
            (a.normal - b.normal).Length() < 0.1f &&
            (a.tangent - b.tangent).Length() < 0.1f);
 }