O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spreading Out the Particles

The first thing we’ll do is spread out our particles, and we’ll also vary the speed of each particle to give each particle fountain some more variety. Let’s go back to ParticleShooter and add the following member variables to the class:

Particles/src/com/particles/android/objects/ParticleShooter.java
 
private​ ​final​ ​float​ angleVariance;
 
private​ ​final​ ​float​ speedVariance;
 
 
private​ ​final​ ​Random​ random = ​new​ ​Random​();
 
 
private​ ​float​​[]​ rotationMatrix = ​new​ ​float​[16];
 
private​ ​float​​[]​ directionVector = ​new​ ​float​[4];
 
private​ ​float​​[]​ resultVector = ​new​ ​float​[4];

Each shooter will have an angle variance that will control the spread of particles and a speed variance to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required