1. cell坐标系(场景的边界值)
(rect.xStart, rect.yStart) 0 ,-80
(rect.xEnd, rect.yEnd) 250 ,210
cell坐标系一个是个瓷砖组成,通过瓷砖中心点,经过缩放得到屏幕坐标(坐标轴垂直屏幕的)
static Core::IPoint getTileCenterPosition(int x, int y) { return Core::IPoint(70 * (x + y + 1)/2, 35 * (x - y) / 2); }
scrollInGarden.xStart = CoordinateSystem().getTileCenterPosition(rect.xStart, rect.yStart).x - 300.f; //подобрано эмпирически
scrollInGarden.xEnd = CoordinateSystem().getTileCenterPosition(rect.xEnd, rect.yEnd).x ;
scrollInGarden.yStart = CoordinateSystem().getTileCenterPosition(rect.xStart, rect.yEnd).y - 150.f; //подобрано эмпирически
scrollInGarden.yEnd = CoordinateSystem().getTileCenterPosition(rect.xEnd, rect.yStart).y ;
crollInGarden.xStart, scrollInGarden.yStart, scrollInGarden.xEnd, scrollInGarden.yEnd
left,bottom,right,top
-3065,-3825,16135,5775
cell(x,y) | screen(x,y) | bound(x,y)(网格中使用) |
(0 ,-80) | (-2800,1400) | (0,68) |
(250 ,210) | (16100,700) | (255,59) |
(0,210) | (7350,-3675) | (137,0) |
(250,-80) | (5950,5775) | (118,128) |
2. 屏幕坐标系(坐标轴平行屏幕的)
红色坐标
屏幕坐标系经过ScreenToIso转换成世界坐标系
void screenToIso(float& x, float& y, float &z){
float screenX = x;
float screenY = y - z;
isoX = -0.5f * screenX + -1.0f * screenY;
isoY = 0.5f * screenX + -1.0f * screenY;
}
2. 世界坐标系(实现z坐标)
两个蓝色坐标轴和一个红色坐标轴
世界坐标系经过转换可以变为屏幕坐标系
void isoToScreen(float& x, float& y, float &z){
float isoX = x;
float isoY = y;
screenX = -1.0f * isoX + 1.0f * isoY;
screenY = -0.5f * isoX + -0.5f * isoY + z;
}