First of all, I am a total beginner to jMonkeyEngine and Java, just to let you know…
I am trying to figure out how I can implement a rigged j3o model (converted from Mixamo) into my Android app, and apply rotations manually using quaternions to certain joints. However, I am struggling with the correct procedure. With the following code, I can succesfully import and view the ybot.j3o model, however I cannot seem to define the bone correctly and rotate it. Can you help me?
java.lang.NullPointerException: Attempt to invoke virtual method 'com.jme3.scene.Node com.jme3.anim.SkinningControl.getAttachmentsNode(java.lang.String)' on a null object reference
The structure of ybot.j3o in jMonkeyEngine SDK is:
Root Scene
-Armature
–Alpha_surface
–Alpha_Joints
–AnimComposer
—Idle
–Armature
—mixamorig:Hips
----mixamorig:LeftUpLeg
----etc…
AttachmentsNode is not what you are looking for. You should get the joint and apply the rotation to the joint, not the AttachmentsNode. AttachmentsNode is meant to be used for attaching items to joints so it will move by joint. (e.g. attaching a sword to hand,…)
Joint n = sc.getArmature().getJoint("mixamorig:RightForeArm");
When I do this, I get the following:
java.lang.NullPointerException: Attempt to invoke virtual method 'com.jme3.anim.Armature com.jme3.anim.SkinningControl.getArmature()' on a null object reference
Thanks, we are getting closer. Now the code runs and the forearm rotates correctly. But the child bones now look a little weird. Maybe they all rotated?
I am not a math genius… I think it happens because my test quaternion “new Quaternion(0.9f, 0.9f, 0.9f, 0.9f)” is not a realistic quaternion… When I try with e.g. “new Quaternion(0.00f, -0.98f, 0.14f, 0.00f)” it works brilliantly!
Thanks so much for help, it is really appreciated!