Viewing a regular photo
Now that we got that done, let's prepare our app to also be able to view regular flat photos. We'll do this by rendering them onto a plane. So first we need to define a Plane
component.
Defining the Plane component and allocating buffers
The
Plane
component rightfully belongs to the RenderBox
library, but for the time being, we'll add it directly to the app.
Create a new Java class file in the RenderBoxExt/components/
folder, and name it Plane
. Define it as extends RenderObject
, as follows:
public class Plane extends RenderObject { }
As with other geometry in the RenderBox
library, we'll define the plane with triangles. Simply two adjacent triangles are required, a total of six indices. The following data arrays define our default plane's 3D coordinates, UV texture coordinates, vertex colors (middle gray), normal vectors, and corresponding indices. Add the following code at the top of the class:
public static final float[] COORDS = new float[] { -1.0f,...