Hi there.
I am trying to sort objects on an ISOMetric map to get the correct drawing order. I have tried using the below example which works perfect when all the objects are the same Height and Width but as soon as the Height or Width changes then this method is no longer accurate as seen in the pictures.
I have tried searching the forums and internet for how others have overcome this issue and the answers seem to be use OpenGL etc… I am sure there has to be another way to accomplish this with some math… If anyone knows of a way to correct this issue or can point me in the right direction it would be appreciated.
package com.deadendertainment.chat.objects;
import java.util.Comparator;
import com.deadendertainment.chat.ChatGame;
import com.deadendertainment.chat.characters.Player;
/**
*
* @author Fsig
*
*/
public class GameObjectComparator implements Comparator<GameObject>{
@Override
public int compare(GameObject e1, GameObject e2) {
return (int) ((e1.getX() - e2.getX()) - (e1.getZ() - e2.getZ()) - (e1.getY() - e2.getY()));
}
}
Example picture one:
Example picture two: