Search in sources :

Example 1 with RotateOnAxisAnimation

use of org.rajawali3d.animation.RotateOnAxisAnimation 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)

Aggregations

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 Material (org.rajawali3d.materials.Material)1 DiffuseMethod (org.rajawali3d.materials.methods.DiffuseMethod)1 ATexture (org.rajawali3d.materials.textures.ATexture)1 Texture (org.rajawali3d.materials.textures.Texture)1 Vector3 (org.rajawali3d.math.vector.Vector3)1 Cube (org.rajawali3d.primitives.Cube)1