public void EndPoint(PointComponents currentPoint, List <int> cwPolyPoints, List <int> ccwPolyPoints)
        {
            AddPointComponents(cwPolyPoints, currentPoint);

            // Build a copy of currentPointComponents with normals inverted
            if (ccwPolyPoints == null)
            {
                return;
            }

            PointComponents tmpPointComponents = new PointComponents(currentPoint);

            List <InputSource> sources = GetAllInputSources();

            for (int accessIndex = 0; accessIndex < sources.Count; ++accessIndex)
            {
                // For normals, since we need to invert them in the copy,
                // we use a negating accessor, and tamper with the point
                // component to change the index to the portion that is negated.
                if (sources[accessIndex].IsNormal)
                {
                    Debug.Assert(sources[accessIndex].Accessor is NegatingFloatAccessor);

                    tmpPointComponents[accessIndex] = -1 * tmpPointComponents[accessIndex];
                }
            }

            AddPointComponents(ccwPolyPoints, tmpPointComponents);
        }
        /// <summary>
        ///   This adds the composite point currentPoint to the set of
        ///   points in this object.  If there is already a point that
        ///   matches, we will use that instead.
        /// </summary>
        /// <param name="polyPoints"></param>
        /// <param name="currentPoint"></param>
        private void AddPointComponents(List <int> polyPoints, PointComponents currentPoint)
        {
            if (polyPoints == null)
            {
                return;
            }

            int compositeIndex = pointSets.IndexOf(currentPoint);

            if (compositeIndex < 0)
            {
                // we don't already have an entry for this point
                int vertexIndex = currentPoint.VertexIndex;
                if (vertexIndex < 0)
                {
                    m_Log.ErrorFormat("No vertex id for point with vertex index: {0}", vertexIndex);
                }

                pointSets.Add(currentPoint);

                compositeIndex = pointSets.Count - 1;

                if (!vertexIds.ContainsKey(vertexIndex))
                {
                    vertexIds[vertexIndex] = new List <int>();
                }

                vertexIds[vertexIndex].Add(compositeIndex);
            }

            polyPoints.Add(compositeIndex);
        }
        internal VertexDataEntry ExtractData(VertexElementSemantic semantic,
                                             int vertexCount, InputSource source,
                                             List <PointComponents> indexSets, int accessIndex)
        {
            float[ , ] fdata = null;
            uint[ , ] idata  = null;
            switch (semantic)
            {
            case VertexElementSemantic.Diffuse:
                idata = new uint[vertexCount, 1];
                for (int i = 0; i < vertexCount; ++i)
                {
                    PointComponents components = indexSets[i];
                    int             inputIndex = components[accessIndex];
                    ColorEx         color      = ColorEx.Black;
                    color.r = (float)source.Accessor.GetParam("R", inputIndex);
                    color.g = (float)source.Accessor.GetParam("G", inputIndex);
                    color.b = (float)source.Accessor.GetParam("B", inputIndex);
                    if (source.Accessor.ContainsParam("A"))
                    {
                        color.a = (float)source.Accessor.GetParam("A", inputIndex);
                    }
                    idata[i, 0] = Root.Instance.RenderSystem.ConvertColor(color);
                }
                break;

            case VertexElementSemantic.TexCoords:
                fdata = new float[vertexCount, 2];
                for (int i = 0; i < vertexCount; ++i)
                {
                    PointComponents components = indexSets[i];
                    int             inputIndex = components[accessIndex];
                    // S,T or U,V ?
                    if (source.Accessor.ContainsParam("S"))
                    {
                        fdata[i, 0] = (float)source.Accessor.GetParam("S", inputIndex);
                        fdata[i, 1] = 1.0f - (float)source.Accessor.GetParam("T", inputIndex);
                    }
                    else if (source.Accessor.ContainsParam("U"))
                    {
                        fdata[i, 0] = (float)source.Accessor.GetParam("U", inputIndex);
                        fdata[i, 1] = 1.0f - (float)source.Accessor.GetParam("V", inputIndex);
                    }
                    else
                    {
                        Debug.Assert(false, "Invalid param names");
                    }
                }
                break;

            case VertexElementSemantic.Position:
            case VertexElementSemantic.Normal:
            case VertexElementSemantic.Tangent:
            case VertexElementSemantic.Binormal:
                fdata = new float[vertexCount, 3];
                for (int i = 0; i < vertexCount; ++i)
                {
                    PointComponents components = indexSets[i];
                    int             inputIndex = components[accessIndex];
                    Vector3         tmp        = Vector3.Zero;
                    tmp.x = (float)source.Accessor.GetParam("X", inputIndex);
                    tmp.y = (float)source.Accessor.GetParam("Y", inputIndex);
                    tmp.z = (float)source.Accessor.GetParam("Z", inputIndex);
                    for (int j = 0; j < 3; ++j)
                    {
                        fdata[i, j] = tmp[j];
                    }
                }
                break;

            default:
                m_Log.InfoFormat("Unknown semantic: {0}", semantic);
                return(null);
            }
            if (fdata == null && idata == null)
            {
                return(null);
            }

            VertexDataEntry vde = new VertexDataEntry();

            vde.semantic = semantic;
            vde.fdata    = fdata;
            vde.idata    = idata;
            return(vde);
        }
 /// <summary>
 ///   Add a point component.
 /// </summary>
 /// <param name="index">Index within the given input source</param>
 public void AddPointComponent(PointComponents currentPoint, int index)
 {
     currentPoint.Add(index);
 }