Android 3D rotation effect implementation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.