0

I've came across this code which works very well when applied to a view:

view.setPivotX(view.getWidth());
view.setPivotY(view.getHeight() * 0.5f);
view.setRotationY(90f * progress);

I've tried many configuration to make it work just with Matrix and camera, but this is not my strong suit... is it even possible?

Is the behavior so fundamentally different between the View's rotation and the Matrix rotation?

What I'm trying to accomplish is Animation Transformation between views, but I want to achieve this generically without the view!

Specifically a Cube rotation like this.

All other examples I've seen does not result in the same effect!!

The difference is I want to make it work in an Animation object, Like so:

public class CubeRotate
        extends Animation {

    public CubeRotate() {
    }

    @Override
    public void initialize(int width, int height, int parentWidth, int parentHeight) {
        super.initialize(width, height, parentWidth, parentHeight);
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        final Matrix matrix = t.getMatrix();

        ...
        What should be here to get the same result?
        ...

        Log.d("Matrix", "\n" + matrix);
    }
}
Community
  • 1
  • 1
TacB0sS
  • 10,106
  • 12
  • 75
  • 118

1 Answers1

1
public static class CubeRotate extends Animation {

    private Camera mCamera;

    @Override
    public void initialize(int width, int height, int parentWidth, int parentHeight) {
        super.initialize(width, height, parentWidth, parentHeight);
        mCamera.setLocation(width, height * .5F, 0);
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {

        mCamera.rotateY(90f * interpolatedTime);
        mCamera.getMatrix(t.getMatrix());
    }
}
kris larson
  • 30,387
  • 5
  • 62
  • 74
  • Here is the code I'm starting with, don't have time right now to test it, but I wanted to give you the basic idea. I will set up test project later today. Cheers – kris larson Jul 25 '15 at 13:37