public IndexedModel toIndexedModel(){
        IndexedModel result = new IndexedModel();
        IndexedModel normalModel = new IndexedModel();
        HashMap<ObjIndex, Integer> resultIndexMap = new HashMap<ObjIndex, Integer>();
        HashMap<Integer, Integer> normalIndexMap = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> indexMap = new HashMap<Integer, Integer>();


        for(int i = 0 ; i < indices.size() ; i++){
            ObjIndex currentIndex = indices.get(i);

            Vector3f currentPosition = positions.get(currentIndex.vertexIndex);
            Vector2f currentTexCoord;
            Vector3f currentNormal;

            if(hasTexCoords){
                currentTexCoord = texCoords.get(currentIndex.texCoordIndex);
            }else{
                currentTexCoord = new Vector2f(0,0);
            }

            if(hasNormals){
                currentNormal = normals.get(currentIndex.normalIndex);
            }else{
                currentNormal = new Vector3f(0,0,0);
            }

            Integer modelVertexIndex = resultIndexMap.get(currentIndex);

            if(modelVertexIndex == null){
                modelVertexIndex = result.getPositions().size();
                resultIndexMap.put(currentIndex, result.getPositions().size());
                result.getPositions().add(currentPosition);
                result.getTexCoords().add(currentTexCoord);
                if(hasNormals){
                    result.getNormals().add(currentNormal);
                }

            }

            Integer normalmodelIndex = normalIndexMap.get(currentIndex.vertexIndex);

            if(normalmodelIndex == null){
                normalmodelIndex = normalModel.getPositions().size();
                normalIndexMap.put(currentIndex.vertexIndex, normalModel.getPositions().size());
                normalModel.getPositions().add(currentPosition);
                normalModel.getTexCoords().add(currentTexCoord);
                normalModel.getNormals().add(currentNormal);
            }

            result.getIndices().add(modelVertexIndex);
            normalModel.getIndices().add(normalmodelIndex);
            indexMap.put(modelVertexIndex, normalmodelIndex);
        }

        if(!hasNormals){
            normalModel.calcNormals();
            for(int i = 0 ; i < result.getPositions().size() ; i++){
                result.getNormals().add(normalModel.getNormals().get(indexMap.get(i)));
            }

        }

        return result;
    }