Java 类android.graphics.Camera 实例源码

项目:Rotate3d    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;
    final Matrix matrix = t.getMatrix();
    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:SciChart.Android.Examples    文件:FlipAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
    final Matrix matrix = t.getMatrix();

    final Camera camera = mCamera;
    camera.save();

    camera.rotateY(degrees);
    camera.getMatrix(matrix);

    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:SphereLayout    文件:SphereLayout.java   
public SphereLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SphereLayout);
    mRadius = a.getDimensionPixelSize(R.styleable.SphereLayout_radius, 0);//球体半径
    mOrientation = a.getInt(R.styleable.SphereLayout_snapOrientation, HORIZONTAL);//标记位于背面的视图是以Y轴水平翻转到达正面 或是以X轴竖直翻转可到达正面
    mHideBack = a.getBoolean(R.styleable.SphereLayout_hideBack, false);//是否隐藏处在背面的布局
    a.recycle();
    mCenter = new Point();
    mCamera = new Camera();
    mDependencyOffset = new int[2];
    //mCamera.setLocation(0, 0, -20);
    mMatrix = new Matrix();
    mPositiveChildren = new ArrayList<>();//depth为正的childview集合
    mNegativeChildren = new ArrayList<>();//depth为负的childview集合
    mDensity = getResources().getDisplayMetrics().density;
}
项目:FragmentRigger    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;
  final Matrix matrix = t.getMatrix();
  camera.save();
  if (mReverse) {
    camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
  } else {
    camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
  }
  camera.rotateY(degrees);
  camera.getMatrix(matrix);
  camera.restore();

  matrix.preTranslate(-centerX, -centerY);
  matrix.postTranslate(centerX, centerY);
}
项目:FragmentRigger    文件:Rotate3d.java   
@Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {
    Camera camera = new Camera();
    camera.save();

    // 设置camera动作为绕Y轴旋转
    // 总共旋转180度,因此计算在每个补间时间点interpolatedTime的角度即为两着相乘
//    camera.rotateX(deg * interpolatedTime);
    camera.rotateY(180 * interpolatedTime);
//    camera.rotateZ(180 * interpolatedTime);
//
    // 根据camera动作产生一个matrix,赋给Transformation的matrix,以用来设置动画效果
    Matrix matrix = t.getMatrix();
    camera.getMatrix(matrix);

    camera.restore();
    //经过以下平移,才能以view的中心点进行翻转
    matrix.preTranslate(-view.getWidth() / 2, -view.getHeight() / 2);
    matrix.postTranslate(view.getWidth() / 2, view.getHeight() / 2);
  }
项目:FreeStreams-TVLauncher    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:FancyView    文件:RotationDrawStrategy.java   
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param fraction 完成时间百分比
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconOne(Canvas canvas, float fraction, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    canvas.save();
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() * fraction * 0.5f, y + icon.getHeight() * fraction * 0.5f);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(-180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
项目:BookLoadingView    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:RoateIndicatorViewDemo    文件:RotateIndicatorView.java   
public RotateIndicatorView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RotateIndicatorView, defStyleAttr, 0);
    diameter = array.getDimensionPixelSize(R.styleable.RotateIndicatorView_diameter, 50);
    textColor = array.getColor(R.styleable.RotateIndicatorView_textColor, Color.RED);
    textBackgroundColor = array.getColor(R.styleable.RotateIndicatorView_textBackgroundColor, Color.WHITE);
    maxPage = array.getInt(R.styleable.RotateIndicatorView_maxPage, 1);

    rightBitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.indicator2);
    Matrix matrix = new Matrix();
    float scale = 1.0f * diameter / rightBitmap.getHeight();
    matrix.postScale(scale, scale);
    rightBitmap = Bitmap.createBitmap(rightBitmap, 0, 0, rightBitmap.getWidth(), rightBitmap.getHeight(), matrix, true);

    mPaint = new Paint();
    camera = new Camera();
}
项目:IMKBaseFrameworkLibrary    文件:Reflect3DImage.java   
/**
 * 3D效果
 * 
 * @param srcBitmap
 * @return
 */
public static Bitmap skewImage(Bitmap srcBitmap, int picWidth, int picHeight, int height) {
    srcBitmap = Bitmap.createScaledBitmap(srcBitmap, picWidth, picHeight, true);
    Bitmap bitmap = createReflectedImage(srcBitmap, height);
    Camera camera = new Camera();
    camera.save();
    Matrix matrix = new Matrix();
    camera.rotateY(15);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-bitmap.getWidth() >> 1, -bitmap.getHeight() >> 1);
    Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    Bitmap canvasBitmap = Bitmap.createBitmap(newBitmap.getWidth(), newBitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(canvasBitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    // paint.setStyle(Style.FILL);
    canvas.drawBitmap(newBitmap, 0, 0, paint);
    newBitmap.recycle();
    // bitmap.recycle();
    return canvasBitmap;
}
项目:Jreader    文件:Rotate3DAnimation.java   
/**
 * 执行顺序 matrix.preTranslate() -->  camera.rotateY(degrees) -->   matrix.postTranslate() -->   matrix.postScale()
 * @param interpolatedTime
 * @param t
 */
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    float degrees = mReverse ? mToDegrees + (mFromDegrees - mToDegrees) * interpolatedTime : mFromDegrees + (mToDegrees - mFromDegrees) * interpolatedTime;
    final Matrix matrix = t.getMatrix();

    final Camera camera = mCamera;

    camera.save();

    camera.rotateY(degrees);

    camera.getMatrix(matrix);
    camera.restore();

          //  matrix.preTranslate(-mPivotXValue, 0);      //在进行rotateY之前需要移动物体,让物体左边与Y轴对齐
          //  matrix.postTranslate(mPivotXValue, 0);      //还原物体位置

    if (mReverse) {
        matrix.postScale(1 + (scaleTimes - 1) * (1.0f - interpolatedTime), 1 + (scaleTimes - 1) * (1.0f - interpolatedTime), mPivotX - mPivotXValue , mPivotY - mPivotYValue);
    } else {
       // matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX, mPivotY);
        matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX - mPivotXValue , mPivotY - mPivotYValue );
    }
}
项目:NewXmPluginSDK    文件:AutoTextView.java   
@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 Camera camera = mCamera;
    final int derection = mTurnUp ? 1 : -1;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mTurnIn) {
        camera.translate(0.0f, derection * mCenterY * (interpolatedTime - 1.0f), 0.0f);
    } else {
        camera.translate(0.0f, derection * mCenterY * (interpolatedTime), 0.0f);
    }
    camera.rotateX(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:AndroidTVWidget    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:eshow-android    文件:AbRotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:Android-tv-widget    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:asstudydemo    文件:Rotate3dAnim.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    float tmpFromDegrees = fromDegrees;
    float degrees = tmpFromDegrees + ((toDegrees - tmpFromDegrees) * interpolatedTime);
    float tmpCenterX = centerX;
    float tmpCenterY = centerY;
    Camera tmpCamera = camera;
    Matrix matrix = t.getMatrix();
    LogUtils.d("interpolatedTime: " + interpolatedTime);
    tmpCamera.save();
    if (reverse) {
        tmpCamera.translate(0f, 0f, depthZ * interpolatedTime);
    } else {
        tmpCamera.translate(0f, 0f, depthZ * (1.0f - interpolatedTime));
    }
    tmpCamera.rotateY(degrees);
    tmpCamera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-tmpCenterX, -tmpCenterY);
    matrix.postTranslate(tmpCenterX, tmpCenterY);
    super.applyTransformation(interpolatedTime, t);
}
项目:cardentry    文件:RotateAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.setLocation(0, 0, 60);
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:CouldBooks    文件:Rotate3DAnimation.java   
/**
 * 执行顺序 matrix.preTranslate() -->  camera.rotateY(degrees) -->   matrix.postTranslate() -->   matrix.postScale()
 * @param interpolatedTime
 * @param t
 */
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    float degrees = mReverse ? mToDegrees + (mFromDegrees - mToDegrees) * interpolatedTime : mFromDegrees + (mToDegrees - mFromDegrees) * interpolatedTime;
    final Matrix matrix = t.getMatrix();

    final Camera camera = mCamera;

    camera.save();

    camera.rotateY(degrees);

    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-mPivotXValue, 0);      //在进行rotateY之前需要移动物体,让物体左边与Y轴对齐
    matrix.postTranslate(mPivotXValue, 0);      //还原物体位置

    if (mReverse) {
        matrix.postScale(1 + (scaleTimes - 1) * (1.0f - interpolatedTime), 1 + (scaleTimes - 1) * (1.0f - interpolatedTime), mPivotX, mPivotY);
    } else {
        matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX, mPivotY);
    }
}
项目:mc_backup    文件:Rotate3DAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final Camera camera = mCamera;
    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateX(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-mCenterX * mWidth, -mCenterY * mHeight);
    matrix.postTranslate(mCenterX * mWidth, mCenterY * mHeight);
}
项目:ApkLauncher    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:ApiDemos    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:android-tv-launcher    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:androidsummary    文件:AbRotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:snakk-ads-android-sdk    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:androidsoft-kids-memory    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:WeatherX    文件:RotationAnim.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = this.fromDegrees;
    float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
    final float centerX = xCenter;
    final float centerY = yCenter;
    final Camera camera = this.camera;
    final Matrix matrix = t.getMatrix(); //保存一次camera初始状态,用于restore()
    camera.save();
    if (reverse) {
        camera.translate(0.0f, 0.0f, zDepth * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, zDepth * (1.0f - interpolatedTime));
    }
    //围绕Y轴旋转degrees度
    camera.rotateY(degrees);
    //行camera中取出矩阵,赋值给matrix
    camera.getMatrix(matrix);
    //camera恢复到初始状态,继续用于下次的计算
    camera.restore();
    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:snakk-ads-android-sample-app    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:tournama    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:appcan-android    文件:EBrowserAnimation.java   
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = m_fromDegree;
    float degrees = fromDegrees + ((m_toDegree - fromDegrees) * interpolatedTime);
    final float centerX = m_centerX;
    final float centerY = m_centerY;
    final Camera camera = m_camera;
    final Matrix matrix = t.getMatrix();
    camera.save();
    if (m_reverse) {
        camera.translate(0.0f, 0.0f, m_depthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, m_depthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:appcan-android    文件:YAxisAnimation.java   
protected final void applyTransformation(float paramFloat, Transformation transformation) {
    float f1 = 0.0F - 360.0F * paramFloat;
    float f2 = mWidth;
    float f3 = mHeight;
    final Camera camera = mCamera;
    Matrix matrix = transformation.getMatrix();
    camera.save();
    if ((0x1 & mRotationFlags) == 1)
        camera.rotateX(f1);
    if ((0x2 & mRotationFlags) == 2)
        camera.rotateY(f1);
    if ((0x4 & mRotationFlags) == 4)
        camera.rotateZ(f1);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-f2, -f3);
    matrix.postTranslate(f2, f3);
}
项目:android-flip3d    文件:Flip3DAnimation.java   
@Override
protected void applyTransformation(final float interpolatedTime, final Transformation t) {
    final float fromDegrees = mFromDegrees;
    final float degrees = fromDegrees + (mToDegrees - fromDegrees) * interpolatedTime;

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();

    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:spoken    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:felix-on-android    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:MEng    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:fruit.launcher    文件:Workspace.java   
/**
 * Used to inflate the Workspace from XML.
 * 
 * @param context
 *            The application's context.
 * @param attrs
 *            The attribtues set containing the Workspace's customization
 *            values.
 * @param defStyle
 *            Unused.
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mWallpaperManager = WallpaperManager.getInstance(context);

    // TypedArray a = context.obtainStyledAttributes(attrs,
    // R.styleable.Workspace, defStyle, 0);
    // mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    // a.recycle();
    // Read default screen value from shared preference
    mDefaultScreen = SettingUtils.mHomeScreenIndex;
    //final int put_screen = LauncherProvider.get_put_screen();
    //mScreenCount = SettingUtils.mScreenCount>put_screen?SettingUtils.mScreenCount:put_screen;
    mScreenCount = SettingUtils.mScreenCount;
    mInflater = LayoutInflater.from(context);

    mTransitionType = Effects.EFFECT_TYPE_INIT;
    EffectsFactory.getAllEffects();
    mCamera = new Camera();

    setHapticFeedbackEnabled(false);
    initWorkspace();
}
项目:codeexamples-android    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:deview-2013-samples    文件:Rotate3dAnimation.java   
@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 Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
项目:GitHub    文件:Rotate3dAnimation.java   
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    mCamera = new Camera();
    mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
    mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
}
项目:Flashcards-Demo    文件:FlipAnimation.java   
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    centerX = width / 2;
    centerY = height / 2;
    camera = new Camera();
}
项目:Android-Code-Demos    文件:Rotate3DAnimation.java   
@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 Camera camera = mCamera;
    final Matrix matrix = t.getMatrix();
    camera.save();

    // 调节深度
    if (mReverse)
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    else
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));

    // 绕y轴旋转
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    // 修正失真,主要修改 MPERSP_0 和 MPERSP_1
    float[] mValues = new float[9];
    matrix.getValues(mValues);              //获取数值
    mValues[6] = mValues[6] / scale;        //数值修正
    mValues[7] = mValues[7] / scale;        //数值修正
    matrix.setValues(mValues);              //重新赋值

    // 调节中心点
    matrix.preTranslate(-centerX, -centerY);
    matrix.postScale(centerX, centerY);

}