번역 및 회전을 사용하여 회전 큐브를 만들려고했습니다. Google 샘플에 제공된 Rotate3dAnimation.java라는 별칭을 사용하고 있습니다. 회전이 잘 작동하고 있으며 스크린에서 더 가깝게 이동하면서 회전하면서 큐브에 깊이있는 환상을 만들기 위해 노력하고있었습니다.
applyTransformation(float interpolatedTime, Transformation t)
이 방법을 수정하고 있었지만 문제는 큐브의 얼굴 (회전하는 동안 숨기는 하나의 얼굴)이 시간의 전반에 대해 더 멀리 움직이는 움직임을 가지고 있으며 두 번째로 다시 닫습니다. 절반.Android 애니메이션 - 적용 변환 - 카메라가 Z 축을 절반으로 변환합니까?
재개 :
Camera.translate(float x, float y, float z)
전반기 줄이고 후반 증가되어야 번역 Z. 여기
내가 코드를 사용하고 있습니다 :
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final String orientation = mOrientation;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
float midTime = getDuration()/2;
if (mReverse) {
camera.translate(0.0f, 0.0f, (interpolatedTime<midTime)?
(mDepthZ * interpolatedTime): (mDepthZ * (1.0f - interpolatedTime)));
} else {
camera.translate(0.0f, 0.0f, (interpolatedTime<midTime)?
(mDepthZ * (1.0f - interpolatedTime)): (mDepthZ * interpolatedTime));
}
if(orientation.equals("horizontal"))
camera.rotateY(degrees);
else
camera.rotateX(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
하지만 그나마 생각이 아주 잘 작동 ... 어떤 sugestions를?
감사합니다.