/// Copy constructor from an Ogre simplespline
 public CatmullRomSpline3(Mogre.SimpleSpline input)
 {
     mPoints.resize((int)input.NumPoints);
     for (ushort i = 0; i < input.NumPoints; i++)
     {
         mPoints.push_back(input.GetPoint(i));
     }
 }
        //--------------------------------------------------------------
        public void modify()
        {
            if (mInputTriangleBuffer == null)
            {
                OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Input triangle buffer must be set", "__FUNCTION__");
            }
            ;

            if (mComputeMode == NormalComputeMode.NCM_TRIANGLE)
            {
                if (mMustWeldUnweldFirst)
                {
                    new UnweldVerticesModifier().setInputTriangleBuffer(mInputTriangleBuffer).modify();
                }

                std_vector <int> indices = mInputTriangleBuffer.getIndices();
                std_vector <TriangleBuffer.Vertex> vertices = mInputTriangleBuffer.getVertices();
                for (int i = 0; i < indices.size(); i += 3)
                {
                    Vector3 v1 = vertices[indices[i]].mPosition;
                    Vector3 v2 = vertices[indices[i + 1]].mPosition;
                    Vector3 v3 = vertices[indices[i + 2]].mPosition;
                    Vector3 n  = (v2 - v1).CrossProduct(v3 - v1).NormalisedCopy;
                    //
                    //ORIGINAL LINE: vertices[indices[i]].mNormal = n;
                    vertices[indices[i]].mNormal = (n);
                    //
                    //ORIGINAL LINE: vertices[indices[i+1]].mNormal = n;
                    vertices[indices[i + 1]].mNormal = (n);
                    //
                    //ORIGINAL LINE: vertices[indices[i+2]].mNormal = n;
                    vertices[indices[i + 2]].mNormal = (n);
                }
            }
            else
            {
                if (mMustWeldUnweldFirst)
                {
                    new WeldVerticesModifier().setInputTriangleBuffer(mInputTriangleBuffer).modify();
                }
                std_vector <int> indices = mInputTriangleBuffer.getIndices();
                std_vector <TriangleBuffer.Vertex> vertices   = mInputTriangleBuffer.getVertices();
                std_vector <std_vector <Vector3> > tmpNormals = new std_vector <std_vector <Vector3> >();
                tmpNormals.resize(vertices.size());
                for (int i = 0; i < indices.size(); i += 3)
                {
                    Vector3 v1 = vertices[indices[i]].mPosition;
                    Vector3 v2 = vertices[indices[i + 1]].mPosition;
                    Vector3 v3 = vertices[indices[i + 2]].mPosition;
                    Vector3 n  = (v2 - v1).CrossProduct(v3 - v1);
                    tmpNormals[indices[i]].push_back(n);
                    tmpNormals[indices[i + 1]].push_back(n);
                    tmpNormals[indices[i + 2]].push_back(n);
                }
                for (int i = 0; i < vertices.size(); i++)
                {
                    Vector3 n = (Vector3.ZERO);
                    for (int j = 0; j < tmpNormals[i].size(); j++)
                    {
                        n += tmpNormals[i][j];
                    }
                    vertices[i].mNormal = n.NormalisedCopy;
                }
            }
        }
        //--------------------------------------------------------------
        public void modify() {
            if (mInputTriangleBuffer == null)
                OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Input triangle buffer must be set", "__FUNCTION__");
            ;

            if (mComputeMode == NormalComputeMode.NCM_TRIANGLE) {
                if (mMustWeldUnweldFirst)
                    new UnweldVerticesModifier().setInputTriangleBuffer(mInputTriangleBuffer).modify();

                std_vector<int> indices = mInputTriangleBuffer.getIndices();
                std_vector<TriangleBuffer.Vertex> vertices = mInputTriangleBuffer.getVertices();
                for (int i = 0; i < indices.size(); i += 3) {
                    Vector3 v1 = vertices[indices[i]].mPosition;
                    Vector3 v2 = vertices[indices[i + 1]].mPosition;
                    Vector3 v3 = vertices[indices[i + 2]].mPosition;
                    Vector3 n = (v2 - v1).CrossProduct(v3 - v1).NormalisedCopy;
                    //
                    //ORIGINAL LINE: vertices[indices[i]].mNormal = n;
                    vertices[indices[i]].mNormal = (n);
                    //
                    //ORIGINAL LINE: vertices[indices[i+1]].mNormal = n;
                    vertices[indices[i + 1]].mNormal = (n);
                    //
                    //ORIGINAL LINE: vertices[indices[i+2]].mNormal = n;
                    vertices[indices[i + 2]].mNormal = (n);
                }
            }
            else {
                if (mMustWeldUnweldFirst)
                    new WeldVerticesModifier().setInputTriangleBuffer(mInputTriangleBuffer).modify();
                std_vector<int> indices = mInputTriangleBuffer.getIndices();
                std_vector<TriangleBuffer.Vertex> vertices = mInputTriangleBuffer.getVertices();
                std_vector<std_vector<Vector3>> tmpNormals = new std_vector<std_vector<Vector3>>();
                tmpNormals.resize(vertices.size());
                for (int i = 0; i < indices.size(); i += 3) {
                    Vector3 v1 = vertices[indices[i]].mPosition;
                    Vector3 v2 = vertices[indices[i + 1]].mPosition;
                    Vector3 v3 = vertices[indices[i + 2]].mPosition;
                    Vector3 n = (v2 - v1).CrossProduct(v3 - v1);
                    tmpNormals[indices[i]].push_back(n);
                    tmpNormals[indices[i + 1]].push_back(n);
                    tmpNormals[indices[i + 2]].push_back(n);
                }
                for (int i = 0; i < vertices.size(); i++) {
                    Vector3 n = (Vector3.ZERO);
                    for (int j = 0; j < tmpNormals[i].size(); j++)
                        n += tmpNormals[i][j];
                    vertices[i].mNormal = n.NormalisedCopy;
                }
            }
        }