На iOS портрет:
"Многие другие учебные пособия и примеры кодов не дают правдоподобных трехмерных отражений. Простое вращение по оси Y - это не то, что делается в iOS. "
После почти 30 часов поиска образцов я должен согласиться.
У меня есть фильм, где я мог бы сделать скриншот в середине.
Правая сторона вида имеет:
- движение влево и сокращение до 95%.
Левая сторона вида имеет:
- движение вправо и сокращение до 80%.
В Android Full (начальное состояние):
Середина Android:
Код Android:
// @param interpolatedTime The value of the normalized time (0.0 to 1.0)
// @param t The Transformation object to fill in with the current transforms.
protected void applyTransformation(float interpolatedTime, Transformation t){
float degrees = toDegree*interpolatedTime;
//float rad = (float) (degrees * Math.PI / 180.0f);
Matrix matrix = t.getMatrix();
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);// M' = M * T(dx, dy)
matrix.postTranslate(centerX, centerY); // M' = T(dx, dy) * M
}
Улучшенную версию кода можно найти в большинстве примеров:
// @param interpolatedTime The value of the normalized time (0.0 to 1.0)
// @param t The Transformation object to fill in with the current transforms.
protected void applyTransformation(float interpolatedTime, Transformation t){
float degrees = toDegree*interpolatedTime;
//float rad = (float) (degrees * Math.PI / 180.0f);
Matrix matrix = t.getMatrix();
camera.save();
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);// M' = M * T(dx, dy)
matrix.postTranslate(centerX, centerY); // M' = T(dx, dy) * M
}
Некоторые различия:
- правая сторона вида не двигается как iOS.
Вот оси камеры Android:
Я верю, что трасляция по осям Z не исправит это. Может быть, нужно было как-то сжать.
float dz = (float) (centerX * Math.sin(rad));
camera.translate(0f, 0f, -dz);
Все еще недостаточно. Для многих это сокращение левой стороны.