for(int i = 0; i < m_indices.size(); i++)
{
OBJIndex currentIndex = m_indices.get(i);
Vector3f currentPosition = m_positions.get(currentIndex.GetVertexIndex());
Vector2f currentTexCoord;
Vector3f currentNormal;
if(m_hasTexCoords)
currentTexCoord = m_texCoords.get(currentIndex.GetTexCoordIndex());
else
currentTexCoord = new Vector2f(0,0);
if(m_hasNormals)
currentNormal = m_normals.get(currentIndex.GetNormalIndex());
else
currentNormal = new Vector3f(0,0,0);
Integer modelVertexIndex = resultIndexMap.get(currentIndex);
if(modelVertexIndex == null)
{
modelVertexIndex = result.GetPositions().size();
resultIndexMap.put(currentIndex, modelVertexIndex);
result.GetPositions().add(currentPosition);
result.GetTexCoords().add(currentTexCoord);
if(m_hasNormals)
result.GetNormals().add(currentNormal);
}
Integer normalModelIndex = normalIndexMap.get(currentIndex.GetVertexIndex());
if(normalModelIndex == null)
{
normalModelIndex = normalModel.GetPositions().size();
normalIndexMap.put(currentIndex.GetVertexIndex(), normalModelIndex);
normalModel.GetPositions().add(currentPosition);
normalModel.GetTexCoords().add(currentTexCoord);
normalModel.GetNormals().add(currentNormal);
normalModel.GetTangents().add(new Vector3f(0,0,0));
}
result.GetIndices().add(modelVertexIndex);
normalModel.GetIndices().add(normalModelIndex);
indexMap.put(modelVertexIndex, normalModelIndex);