A simple box scene

Let's rock this riddim! Make a scene with just a cube and, of course, a camera (which has been set up automatically by RenderBox). Set up the MainActivity class using the IRenderBox interface's setup callback.

In setup of MainActivity, we create a Transform for the cube and position it so that it's set back and slightly offset in space:

    Transform cube;

        @Override
    public void setup() {
        cube = new Transform();
        cube.addComponent(new Cube());
        cube.setLocalPosition(2.0f, -2.f, -5.0f);
    }

In Android Studio, click on Run. The program should compile, build, and install onto your connected Android phone. If you receive any compile errors, fix them now! As mentioned earlier, with the Matrix class, make sure that you are importing the right Camera type. There is also a Camera class within the SDK, which represents the phone's physical camera.

You will see something like this on your device display. (Remember to start the app while the device is facing you, or you might need to look behind you to find the cube!)

A simple box scene

I don't know about you, but I'm excited! Now, let's add some light and shading.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset