Search in sources :

Example 21 with Material

use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.

the class ObjectColorPicker method initialize.

public void initialize() {
    final int size = Math.max(mRenderer.getViewportWidth(), mRenderer.getViewportHeight());
    mRenderTarget = new RenderTarget("colorPickerTarget", size, size, 0, 0, false, false, GLES20.GL_TEXTURE_2D, Config.ARGB_8888, FilterType.LINEAR, WrapType.CLAMP);
    mRenderer.addRenderTarget(mRenderTarget);
    mPickerMaterial = new Material();
    MaterialManager.getInstance().addMaterial(mPickerMaterial);
}
Also used : Material(org.rajawali3d.materials.Material) RenderTarget(org.rajawali3d.renderer.RenderTarget)

Example 22 with Material

use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.

the class Scene method setSkybox.

/**
     * Creates a skybox with the specified 6 {@link Bitmap} textures.
     *
     * @param bitmaps {@link Bitmap} array containing the cube map textures.
     */
public boolean setSkybox(Bitmap[] bitmaps) {
    final AFrameTask task = new AFrameTask() {

        @Override
        protected void doTask() {
            for (int i = 0, j = mCameras.size(); i < j; ++i) mCameras.get(i).setFarPlane(1000);
        }
    };
    final Cube skybox = new Cube(700, true);
    final CubeMapTexture texture = new CubeMapTexture("bitmap_skybox", bitmaps);
    texture.isSkyTexture(true);
    final Material material = new Material();
    material.setColorInfluence(0);
    try {
        material.addTexture(texture);
    } catch (TextureException e) {
        RajLog.e(e.getMessage());
    }
    skybox.setMaterial(material);
    synchronized (mNextCameraLock) {
        mNextSkybox = skybox;
    }
    return internalOfferTask(task);
}
Also used : TextureException(org.rajawali3d.materials.textures.ATexture.TextureException) AFrameTask(org.rajawali3d.renderer.AFrameTask) Cube(org.rajawali3d.primitives.Cube) Material(org.rajawali3d.materials.Material) ShadowMapMaterial(org.rajawali3d.postprocessing.materials.ShadowMapMaterial) CubeMapTexture(org.rajawali3d.materials.textures.CubeMapTexture)

Example 23 with Material

use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.

the class Scene method updateChildMaterialWithLights.

/**
	 * Update the lights on this child's material. This method should only
	 * be called when the lights collection is dirty. It will
	 * trigger compilation of all light-enabled shaders.
	 *
	 * @param child
	 */
private void updateChildMaterialWithLights(Object3D child) {
    Material material = child.getMaterial();
    if (material != null && material.lightingEnabled())
        material.setLights(mLights);
    if (material != null && mFogParams != null)
        material.addPlugin(new FogMaterialPlugin(mFogParams));
    int numChildren = child.getNumChildren();
    for (int i = 0; i < numChildren; i++) {
        Object3D grandChild = child.getChildAt(i);
        updateChildMaterialWithLights(grandChild);
    }
}
Also used : Material(org.rajawali3d.materials.Material) ShadowMapMaterial(org.rajawali3d.postprocessing.materials.ShadowMapMaterial) FogMaterialPlugin(org.rajawali3d.materials.plugins.FogMaterialPlugin) Object3D(org.rajawali3d.Object3D)

Example 24 with Material

use of org.rajawali3d.materials.Material 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)

Example 25 with Material

use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.

the class VuforiaRenderer method onRenderSurfaceSizeChanged.

@Override
public void onRenderSurfaceSizeChanged(GL10 gl, int width, int height) {
    RajLog.i("onRenderSurfaceSizeChanged " + width + ", " + height);
    super.onRenderSurfaceSizeChanged(gl, width, height);
    updateRendering(width, height);
    QCAR.onSurfaceChanged(width, height);
    getCurrentCamera().setProjectionMatrix(getFOV(), getVideoWidth(), getVideoHeight());
    if (mBackgroundRenderTarget == null) {
        mBackgroundRenderTarget = new RenderTarget("rajVuforia", width, height);
        addRenderTarget(mBackgroundRenderTarget);
        Material material = new Material();
        material.setColorInfluence(0);
        try {
            material.addTexture(mBackgroundRenderTarget.getTexture());
        } catch (TextureException e) {
            e.printStackTrace();
        }
        mBackgroundQuad = new ScreenQuad();
        if (mVuforiaManager.getScreenOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
            mBackgroundQuad.setScaleY((float) height / (float) getVideoHeight());
        else
            mBackgroundQuad.setScaleX((float) width / (float) getVideoWidth());
        mBackgroundQuad.setMaterial(material);
        getCurrentScene().addChildAt(mBackgroundQuad, 0);
    }
}
Also used : TextureException(org.rajawali3d.materials.textures.ATexture.TextureException) ScreenQuad(org.rajawali3d.primitives.ScreenQuad) Material(org.rajawali3d.materials.Material) RenderTarget(org.rajawali3d.renderer.RenderTarget)

Aggregations

Material (org.rajawali3d.materials.Material)25 Vector3 (org.rajawali3d.math.vector.Vector3)9 DiffuseMethod (org.rajawali3d.materials.methods.DiffuseMethod)7 Texture (org.rajawali3d.materials.textures.Texture)6 TextureException (org.rajawali3d.materials.textures.ATexture.TextureException)5 Object3D (org.rajawali3d.Object3D)4 ShadowMapMaterial (org.rajawali3d.postprocessing.materials.ShadowMapMaterial)4 Cube (org.rajawali3d.primitives.Cube)4 ParsingException (org.rajawali3d.loader.ParsingException)3 NormalMapTexture (org.rajawali3d.materials.textures.NormalMapTexture)3 DirectionalLight (org.rajawali3d.lights.DirectionalLight)2 AwdProperties (org.rajawali3d.loader.LoaderAWD.AwdProperties)2 SpecularMethod (org.rajawali3d.materials.methods.SpecularMethod)2 ATexture (org.rajawali3d.materials.textures.ATexture)2 CubeMapTexture (org.rajawali3d.materials.textures.CubeMapTexture)2 Matrix4 (org.rajawali3d.math.Matrix4)2 ScreenQuad (org.rajawali3d.primitives.ScreenQuad)2 Sphere (org.rajawali3d.primitives.Sphere)2 AFrameTask (org.rajawali3d.renderer.AFrameTask)2 RenderTarget (org.rajawali3d.renderer.RenderTarget)2