3d animation / Camera transformation and modern devices

£可爱£侵袭症+ 提交于 2019-12-11 10:42:33

问题


In my app I have 3d transformations by means android.graphics.Camera. It seemed to work fine until I tried Nexus.

I installed the app on Nexus 7 (4.2.1) and Galaxy Nexus (4.1.2), both of them don't perform Camera transformation at all. I have two different views with Camera and both show standart animation and doesn't apply Camera transformations.

Who can explain such a behaviour?

UPD: camera code

transformation.clear();     
transformation.setTransformationType(Transformation.TYPE_MATRIX);   
mCamera.save();     
final Matrix matrix = transformation.getMatrix();         
mCamera.translate(x,y,z);  
mCamera.getMatrix(matrix);  
matrix.preTranslate(-centerX, -centerY);        
matrix.postTranslate(centerX, centerY);         
mCamera.restore();

UPD2: the same with Galaxy S3 (4.2), but not with S2 (4.0.4)


回答1:


Just add to the end of getChildStaticTransformation

if (android.os.Build.VERSION.SDK_INT >= 16 /*JellyBean*/) child.invalidate();



回答2:


Solution provided by Mikhail works for me at the end of getChildStaticTransformation.

The only problem is the getChildStaticTransformation method will be always called.

My solution is to put the code just after updated x,y,z value for each item.

// items is a ArrayList of ControlItem for example
// x,y,z are custom property of ControlItem class

items.get(0).x = 250;
items.get(0).y = 100;
items.get(0).z = 0;

for ( ControlItem item : items )
{
    // Item must be invalidate with JellyBean and superior
    if ( android.os.Build.VERSION.SDK_INT >= 16 ) item.invalidate();
}

// getChildStaticTransformation() will be called after, transformation will be applied


来源:https://stackoverflow.com/questions/13800401/3d-animation-camera-transformation-and-modern-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!