The Light component
A light source in our scene is a type of Component
with a color and a float array that is used to represent the calculated location in eye space. Let's create the Light
class now.
Create a new Light
Java class in the renderbox/components
folder. Define it as follows:
public class Light extends Component { private static final String TAG = "RenderBox.Light"; public final float[] lightPosInEyeSpace = new float[4]; public float[] color = new float[]{1,1,1,1}; public void onDraw(float[] view){ Matrix.multiplyMV(lightPosInEyeSpace, 0, view, 0, transform.getPosition().toFloat4(), 0); } }
Our default light is white (color 1,1,1).
The onDraw
method calculates the actual light position in eye space based on the position of Transform
multiplied ...
Get Cardboard VR Projects for Android now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.