When it comes to the first step, the most likely response is to use OpenGL ES .... However, to achieve such a small function, to use this thing, inexplicable fear Ah!!!! So far I have not figured out how to play this ...
Well, fortunately, there's a camera class that can help us, and it's said that the underlying implementation is also using OpenGL ES
Note: The Android.graphics.Camera is used
Words not much to say, directly on the code:
Public class_3danimationextendsAnimation {Private floatmfromdegrees; Private floatmtodegrees; Private floatMcenterx; Private floatMcentery; PrivateCamera Mcamera; Public_3danimation (floatFromdegress,floattodegress) { This. mfromdegrees=fromdegress; This. mtodegrees=todegress; } @Override Public voidInitializeintWidthintHeightintParentwidth,intparentheight) { Super. Initialize (width, height, parentwidth, parentheight); This. MCENTERX=WIDTH/2; This. MCENTERY=HEIGHT/2; Mcamera=NewCamera (); } @Overrideprotected voidApplytransformation (floatInterpolatedtime, Transformation t) { Super. Applytransformation (Interpolatedtime, T); Final floatFromdegrees =mfromdegrees; floatdegrees = fromdegrees + (mtodegrees-mfromdegrees) *Interpolatedtime; FinalMatrix Matrix =T.getmatrix (); //interpolatedtime 0~1 ChangeMcamera.save (); Mcamera.rotatey (degrees); Mcamera.getmatrix (matrix); Mcamera.restore (); Matrix.pretranslate (-mcenterx,-mcentery);//camera located (0,0), mobile picture, camera located in Picture centermatrix.posttranslate (Mcenterx, mcentery); }}
Android 3D rotation effect implementation