GVRSceneObject makeParticleMesh ( float [ ] vertices , float [ ] velocities , float [ ] particleTimeStamps ) { mParticleMesh = new GVRMesh ( mGVRContext ) ; //pass the particle positions as vertices, velocities as normals, and //spawning times as texture coordinates. mParticleMesh . setVertices ( vertices ) ; mParticleMesh . setNormals ( velocities ) ; mParticleMesh . setTexCoords ( particleTimeStamps ) ; particleID = new GVRShaderId ( ParticleShader . class ) ; material = new GVRMaterial ( mGVRContext , particleID ) ; material . setVec4 ( "u_color" , mColorMultiplier . x , mColorMultiplier . y , mColorMultiplier . z , mColorMultiplier . w ) ; material . setFloat ( "u_particle_age" , mAge ) ; material . setVec3 ( "u_acceleration" , mAcceleration . x , mAcceleration . y , mAcceleration . z ) ; material . setFloat ( "u_particle_size" , mSize ) ; material . setFloat ( "u_size_change_rate" , mParticleSizeRate ) ; material . setFloat ( "u_fade" , mFadeWithAge ) ; material . setFloat ( "u_noise_factor" , mNoiseFactor ) ; GVRRenderData renderData = new GVRRenderData ( mGVRContext ) ; renderData . setMaterial ( material ) ; renderData . setMesh ( mParticleMesh ) ; material . setMainTexture ( mTexture ) ; GVRSceneObject meshObject = new GVRSceneObject ( mGVRContext ) ; meshObject . attachRenderData ( renderData ) ; meshObject . getRenderData ( ) . setMaterial ( material ) ; // Set the draw mode to GL_POINTS, disable writing to depth buffer, enable depth testing // and set the rendering order to transparent. // Disabling writing to depth buffer ensure that the particles blend correctly // and keeping the depth test on along with rendering them // after the geometry queue makes sure they occlude, and are occluded, correctly. meshObject . getRenderData ( ) . setDrawMode ( GL_POINTS ) ; meshObject . getRenderData ( ) . setDepthTest ( true ) ; meshObject . getRenderData ( ) . setDepthMask ( false ) ; meshObject . getRenderData ( ) . setRenderingOrder ( GVRRenderData . GVRRenderingOrder . TRANSPARENT ) ; return meshObject ; }
Creates and returns a GVRSceneObject with the specified mesh attributes .