Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3D rotation - perspective

public class MainActivity extends Activity {

LinearLayout rotator;

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    rotator = (LinearLayout) findViewById(R.id.rotator);

    ObjectAnimator rotation = ObjectAnimator.ofFloat(rotator, "rotationY", 0, 360);
    rotation.setDuration(3000);
    rotation.start();

}
}

I've got above code, which is rotating View around Y axis. Problem is, that the perspective seems to be too "strong" - the edge of view that is in foreground becomes too big and the edge in background becomes too small. Is there any possibility to "lower down" the perspecitve factor?

like image 207
Incredible Avatar asked Oct 22 '14 16:10

Incredible


People also ask

How do you do Perspective left 3D rotation?

How? Click the picture that you want to apply the effect to, and then click the Format Picture tab. Under Picture Styles, click Effects, point to 3-D Rotation, and then click the effect that you want, such as Isometric Left Down.

Where is 3D rotation in PowerPoint?

On the Animations tab of the ribbon, select one of the 3D animation effects. Select the animation effect you want. On the ribbon, select Effect Options to open the menu. You can choose properties related to the Direction, Intensity, and Rotation Axis of movement.

What is use of 3D rotation effect?

That's what 3D rotation does–it shows you an object from an angle.

How do you add Perspective relaxed moderately 3D rotation effect?

Select the text box and choose FORMAT → WordArt Styles → Text Effects → 3-D Rotation → Perspective Relaxed Moderately.


1 Answers

int distance = 1900;
float scale = getResources().getDisplayMetrics().density;
rotator.setCameraDistance(distance * scale);

So this is the solution for all screen densities.

like image 142
Incredible Avatar answered Sep 28 '22 10:09

Incredible