Search in sources :

Example 1 with ObjectColorPicker

use of org.rajawali3d.util.ObjectColorPicker in project Rajawali by Rajawali.

the class Scene method doColorPicking.

protected void doColorPicking(ColorPickerInfo pickerInfo) {
    ObjectColorPicker picker = pickerInfo.getPicker();
    picker.getRenderTarget().bind();
    // Set background color (to Object3D.UNPICKABLE to prevent any conflicts)
    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    // Configure depth testing
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glDepthFunc(GLES20.GL_LESS);
    GLES20.glDepthMask(true);
    GLES20.glClearDepthf(1.0f);
    // Clear buffers used for color-picking
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    // Get the picking material
    Material pickingMaterial = picker.getMaterial();
    // Can't blend picking colors
    GLES20.glDisable(GLES20.GL_BLEND);
    // Render the Skybox first (no need for depth testing)
    if (mSkybox != null && mSkybox.isPickingEnabled()) {
        GLES20.glDisable(GLES20.GL_DEPTH_TEST);
        GLES20.glDepthMask(false);
        mSkybox.renderColorPicking(mCamera, pickingMaterial);
        GLES20.glEnable(GLES20.GL_DEPTH_TEST);
        GLES20.glDepthMask(true);
    }
    // Render all children using their picking colors
    synchronized (mChildren) {
        for (int i = 0, j = mChildren.size(); i < j; ++i) {
            mChildren.get(i).renderColorPicking(mCamera, pickingMaterial);
        }
    }
    // pickObject() unbinds the renderTarget's framebuffer...
    ObjectColorPicker.pickObject(pickerInfo);
}
Also used : ObjectColorPicker(org.rajawali3d.util.ObjectColorPicker) Material(org.rajawali3d.materials.Material) ShadowMapMaterial(org.rajawali3d.postprocessing.materials.ShadowMapMaterial)

Aggregations

Material (org.rajawali3d.materials.Material)1 ShadowMapMaterial (org.rajawali3d.postprocessing.materials.ShadowMapMaterial)1 ObjectColorPicker (org.rajawali3d.util.ObjectColorPicker)1