Search in sources :

Example 1 with Cube

use of org.rajawali3d.primitives.Cube 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)

Example 2 with Cube

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

the class WallpaperRenderer method initScene.

@Override
protected void initScene() {
    ALight light = new DirectionalLight(-1, 0, -1);
    light.setPower(2);
    getCurrentScene().addLight(light);
    getCurrentCamera().setPosition(0, 0, 7);
    getCurrentCamera().setLookAt(0, 0, 0);
    try {
        Cube cube = new Cube(1);
        Material material = new Material();
        material.enableLighting(true);
        material.setDiffuseMethod(new DiffuseMethod.Lambert());
        material.addTexture(new Texture("rajawaliTex", R.drawable.rajawali_tex));
        material.setColorInfluence(0);
        cube.setMaterial(material);
        getCurrentScene().addChild(cube);
        Vector3 axis = new Vector3(3, 1, 6);
        axis.normalize();
        Animation3D anim = new RotateOnAxisAnimation(axis, 0, 360);
        anim.setDurationMilliseconds(8000);
        anim.setRepeatMode(Animation.RepeatMode.INFINITE);
        anim.setInterpolator(new AccelerateDecelerateInterpolator());
        anim.setTransformable3D(cube);
        getCurrentScene().registerAnimation(anim);
        anim.play();
    } catch (ATexture.TextureException e) {
        e.printStackTrace();
    }
}
Also used : Material(org.rajawali3d.materials.Material) Vector3(org.rajawali3d.math.vector.Vector3) ATexture(org.rajawali3d.materials.textures.ATexture) Texture(org.rajawali3d.materials.textures.Texture) Animation3D(org.rajawali3d.animation.Animation3D) Cube(org.rajawali3d.primitives.Cube) RotateOnAxisAnimation(org.rajawali3d.animation.RotateOnAxisAnimation) DirectionalLight(org.rajawali3d.lights.DirectionalLight) ATexture(org.rajawali3d.materials.textures.ATexture) DiffuseMethod(org.rajawali3d.materials.methods.DiffuseMethod) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ALight(org.rajawali3d.lights.ALight)

Example 3 with Cube

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

the class BoundingBox method drawBoundingVolume.

public void drawBoundingVolume(Camera camera, final Matrix4 vpMatrix, final Matrix4 projMatrix, final Matrix4 vMatrix, final Matrix4 mMatrix) {
    if (mVisualBox == null) {
        mVisualBox = new Cube(1);
        Material material = new Material();
        mVisualBox.setMaterial(material);
        mVisualBox.setColor(mBoundingColor.get());
        mVisualBox.setDrawingMode(GLES20.GL_LINE_LOOP);
        mVisualBox.setDoubleSided(true);
    }
    mVisualBox.setScale(Math.abs(mTransformedMax.x - mTransformedMin.x), Math.abs(mTransformedMax.y - mTransformedMin.y), Math.abs(mTransformedMax.z - mTransformedMin.z));
    mVisualBox.setPosition(mTransformedMin.x + (mTransformedMax.x - mTransformedMin.x) * .5, mTransformedMin.y + (mTransformedMax.y - mTransformedMin.y) * .5, mTransformedMin.z + (mTransformedMax.z - mTransformedMin.z) * .5);
    mVisualBox.render(camera, vpMatrix, projMatrix, vMatrix, mTmpMatrix, null);
}
Also used : Cube(org.rajawali3d.primitives.Cube) Material(org.rajawali3d.materials.Material)

Example 4 with Cube

use of org.rajawali3d.primitives.Cube 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)

Aggregations

Material (org.rajawali3d.materials.Material)4 Cube (org.rajawali3d.primitives.Cube)4 CubeMapTexture (org.rajawali3d.materials.textures.CubeMapTexture)2 ShadowMapMaterial (org.rajawali3d.postprocessing.materials.ShadowMapMaterial)2 AFrameTask (org.rajawali3d.renderer.AFrameTask)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 Animation3D (org.rajawali3d.animation.Animation3D)1 RotateOnAxisAnimation (org.rajawali3d.animation.RotateOnAxisAnimation)1 ALight (org.rajawali3d.lights.ALight)1 DirectionalLight (org.rajawali3d.lights.DirectionalLight)1 DiffuseMethod (org.rajawali3d.materials.methods.DiffuseMethod)1 ATexture (org.rajawali3d.materials.textures.ATexture)1 TextureException (org.rajawali3d.materials.textures.ATexture.TextureException)1 Texture (org.rajawali3d.materials.textures.Texture)1 Vector3 (org.rajawali3d.math.vector.Vector3)1