Search in sources :

Example 6 with Material

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

the class GridFloor method createGridFloor.

private void createGridFloor() {
    final float sizeHalf = mSize * 0.5f;
    final float spacing = mSize / mNumLines;
    mPoints = new Stack<>();
    for (float z = -sizeHalf; z <= sizeHalf; z += spacing) {
        mPoints.add(new Vector3(-sizeHalf, 0, z));
        mPoints.add(new Vector3(sizeHalf, 0, z));
    }
    for (float x = -sizeHalf; x <= sizeHalf; x += spacing) {
        mPoints.add(new Vector3(x, 0, -sizeHalf));
        mPoints.add(new Vector3(x, 0, sizeHalf));
    }
    setMaterial(new Material());
    init(true);
    setDrawingMode(GLES20.GL_LINES);
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) Material(org.rajawali3d.materials.Material)

Example 7 with Material

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

the class DebugBoundingBox method updateBoundingBox.

public void updateBoundingBox(BoundingBox boundingBox) {
    if (mBBoxVertices == null) {
        mBBoxVertices = new Vector3[8];
        mPoints = new Stack<>();
        for (int i = 0; i < 16; i++) {
            mPoints.push(new Vector3());
            if (i < 8)
                mBBoxVertices[i] = new Vector3();
        }
        init(true);
        getGeometry().changeBufferUsage(mGeometry.getVertexBufferInfo(), GLES20.GL_DYNAMIC_DRAW);
        setMaterial(new Material());
    }
    updateBox(boundingBox);
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) Material(org.rajawali3d.materials.Material)

Example 8 with Material

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

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

the class EffectPass method createMaterial.

protected void createMaterial(@NonNull VertexShader vertexShader, @NonNull FragmentShader fragmentShader) {
    mVertexShader = vertexShader;
    mFragmentShader = fragmentShader;
    mVertexShader.setNeedsBuild(false);
    mFragmentShader.setNeedsBuild(false);
    setMaterial(new Material(mVertexShader, mFragmentShader));
}
Also used : Material(org.rajawali3d.materials.Material)

Example 10 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 textures.
	 *
	 * @param posx int Resource id for the front face.
	 * @param negx int Resource id for the right face.
	 * @param posy int Resource id for the back face.
	 * @param negy int Resource id for the left face.
	 * @param posz int Resource id for the up face.
	 * @param negz int Resource id for the down face.
	 * @throws TextureException
	 */
public boolean setSkybox(int posx, int negx, int posy, int negy, int posz, int negz) throws TextureException {
    final AFrameTask task = new AFrameTask() {

        @Override
        protected void doTask() {
            for (int i = 0, j = mCameras.size(); i < j; ++i) mCameras.get(i).setFarPlane(1000);
        }
    };
    synchronized (mNextSkyboxLock) {
        mNextSkybox = new Cube(700, true);
        int[] resourceIds = new int[] { posx, negx, posy, negy, posz, negz };
        mSkyboxTexture = new CubeMapTexture("skybox", resourceIds);
        ((CubeMapTexture) mSkyboxTexture).isSkyTexture(true);
        Material mat = new Material();
        mat.setColorInfluence(0);
        mat.addTexture(mSkyboxTexture);
        mNextSkybox.setMaterial(mat);
    }
    return internalOfferTask(task);
}
Also used : 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)

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