Java Code Examples for android.opengl.GLES20#glUniformMatrix4fv()
The following examples show how to use
android.opengl.GLES20#glUniformMatrix4fv() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Image70sFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
@Override protected void drawFilter() { GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); }
Example 2
Source File: DrawerImpl.java From android-3D-model-viewer with GNU Lesser General Public License v3.0 | 6 votes |
private void setJointTransforms(AnimatedModel animatedModel) { float[][] jointTransformsArray = animatedModel.getJointTransforms(); // get handle to fragment shader's vColor member // TODO: optimize this (memory allocation) for (int i = 0; i < jointTransformsArray.length; i++) { float[] jointTransform = jointTransformsArray[i]; // Log.v("DrawerImpl","jointTransform: "+ Arrays.toString(jointTransform)); String jointTransformHandleName = cache1.get(i); if (jointTransformHandleName == null) { jointTransformHandleName = "jointTransforms[" + i + "]"; cache1.put(i, jointTransformHandleName); } int jointTransformsHandle = GLES20.glGetUniformLocation(mProgram, jointTransformHandleName); GLUtil.checkGlError("glGetUniformLocation"); GLES20.glUniformMatrix4fv(jointTransformsHandle, 1, false, jointTransform, 0); //handles.add(jointTransformsHandle); } }
Example 3
Source File: MD360Director.java From MD360Player4Android with Apache License 2.0 | 6 votes |
public void shot(MD360Program program, MDPosition modelPosition) { // This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix // (which currently contains model * view). Matrix.multiplyMM(mMVMatrix, 0, mViewMatrix, 0, modelPosition.getMatrix(), 0); // This multiplies the model view matrix by the projection matrix, and stores the result in the MVP matrix // (which now contains model * view * projection). Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVMatrix, 0); // Pass in the model view matrix GLES20.glUniformMatrix4fv(program.getMVMatrixHandle(), 1, false, mMVMatrix, 0); // Pass in the combined matrix. GLES20.glUniformMatrix4fv(program.getMVPMatrixHandle(), 1, false, mMVPMatrix, 0); }
Example 4
Source File: Painting.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void renderBlit() { Shader shader = shaders.get("blit"); if (shader == null) { return; } GLES20.glUseProgram(shader.program); GLES20.glUniformMatrix4fv(shader.getUniform("mvpMatrix"), 1, false, FloatBuffer.wrap(renderProjection)); GLES20.glUniform1i(shader.getUniform("texture"), 0); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTexture()); GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA); GLES20.glVertexAttribPointer(0, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer); GLES20.glEnableVertexAttribArray(0); GLES20.glVertexAttribPointer(1, 2, GLES20.GL_FLOAT, false, 8, textureBuffer); GLES20.glEnableVertexAttribArray(1); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); Utils.HasGLError(); }
Example 5
Source File: Triangle.java From Android-9-Development-Cookbook with MIT License | 6 votes |
public void draw(float[] mvpMatrix) { GLES20.glUseProgram(mProgram); mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition"); GLES20.glEnableVertexAttribArray(mPositionHandle); GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, vertexBuffer); mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor"); mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix"); GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0); GLES20.glUniform4fv(mColorHandle, 1, color, 0); GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, vertexCount); GLES20.glDisableVertexAttribArray(mPositionHandle); }
Example 6
Source File: NegativeFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
@Override protected void drawFilter() { GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); }
Example 7
Source File: GLES20Canvas.java From TurboLauncher with Apache License 2.0 | 6 votes |
private void drawTextureRect(BasicTexture texture, float[] textureMatrix, RectF target) { ShaderParameter[] params = prepareTexture(texture); setPosition(params, OFFSET_FILL_RECT); GLES20.glUniformMatrix4fv(params[INDEX_TEXTURE_MATRIX].handle, 1, false, textureMatrix, 0); checkError(); if (texture.isFlippedVertically()) { save(SAVE_FLAG_MATRIX); translate(0, target.centerY()); scale(1, -1, 1); translate(0, -target.centerY()); } draw(params, GLES20.GL_TRIANGLE_STRIP, COUNT_FILL_VERTEX, target.left, target.top, target.width(), target.height()); if (texture.isFlippedVertically()) { restore(); } mCountTextureRect++; }
Example 8
Source File: SphereReflector.java From Fatigue-Detection with MIT License | 6 votes |
@Override public void onDrawFrame(int textureId) { super.onDrawFrame(textureId); glSphereProgram.use(); sphere.uploadTexCoordinateBuffer(glSphereProgram.getTextureCoordinateHandle()); sphere.uploadVerticesBuffer(glSphereProgram.getPositionHandle()); Matrix.perspectiveM(projectionMatrix, 0, 90, ratio, 1f, 500f); Matrix.multiplyMM(modelViewMatrix, 0, viewMatrix, 0, modelMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, projectionMatrix, 0, modelViewMatrix, 0); GLES20.glUniformMatrix4fv(glSphereProgram.getMVPMatrixHandle(), 1, false, mMVPMatrix, 0); TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSphereProgram.getTextureSamplerHandle(),0); sphere.draw(); }
Example 9
Source File: ZebraFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
@Override protected void drawFilter() { GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); float time = ((float) (System.currentTimeMillis() - START_TIME)) / 1000.0f; GLES20.glUniform1f(uTimeHandle, time); GLES20.glUniform1f(uLevelsHandle, levels); GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); }
Example 10
Source File: DrawImageFilter.java From Fatigue-Detection with MIT License | 6 votes |
@Override public void onDrawFrame(int textureId) { super.onDrawFrame(textureId); GLES20.glEnable(GLES20.GL_BLEND); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); TextureUtils.bindTexture2D(bitmapTexture.getImageTextureId(), GLES20.GL_TEXTURE0,glPassThroughProgram.getTextureSamplerHandle(),0); imagePlane.uploadTexCoordinateBuffer(glPassThroughProgram.getTextureCoordinateHandle()); imagePlane.uploadVerticesBuffer(glPassThroughProgram.getPositionHandle()); MatrixUtils.updateProjectionFit( bitmapTexture.getImageWidth(), bitmapTexture.getImageHeight(), surfaceWidth, surfaceHeight, projectionMatrix); GLES20.glUniformMatrix4fv(glPassThroughProgram.getMVPMatrixHandle(), 1, false, projectionMatrix, 0); imagePlane.draw(); GLES20.glDisable(GLES20.GL_BLEND); }
Example 11
Source File: VideoFBORender.java From EZFilter with MIT License | 5 votes |
@Override protected void bindShaderValues() { super.bindShaderVertices(); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureIn); GLES20.glUniform1i(mTextureHandle, 0); mSurfaceTexture.getTransformMatrix(mMatrix); GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMatrix, 0); }
Example 12
Source File: PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override public void bind(final GLState pGLState, final VertexBufferObjectAttributes pVertexBufferObjectAttributes) { GLES20.glDisableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_COLOR_LOCATION); GLES20.glDisableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_POSITION_LOCATION); GLES20.glEnableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_POSITION_0_LOCATION); GLES20.glEnableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_POSITION_1_LOCATION); super.bind(pGLState, pVertexBufferObjectAttributes); GLES20.glUniformMatrix4fv(PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformModelViewPositionMatrixLocation, 1, false, pGLState.getModelViewProjectionGLMatrix(), 0); GLES20.glUniform1i(PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformTexture0Location, 0); GLES20.glUniform1i(PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformTexture1Location, 1); }
Example 13
Source File: PositionTextureCoordinatesUniformColorShaderProgram.java From tilt-game-android with MIT License | 5 votes |
@Override public void bind(final GLState pGLState, final VertexBufferObjectAttributes pVertexBufferObjectAttributes) { GLES20.glDisableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_COLOR_LOCATION); super.bind(pGLState, pVertexBufferObjectAttributes); GLES20.glUniformMatrix4fv(PositionTextureCoordinatesUniformColorShaderProgram.sUniformModelViewPositionMatrixLocation, 1, false, pGLState.getModelViewProjectionGLMatrix(), 0); GLES20.glUniform1i(PositionTextureCoordinatesUniformColorShaderProgram.sUniformTexture0Location, 0); }
Example 14
Source File: GLES20Canvas.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
private void setMatrix(ShaderParameter[] params, float x, float y, float width, float height) { Matrix.translateM(mTempMatrix, 0, mMatrices, mCurrentMatrixIndex, x, y, 0f); Matrix.scaleM(mTempMatrix, 0, width, height, 1f); Matrix.multiplyMM(mTempMatrix, MATRIX_SIZE, mProjectionMatrix, 0, mTempMatrix, 0); GLES20.glUniformMatrix4fv(params[INDEX_MATRIX].handle, 1, false, mTempMatrix, MATRIX_SIZE); checkError(); }
Example 15
Source File: FeatureShader.java From geoar-app with Apache License 2.0 | 5 votes |
public void setModelViewProjectionMatrix(float[] mvpMatrix) { if (programHandle == -1) { initProgram(); } // combined Matrix mvpMatrixUniform = GLES20.glGetUniformLocation(programHandle, UNIFORM_MATRIX_MVP); if (mvpMatrixUniform >= 0) GLES20.glUniformMatrix4fv(mvpMatrixUniform, 1, false, mvpMatrix, 0); }
Example 16
Source File: BaseObjectFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
@Override protected void drawFilter() { if (shouldLoad) { releaseTexture(); streamObjectTextureId = textureLoader.load(streamObject.getBitmaps()); shouldLoad = false; } GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); squareVertexObject.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aTextureObjectHandle, 2, GLES20.GL_FLOAT, false, 2 * FLOAT_SIZE_BYTES, squareVertexObject); GLES20.glEnableVertexAttribArray(aTextureObjectHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); //Sampler GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); //Object GLES20.glUniform1i(uObjectHandle, 0); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); }
Example 17
Source File: TreasureHuntActivity.java From PanoramaGL with Apache License 2.0 | 5 votes |
/** * Draw the cube. * * <p>We've set all of our transformation matrices. Now we simply pass them into the shader. */ public void drawCube() { GLES20.glUseProgram(cubeProgram); GLES20.glUniform3fv(cubeLightPosParam, 1, lightPosInEyeSpace, 0); // Set the Model in the shader, used to calculate lighting GLES20.glUniformMatrix4fv(cubeModelParam, 1, false, modelCube, 0); // Set the ModelView in the shader, used to calculate lighting GLES20.glUniformMatrix4fv(cubeModelViewParam, 1, false, modelView, 0); // Set the position of the cube GLES20.glVertexAttribPointer( cubePositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, cubeVertices); // Set the ModelViewProjection matrix in the shader. GLES20.glUniformMatrix4fv(cubeModelViewProjectionParam, 1, false, modelViewProjection, 0); // Set the normal positions of the cube, again for shading GLES20.glVertexAttribPointer(cubeNormalParam, 3, GLES20.GL_FLOAT, false, 0, cubeNormals); GLES20.glVertexAttribPointer(cubeColorParam, 4, GLES20.GL_FLOAT, false, 0, isLookingAtObject() ? cubeFoundColors : cubeColors); // Enable vertex arrays GLES20.glEnableVertexAttribArray(cubePositionParam); GLES20.glEnableVertexAttribArray(cubeNormalParam); GLES20.glEnableVertexAttribArray(cubeColorParam); GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36); checkGLError("Drawing cube"); }
Example 18
Source File: GLES20DrawContext.java From settlers-remake with MIT License | 4 votes |
@Override public void setHeightMatrix(float[] matrix) { useProgram(prog_background); GLES20.glUniformMatrix4fv(prog_background.ufs[HEIGHT], 1, false, matrix, 0); }
Example 19
Source File: Texture2dProgram.java From AndroidPlayground with MIT License | 4 votes |
/** * Issues the draw call. Does the full setup on every call. * * @param mvpMatrix The 4x4 projection matrix. * @param vertexBuffer Buffer with vertex position data. * @param firstVertex Index of first vertex to use in vertexBuffer. * @param vertexCount Number of vertices in vertexBuffer. * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2). * @param vertexStride Width, in bytes, of the position data for each vertex (often * vertexCount * sizeof(float)). * @param texMatrix A 4x4 transformation matrix for texture coords. (Primarily intended * for use with SurfaceTexture.) * @param texBuffer Buffer with vertex texture data. * @param texStride Width, in bytes, of the texture data for each vertex. */ public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex, int vertexCount, int coordsPerVertex, int vertexStride, float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) { GlUtil.checkGlError("draw start"); // Select the program. GLES20.glUseProgram(mProgramHandle); GlUtil.checkGlError("glUseProgram"); // Set the texture. GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(mTextureTarget, textureId); // Copy the model / view / projection matrix over. GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0); GlUtil.checkGlError("glUniformMatrix4fv"); // Copy the texture transformation matrix over. GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0); GlUtil.checkGlError("glUniformMatrix4fv"); // Enable the "aPosition" vertex attribute. GLES20.glEnableVertexAttribArray(maPositionLoc); GlUtil.checkGlError("glEnableVertexAttribArray"); // Connect vertexBuffer to "aPosition". GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex, GLES20.GL_FLOAT, false, vertexStride, vertexBuffer); GlUtil.checkGlError("glVertexAttribPointer"); // Enable the "aTextureCoord" vertex attribute. GLES20.glEnableVertexAttribArray(maTextureCoordLoc); GlUtil.checkGlError("glEnableVertexAttribArray"); // Connect texBuffer to "aTextureCoord". GLES20.glVertexAttribPointer(maTextureCoordLoc, 2, GLES20.GL_FLOAT, false, texStride, texBuffer); GlUtil.checkGlError("glVertexAttribPointer"); // Populate the convolution kernel, if present. if (muKernelLoc >= 0) { GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0); GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0); GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust); } // Draw the rect. GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount); GlUtil.checkGlError("glDrawArrays"); // Done -- disable vertex array, texture, and program. GLES20.glDisableVertexAttribArray(maPositionLoc); GLES20.glDisableVertexAttribArray(maTextureCoordLoc); GLES20.glBindTexture(mTextureTarget, 0); GLES20.glUseProgram(0); }
Example 20
Source File: GLParticles.java From Tanks with MIT License | 4 votes |
@Override protected void draw(RendererContext context, Data data) { if (isEnabled()) particles.update(); ShaderParticles shader = (ShaderParticles) Shader.getCurrent(); // build result matrix Matrix.multiplyMM(modelProjectionViewMatrix, 0, context.getProjectionViewMatrix(), 0, modelMatrix, 0); // bind texture to 0 slot GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureData.getHandle()); // send data to shader float life = count * updateTimeout; GLES20.glUniform2f(shader.uniformLifeTimeHandle, life, particles.getTime()); GLES20.glUniformMatrix4fv(shader.uniformMatrixHandle, 1, false, modelProjectionViewMatrix, 0); GLES20.glUniform1i(shader.uniformTextureHandle, 0); GLES20.glUniform2f(shader.uniformPointSize, startPointSize, endPointSize); GLES20.glUniform4fv(shader.uniformStartColor, 1, startColor.getRaw(), 0); GLES20.glUniform4fv(shader.uniformEndColor, 1, endColor.getRaw(), 0); // reset array buffer GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); // set offsets to arrays for buffer FloatBuffer buffer = particles.getBuffer(); buffer.position(0); GLES20.glVertexAttribPointer(shader.attributeDirectionVectorHandle, 3, GLES20.GL_FLOAT, false, 16, buffer); buffer.position(3); GLES20.glVertexAttribPointer(shader.attributeStartTimeHandle, 1, GLES20.GL_FLOAT, false, 16, buffer); // enable attribute arrays GLES20.glEnableVertexAttribArray(shader.attributeDirectionVectorHandle); GLES20.glEnableVertexAttribArray(shader.attributeStartTimeHandle); // validating if debug shader.validate(); // draw GLES20.glDrawArrays(GLES20.GL_POINTS, 0, particles.getCount()); // disable attribute arrays GLES20.glDisableVertexAttribArray(shader.attributeDirectionVectorHandle); GLES20.glDisableVertexAttribArray(shader.attributeStartTimeHandle); // auto unbind if max time reached if (maxTime > 0 && particles.getTime() > maxTime && !unbinded) { unbinded = true; unbind(); } }