Hi,
I wanted to do a small experiment, to use Android View rotation capabilities to do some of the work for me for a very simple 3D app, simulating perspective (there are some posts and snippets of view rotation here in the forum)
Android views can rotate on different axes and pivot points. So I thought that I could use them to emulate the walls of a box viewed from the front. I thought that for a square box, 45 degrees on each side would produce a nice perspective.. In my device, the good value (trial and error) has been 47º, I suppose that it is because I haven't taken into account camera position and a 'real' equation set. But it works ok.
(2nd edit) Added an example with 3 balls and a simple collision detector
The code is made just with a timer and a direction vector. One canvas for each 'side' draws the ball or its shadow, as if we were in front of each wall while it moves. Perspective does the rest. I think it can be modified with more than one ball and collision detection
A bit of math background will be needed to understand the code. Also, I have only used normal views, as speed was not the goal in this demo.
Hope you like it
I wanted to do a small experiment, to use Android View rotation capabilities to do some of the work for me for a very simple 3D app, simulating perspective (there are some posts and snippets of view rotation here in the forum)
Android views can rotate on different axes and pivot points. So I thought that I could use them to emulate the walls of a box viewed from the front. I thought that for a square box, 45 degrees on each side would produce a nice perspective.. In my device, the good value (trial and error) has been 47º, I suppose that it is because I haven't taken into account camera position and a 'real' equation set. But it works ok.
(2nd edit) Added an example with 3 balls and a simple collision detector
The code is made just with a timer and a direction vector. One canvas for each 'side' draws the ball or its shadow, as if we were in front of each wall while it moves. Perspective does the rest. I think it can be modified with more than one ball and collision detection
A bit of math background will be needed to understand the code. Also, I have only used normal views, as speed was not the goal in this demo.
Hope you like it
Attachments
Last edited: