當前位置:首頁 » 安卓系統 » android3d旋轉

android3d旋轉

發布時間: 2022-08-09 09:17:46

Ⅰ 高分追加:界面很炫的 Android 安卓平台音樂播放器 「3」(名字就是這個3)可以3D立體旋轉唱片封面

貌似3D圖片軟體製作出來的吧

安卓手機3D旋轉立體壁紙哪裡有

這個壁紙好像沒有,這是一個桌面,可以下載一個3D桌面既可。

Ⅲ 求助,怎麼用android實現控制項的3D立體旋轉效果

  • 實現水平滑動,所以可在手勢抬起的時候進行判斷並處理,是滑動顯得流暢,代碼如下:

java">packagecom.example.rotation3dview;
importandroid.content.Context;
importandroid.graphics.Camera;
importandroid.graphics.Canvas;
importandroid.graphics.Matrix;
importandroid.util.AttributeSet;
importandroid.view.MotionEvent;
importandroid.view.VelocityTracker;
importandroid.view.View;
importandroid.view.ViewDebug.HierarchyTraceType;
importandroid.view.ViewGroup;
importandroid.widget.ImageView;
importandroid.widget.Scroller;

{
privateintmCurScreen=1;
//滑動的速度
privatestaticfinalintSNAP_VELOCITY=500;
;
privateintmWidth;
privateScrollermScroller;
privateCameramCamera;
privateMatrixmMatrix;
//旋轉的角度,可以進行修改來觀察效果
privatefloatangle=90;
publicRote3DView(Contextcontext,AttributeSetattrs){
super(context,attrs);
mScroller=newScroller(context);
mCamera=newCamera();
mMatrix=newMatrix();
initScreens();
}

publicvoidinitScreens(){
ViewGroup.LayoutParamsp=newViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
for(inti=0;i<3;i++){
this.addView(newImageView(this.getContext()),i,p);
}
((ImageView)this.getChildAt(0)).setImageResource(R.drawable.page1);
((ImageView)this.getChildAt(1)).setImageResource(R.drawable.page2);
((ImageView)this.getChildAt(2)).setImageResource(R.drawable.page3);
}

@Override
protectedvoidonLayout(booleanchanged,intl,intt,intr,intb){
intchildLeft=0;
finalintchildCount=getChildCount();
for(inti=0;i<childCount;i++){
finalViewchildView=getChildAt(i);
if(childView.getVisibility()!=View.GONE){
finalintchildWidth=childView.getMeasuredWidth();
childView.layout(childLeft,0,childLeft+childWidth,childView.getMeasuredHeight());
childLeft+=childWidth;
}
}
}

@Override
protectedvoidonMeasure(intwidthMeasureSpec,intheightMeasureSpec){
super.onMeasure(widthMeasureSpec,heightMeasureSpec);
finalintwidth=MeasureSpec.getSize(widthMeasureSpec);
finalintwidthMode=MeasureSpec.getMode(widthMeasureSpec);
if(widthMode!=MeasureSpec.EXACTLY){
thrownewIllegalStateException("僅支持精確尺寸");
}
finalintheightMode=MeasureSpec.getMode(heightMeasureSpec);
if(heightMode!=MeasureSpec.EXACTLY){
thrownewIllegalStateException("僅支持精確尺寸");
}
finalintcount=getChildCount();
for(inti=0;i<count;i++){
getChildAt(i).measure(widthMeasureSpec,heightMeasureSpec);
}
scrollTo(mCurScreen*width,0);
}

privatefloatmDownX;
@Override
publicbooleanonTouchEvent(MotionEventevent){
if(mVelocityTracker==null){
mVelocityTracker=VelocityTracker.obtain();
}
//將當前的觸摸事件傳遞給VelocityTracker對象
mVelocityTracker.addMovement(event);
floatx=event.getX();
switch(event.getAction()){
caseMotionEvent.ACTION_DOWN:
if(!mScroller.isFinished()){
mScroller.abortAnimation();
}
mDownX=x;
break;
caseMotionEvent.ACTION_MOVE:
intdisX=(int)(mDownX-x);
mDownX=x;
scrollBy(disX,0);
break;
caseMotionEvent.ACTION_UP:
=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000);
intvelocityX=(int)velocityTracker.getXVelocity();
if(velocityX>SNAP_VELOCITY&&mCurScreen>0){
snapToScreen(mCurScreen-1);
}elseif(velocityX<-SNAP_VELOCITY&&mCurScreen<getChildCount()-1){
snapToScreen(mCurScreen+1);
}else{
snapToDestination();
}
if(mVelocityTracker!=null){
mVelocityTracker.recycle();
mVelocityTracker=null;
}
break;
}
returntrue;
}

@Override
publicvoidcomputeScroll(){
if(mScroller.computeScrollOffset()){
scrollTo(mScroller.getCurrX(),mScroller.getCurrY());
postInvalidate();
}
}

publicvoidsnapToDestination(){
setMWidth();
finalintdestScreen=(getScrollX()+mWidth/2)/mWidth;
snapToScreen(destScreen);
}

publicvoidsnapToScreen(intwhichScreen){
whichScreen=Math.max(0,Math.min(whichScreen,getChildCount()-1));
setMWidth();
intscrollX=getScrollX();
intstartWidth=whichScreen*mWidth;
if(scrollX!=startWidth){
intdelta=0;
intstartX=0;
if(whichScreen>mCurScreen){
setPre();
delta=startWidth-scrollX;
startX=mWidth-startWidth+scrollX;
}elseif(whichScreen<mCurScreen){
setNext();
delta=-scrollX;
startX=scrollX+mWidth;
}else{
startX=scrollX;
delta=startWidth-scrollX;
}
mScroller.startScroll(startX,0,delta,0,Math.abs(delta)*2);
invalidate();
}
}

privatevoidsetNext(){
intcount=this.getChildCount();
Viewview=getChildAt(count-1);
removeViewAt(count-1);
addView(view,0);
}

privatevoidsetPre(){
intcount=this.getChildCount();
Viewview=getChildAt(0);
removeViewAt(0);
addView(view,count-1);
}

privatevoidsetMWidth(){
if(mWidth==0){
mWidth=getWidth();
}
}
}
  • 實現立體效果,添加如下代碼:

/*
*當進行View滑動時,會導致當前的View無效,該函數的作用是對View進行重新繪制調用drawScreen函數
*/
@Override
protectedvoiddispatchDraw(Canvascanvas){
finallongdrawingTime=getDrawingTime();
finalintcount=getChildCount();
for(inti=0;i<count;i++){
drawScreen(canvas,i,drawingTime);
}
}

publicvoiddrawScreen(Canvascanvas,intscreen,longdrawingTime){
//得到當前子View的寬度
finalintwidth=getWidth();
finalintscrollWidth=screen*width;
finalintscrollX=this.getScrollX();
//偏移量不足的時
if(scrollWidth>scrollX+width||scrollWidth+width<scrollX){
return;
}
finalViewchild=getChildAt(screen);
finalintfaceIndex=screen;
finalfloatcurrentDegree=getScrollX()*(angle/getMeasuredWidth());
finalfloatfaceDegree=currentDegree-faceIndex*angle;
if(faceDegree>90||faceDegree<-90){
return;
}
finalfloatcenterX=(scrollWidth<scrollX)?scrollWidth+width
:scrollWidth;
finalfloatcenterY=getHeight()/2;
finalCameracamera=mCamera;
finalMatrixmatrix=mMatrix;
canvas.save();
camera.save();
camera.rotateY(-faceDegree);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX,-centerY);
matrix.postTranslate(centerX,centerY);
canvas.concat(matrix);
drawChild(canvas,child,drawingTime);
canvas.restore();
}

    Ⅳ 安卓手機上什麼軟體能製作3D立體模型,可以使模型旋轉到各個角度看的那種

    sketchup!! http://58.251.57.206/down1?cid=

    Ⅳ android怎樣實現多張圖片的旋轉木馬切換的3d特效

    我們最近在整理一款這樣的包含各種3d效果的SDK,到時發布了給你用

    Ⅵ 畢業設計選了用android做一個3d魔方的游戲,應為android以前沒接觸過的,要從頭開始學的。這個難嗎高手

    只要java好就沒有問題,這是3D魔方android的源碼
    package com.example.android.image3D;

    import android.view.SurfaceView;
    import android.view.SurfaceHolder;
    import android.content.Context;
    import android.util.AttributeSet;
    import java.util.ArrayList;
    import java.util.concurrent.Semaphore;

    import javax.microedition.khronos.egl.EGL10;
    import javax.microedition.khronos.egl.EGL11;
    import javax.microedition.khronos.egl.EGLConfig;
    import javax.microedition.khronos.egl.EGLContext;
    import javax.microedition.khronos.egl.EGLDisplay;
    import javax.microedition.khronos.egl.EGLSurface;
    import javax.microedition.khronos.opengles.GL;
    import javax.microedition.khronos.opengles.GL10;

    public class View3D extends SurfaceView implements SurfaceHolder.Callback {

    private static final Semaphore sEglSemaphore = new Semaphore(1);
    private boolean mSizeChanged = true;

    private SurfaceHolder mHolder;
    private GLThread mGLThread;
    private GLWrapper mGLWrapper;

    public View3D(Context context) {
    super(context);
    init();
    }

    public View3D(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
    }

    private void init() {
    mHolder = getHolder();
    mHolder.addCallback(this);
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
    }

    public SurfaceHolder getSurfaceHolder() {
    return mHolder;
    }

    public void setGLWrapper(GLWrapper glWrapper) {
    mGLWrapper = glWrapper;
    }

    public void setRenderer(Renderer renderer) {
    mGLThread = new GLThread(renderer);
    mGLThread.start();
    }

    public void surfaceCreated(SurfaceHolder holder) {
    mGLThread.surfaceCreated();
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
    mGLThread.surfaceDestroyed();
    }

    public void surfaceChanged(SurfaceHolder holder,
    int format, int w, int h) {
    mGLThread.onWindowResize(w, h);
    }

    public void onPause() {
    mGLThread.onPause();
    }

    public void onResume() {
    mGLThread.onResume();
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    mGLThread.onWindowFocusChanged(hasFocus);
    }

    public void queueEvent(Runnable r) {
    mGLThread.queueEvent(r);
    }

    @Override
    protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    mGLThread.requestExitAndWait();
    }

    public interface GLWrapper {
    GL wrap(GL gl);
    }

    public interface Renderer {

    int[] getConfigSpec();

    void surfaceCreated(GL10 gl);
    void sizeChanged(GL10 gl, int width, int height);
    void drawFrame(GL10 gl);
    }

    private class EglHelper {

    EGL10 mEgl;
    EGLDisplay mEglDisplay;
    EGLSurface mEglSurface;
    EGLConfig mEglConfig;
    EGLContext mEglContext;

    public EglHelper() {

    }

    public void start(int[] configSpec){

    mEgl = (EGL10) EGLContext.getEGL();
    mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    int[] version = new int[2];
    mEgl.eglInitialize(mEglDisplay, version);

    EGLConfig[] configs = new EGLConfig[1];
    int[] num_config = new int[1];
    mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1,
    num_config);
    mEglConfig = configs[0];

    mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
    EGL10.EGL_NO_CONTEXT, null);

    mEglSurface = null;
    }

    public GL createSurface(SurfaceHolder holder) {

    if (mEglSurface != null) {

    mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
    EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
    mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
    }

    mEglSurface = mEgl.eglCreateWindowSurface(mEglDisplay,
    mEglConfig, holder, null);

    mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
    mEglContext);

    GL gl = mEglContext.getGL();
    if (mGLWrapper != null) {
    gl = mGLWrapper.wrap(gl);
    }
    return gl;
    }

    public boolean swap() {
    mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
    return mEgl.eglGetError() != EGL11.EGL_CONTEXT_LOST;
    }

    public void finish() {
    if (mEglSurface != null) {
    mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
    EGL10.EGL_NO_SURFACE,
    EGL10.EGL_NO_CONTEXT);
    mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
    mEglSurface = null;
    }
    if (mEglContext != null) {
    mEgl.eglDestroyContext(mEglDisplay, mEglContext);
    mEglContext = null;
    }
    if (mEglDisplay != null) {
    mEgl.eglTerminate(mEglDisplay);
    mEglDisplay = null;
    }
    }

    }

    class GLThread extends Thread {

    private boolean mDone;
    private boolean mPaused;
    private boolean mHasFocus;
    private boolean mHasSurface;
    private boolean mContextLost;
    private int mWidth;
    private int mHeight;
    private Renderer mRenderer;
    private ArrayList<Runnable>
    mEventQueue = new ArrayList<Runnable>();
    private EglHelper mEglHelper;

    GLThread(Renderer renderer) {
    super();
    mDone = false;
    mWidth = 0;
    mHeight = 0;
    mRenderer = renderer;
    setName("GLThread");
    }

    @Override
    public void run() {

    try {
    try {
    sEglSemaphore.acquire();
    } catch (InterruptedException e) {
    return;
    }
    guardedRun();
    } catch (InterruptedException e) {

    } finally {
    sEglSemaphore.release();
    }
    }

    private void guardedRun() throws InterruptedException {
    mEglHelper = new EglHelper();
    int[] configSpec = mRenderer.getConfigSpec();
    mEglHelper.start(configSpec);

    GL10 gl = null;
    boolean tellRendererSurfaceCreated = true;
    boolean tellRendererSurfaceChanged = true;

    while (!mDone) {

    int w, h;
    boolean changed;
    boolean needStart = false;
    synchronized (this) {
    Runnable r;
    while ((r = getEvent()) != null) {
    r.run();
    }
    if (mPaused) {
    mEglHelper.finish();
    needStart = true;
    }
    if(needToWait()) {
    while (needToWait()) {
    wait();
    }
    }
    if (mDone) {
    break;
    }
    changed = mSizeChanged;
    w = mWidth;
    h = mHeight;
    mSizeChanged = false;
    }
    if (needStart) {
    mEglHelper.start(configSpec);
    tellRendererSurfaceCreated = true;
    changed = true;
    }
    if (changed) {
    gl = (GL10) mEglHelper.createSurface(mHolder);
    tellRendererSurfaceChanged = true;
    }
    if (tellRendererSurfaceCreated) {
    mRenderer.surfaceCreated(gl);
    tellRendererSurfaceCreated = false;
    }
    if (tellRendererSurfaceChanged) {
    mRenderer.sizeChanged(gl, w, h);
    tellRendererSurfaceChanged = false;
    }
    if ((w > 0) && (h > 0)) {

    mRenderer.drawFrame(gl);
    mEglHelper.swap();
    }
    }
    mEglHelper.finish();
    }

    private boolean needToWait() {
    return (mPaused || (! mHasFocus) || (! mHasSurface) || mContextLost)
    && (! mDone);
    }

    public void surfaceCreated() {
    synchronized(this) {
    mHasSurface = true;
    mContextLost = false;
    notify();
    }
    }

    public void surfaceDestroyed() {
    synchronized(this) {
    mHasSurface = false;
    notify();
    }
    }

    public void onPause() {
    synchronized (this) {
    mPaused = true;
    }
    }

    public void onResume() {
    synchronized (this) {
    mPaused = false;
    notify();
    }
    }

    public void onWindowFocusChanged(boolean hasFocus) {
    synchronized (this) {
    mHasFocus = hasFocus;
    if (mHasFocus == true) {
    notify();
    }
    }
    }

    public void onWindowResize(int w, int h) {
    synchronized (this) {
    mWidth = w;
    mHeight = h;
    mSizeChanged = true;
    }
    }

    public void requestExitAndWait() {
    synchronized(this) {
    mDone = true;
    notify();
    }
    try {
    join();
    } catch (InterruptedException ex) {
    Thread.currentThread().interrupt();
    }
    }

    public void queueEvent(Runnable r) {
    synchronized(this) {
    mEventQueue.add(r);
    }
    }

    private Runnable getEvent() {
    synchronized(this) {
    if (mEventQueue.size() > 0) {
    return mEventQueue.remove(0);
    }

    }
    return null;
    }
    }
    }

    Ⅶ 我在使用android Rotate3dAnimation的時候旋轉的時候為什麼會出現豎線

    可能是有緩沖,android動畫是雙緩沖機制,你可以去掉,試試

    Ⅷ 如何在android中加入一個用3dsmax製作的3D模型,並讓他根據手勢旋轉

    寫一個3d模型瀏覽器app,必須支持你的模型格式,加入手勢操作

    熱點內容
    i西安編程 發布:2024-04-25 16:55:35 瀏覽:262
    核磁看壓縮 發布:2024-04-25 16:37:22 瀏覽:431
    訪問不上光貓 發布:2024-04-25 16:13:44 瀏覽:319
    部隊電腦配置有哪些 發布:2024-04-25 16:13:43 瀏覽:970
    霍曼密碼鎖什麼價位 發布:2024-04-25 16:08:01 瀏覽:750
    ftp雙機熱備 發布:2024-04-25 16:03:48 瀏覽:360
    我的世界伺服器限制模組 發布:2024-04-25 15:55:32 瀏覽:888
    平板電腦能連接雲伺服器嗎 發布:2024-04-25 15:54:05 瀏覽:937
    多看怎麼上傳雲 發布:2024-04-25 15:45:31 瀏覽:39
    山東ftp 發布:2024-04-25 15:44:46 瀏覽:261