Beispiel #1
0
    /// <summary>
    /// Converts the string of index (ex: "1/4/3") data into a VertexCombo.
    /// </summary>
    static VertexCombo MakeVertexCombo(string vertIndices)
    {
        VertexCombo ret = new VertexCombo();

        string[] asParts = vertIndices.Split('/');
        ret.aVertIndex    = int.Parse(asParts[0]) - 1;
        ret.bTextureIndex = int.Parse(asParts[1]) - 1;
        ret.cNormalIndex  = int.Parse(asParts[2]) - 1;
        return(ret);
    }
Beispiel #2
0
    /// <summary>
    /// Adds a line of triangle data to our in-memory data.
    /// (ex: "1/1/1 2/4/9 8/4/2").
    /// </summary>
    /// <param name="lineParts"></param>
    static void AddFace(string[] lineParts)
    {
        VertexCombo one   = MakeVertexCombo(lineParts[1]);
        VertexCombo two   = MakeVertexCombo(lineParts[2]);
        VertexCombo three = MakeVertexCombo(lineParts[3]);

        addIndex(one);
        addIndex(two);
        addIndex(three);
    }
Beispiel #3
0
    /// <summary>
    /// Detects if this VertexCombo has been seen before. If so, we just
    /// use the index of the exising vertex. Otherwise we add this combo
    /// and use its index instead.
    /// </summary>
    /// <param name="combo"></param>
    static void addIndex(VertexCombo combo)
    {
        ushort index = (ushort)vertexCombos.IndexOf(combo);

        if (index == unchecked ((ushort)-1))
        {
            vertexCombos.Add(combo);
            index = (ushort)(vertexCombos.Count - 1);
        }
        indices.Add(index);
    }
Beispiel #4
0
    public override bool Equals(object obj)
    {
        VertexCombo other = obj as VertexCombo;

        return(other.aVertIndex == aVertIndex && other.bTextureIndex == bTextureIndex && other.cNormalIndex == cNormalIndex);
    }