Search in sources :

Example 1 with ScreenQuad

use of org.rajawali3d.primitives.ScreenQuad in project Rajawali by Rajawali.

the class SideBySideRenderer method initScene.

@Override
public void initScene() {
    mCameraLeft = new Camera();
    mCameraLeft.setNearPlane(.01f);
    mCameraLeft.setFieldOfView(getCurrentCamera().getFieldOfView());
    mCameraLeft.setNearPlane(getCurrentCamera().getNearPlane());
    mCameraLeft.setFarPlane(getCurrentCamera().getFarPlane());
    mCameraRight = new Camera();
    mCameraRight.setNearPlane(.01f);
    mCameraRight.setFieldOfView(getCurrentCamera().getFieldOfView());
    mCameraRight.setNearPlane(getCurrentCamera().getNearPlane());
    mCameraRight.setFarPlane(getCurrentCamera().getFarPlane());
    setPupilDistance(mPupilDistance);
    mLeftQuadMaterial = new Material();
    mLeftQuadMaterial.setColorInfluence(0);
    mRightQuadMaterial = new Material();
    mRightQuadMaterial.setColorInfluence(0);
    mSideBySideScene = new Scene(this);
    mLeftQuad = new ScreenQuad();
    mLeftQuad.setScaleX(.5);
    mLeftQuad.setX(-.25);
    mLeftQuad.setMaterial(mLeftQuadMaterial);
    mSideBySideScene.addChild(mLeftQuad);
    mRightQuad = new ScreenQuad();
    mRightQuad.setScaleX(.5);
    mRightQuad.setX(.25);
    mRightQuad.setMaterial(mRightQuadMaterial);
    mSideBySideScene.addChild(mRightQuad);
    addScene(mSideBySideScene);
    mViewportWidthHalf = (int) (mDefaultViewportWidth * .5f);
    mLeftRenderTarget = new RenderTarget("sbsLeftRT", mViewportWidthHalf, mDefaultViewportHeight);
    mLeftRenderTarget.setFullscreen(false);
    mRightRenderTarget = new RenderTarget("sbsRightRT", mViewportWidthHalf, mDefaultViewportHeight);
    mRightRenderTarget.setFullscreen(false);
    mCameraLeft.setProjectionMatrix(mViewportWidthHalf, mDefaultViewportHeight);
    mCameraRight.setProjectionMatrix(mViewportWidthHalf, mDefaultViewportHeight);
    addRenderTarget(mLeftRenderTarget);
    addRenderTarget(mRightRenderTarget);
    try {
        mLeftQuadMaterial.addTexture(mLeftRenderTarget.getTexture());
        mRightQuadMaterial.addTexture(mRightRenderTarget.getTexture());
    } catch (TextureException e) {
        e.printStackTrace();
    }
}
Also used : TextureException(org.rajawali3d.materials.textures.ATexture.TextureException) ScreenQuad(org.rajawali3d.primitives.ScreenQuad) Material(org.rajawali3d.materials.Material) Camera(org.rajawali3d.cameras.Camera) Scene(org.rajawali3d.scene.Scene)

Example 2 with ScreenQuad

use of org.rajawali3d.primitives.ScreenQuad 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)2 TextureException (org.rajawali3d.materials.textures.ATexture.TextureException)2 ScreenQuad (org.rajawali3d.primitives.ScreenQuad)2 Camera (org.rajawali3d.cameras.Camera)1 RenderTarget (org.rajawali3d.renderer.RenderTarget)1 Scene (org.rajawali3d.scene.Scene)1