Last active
December 23, 2015 07:28
-
-
Save jawinn/6600663 to your computer and use it in GitHub Desktop.
Debugging Error - Renderer.java for Rajawali Live Wallpaper Template - Can't change color on OBJ. Can change color on created cube. The imported OBJ is in the raw folder and is named "testscene_obj".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mydomain.wallpaper.mywallpaper; | |
import javax.microedition.khronos.egl.EGLConfig; | |
import javax.microedition.khronos.opengles.GL10; | |
import rajawali.Object3D; | |
import rajawali.parser.LoaderOBJ; | |
import rajawali.parser.ALoader.ParsingException; | |
import rajawali.animation.Animation3D.RepeatMode; | |
import rajawali.animation.RotateAnimation3D; | |
import rajawali.lights.ALight; | |
import rajawali.lights.DirectionalLight; | |
import rajawali.materials.Material; | |
import rajawali.materials.methods.DiffuseMethod; | |
import rajawali.materials.textures.ATexture.TextureException; | |
import rajawali.materials.textures.Texture; | |
import rajawali.math.vector.Vector3; | |
import rajawali.primitives.Cube; | |
import rajawali.renderer.RajawaliRenderer; | |
import android.content.Context; | |
import android.view.animation.AccelerateDecelerateInterpolator; | |
public class Renderer extends RajawaliRenderer { | |
public Renderer(Context context) { | |
super(context); | |
} | |
public 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); | |
// Set color on cube. Works | |
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.setColor(0xff0000ff); | |
cube.setMaterial(material); | |
cube.setColor(0xff0000ff); | |
addChild(cube); | |
// Set color on OBJ. Doesn't work; remains green | |
LoaderOBJ objParser = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.testscene_obj); | |
Object3D testModel; | |
try { | |
// Parse 3d Model(s) | |
objParser.parse(); | |
testModel = objParser.getParsedObject(); | |
testModel.setMaterial(material); | |
testModel.setColor(0xff0000ff); | |
addChild(testModel); | |
} | |
catch (ParsingException e) { | |
e.printStackTrace(); | |
} | |
Vector3 axis = new Vector3(3, 1, 6); | |
axis.normalize(); | |
RotateAnimation3D anim = new RotateAnimation3D(axis, 360); | |
anim.setDuration(8000); | |
anim.setRepeatMode(RepeatMode.INFINITE); | |
anim.setInterpolator(new AccelerateDecelerateInterpolator()); | |
anim.setTransformable3D(cube); | |
registerAnimation(anim); | |
anim.play(); | |
} | |
public void onSurfaceCreated(GL10 gl, EGLConfig config) { | |
super.onSurfaceCreated(gl, config); | |
} | |
public void onDrawFrame(GL10 glUnused) { | |
super.onDrawFrame(glUnused); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment