Closed jychimaster closed 10 years ago
I realized my mistake.
I should've never initialized and assign animation objects at the foundframemarker method (or any target found related methods). I did the assignments at the initScene method and simply called the play method in the "target found" methods.
Also very important is that the object3d container object must have a mesh. A simple cube with adequate scale size will suffice. Set mycontainer.isContainer(true) and then add your models to be animated with mycontainer.addChild(mymodel);
Closing
If the container is set isContainer(true) it should not need a mesh unless something has changed in the rendering method of the base object.
Toxic: Upon building the project, I would get null pointer exception if I did not add a basic mesh:
08-10 13:42:16.381: W/System.err(9722): java.lang.NullPointerException 08-10 13:42:16.381: W/System.err(9722): at com.example.rajawalivuforiaexample.RajawaliVuforiaExampleRenderer.initScene(RajawaliVuforiaExampleRenderer.java:422) 08-10 13:42:16.381: W/System.err(9722): at rajawali.renderer.RajawaliRenderer.onSurfaceChanged(RajawaliRenderer.java:426) 08-10 13:42:16.381: W/System.err(9722): at rajawali.vuforia.RajawaliVuforiaRenderer.onSurfaceChanged(RajawaliVuforiaRenderer.java:53) 08-10 13:42:16.381: W/System.err(9722): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1356) 08-10 13:42:16.381: W/System.err(9722): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118) 08-10 13:42:16.381: D/Rajawali(9722): Java_rajawali_vuforia_RajawaliVuforiaRenderer_updateRendering
Here's my snippet in the initScene method to get it working:
protected void initScene()
{
try {
// This cube is a simple model intended to be visible and animating
mTestCube= new Cube(20);
Material m_mat_TestCube = new Material();
m_mat_TestCube.enableLighting(true);
m_mat_TestCube.setDiffuseMethod(new DiffuseMethod.Lambert());
m_mat_TestCube.setSpecularMethod(new SpecularMethod.Phong());
mTestCube.setMaterial(m_mat_TestCube);
mTestCube.setColor(0x7fff0000);
// This is the empty Object3D suggested
mWorldObject = new Cube(40);
mWorldObject.isContainer(true);
mWorldObject.addChild(mTestCube);
getCurrentScene().addChild(mWorldObject);
// Rotating Animations
m_Anim = new RotateOnAxisAnimation(Axis.Y, 359);
m_Anim.setTransformable3D(mTestCube);
m_Anim.setDurationMilliseconds(3000);
m_Anim.setRepeatMode(RepeatMode.INFINITE);
getCurrentScene().registerAnimation(m_Anim);
}
catch (Exception e)
{
e.printStackTrace();
}
}
Hi @jychimaster
Change this
mWorldObject = new Cube(40);
mWorldObject.isContainer(true);
into
mWorldObject = new Object3D();
This is the correct way to create an empy.
Thanks for catching that. It was overlooked from my attempts to animate everything correctly. Cleaned up the code a bit. Instantiating with an Object3D() will work fine in this way as you said.
Hello, I tried making SkeletalAnimationObject3D object a child of an empty Object3D, then added the parent to the root of currentScene, now I can't see my animation on the screen. Any idea on what i'm doing wrong
Hi Dennis Rajawai and it's integration with Vuforia has been heaven-sent! Thank you for your contribution. I have an issue trying to animate models such as rotation, translate, color, etc when a marker or image has been found by the Vuforia AR engine.
I saw this stackoverflow thread: http://stackoverflow.com/questions/17548861/rajawali-and-vuforia-3d-model-positioning
I tried following your suggestion by creating an empty object3d object. However, it appears that by adding my model as a child to it, it follows the same locking trap that is going on for each frame being rendered. Specifically it looks like it's trying to do the animation only that it's looping back over and over.
Do you have any simple script for the initScene and foundImageMarker methods so that I can do the simple animation to it's completion without interference? I hope this makes sense.
Thanks!