Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tangomajom

Pages: [1]
1
Bones / Add child joint to existing skeleton at runtime
« on: January 18, 2017, 11:06:12 am »
Hi Raft,

After a long time I'm back again with an interesting question. :)

Is it possible to "extend" the skeleton of an Animated3D object with an extra child bone?

Let me explain the reason of this question:
As you may remember I'm working on a fitness application, and I have an animated Male who can show various exercises. The human body can move correctly thanks to JPCT and your library. :)
Now I would like to modify my code to let the human grab and lift objects (barbells, chains, kettlebells etc.).

Here is my plan:
1. create the movable objects in blender with only 1 bone, which affects the whole mesh.
2. export the objects with the ogre exporter (Just like I did with the Male body), and import the .bones file to my android project
3. after loading I would like to add the movable objects single bone to the Male body skeleton as a child of the hand bone.

If this is possible then I just need to animate only the human body, and the accessories will follow the linked bone.
Step 1 and 2 is easy, but with step 3 I need your help. Is it possible to connect the object like this way?

Thank you in advance,


2
Bones / Re: Some bones from the skeleton are twisted
« on: November 07, 2016, 09:34:27 am »
Ah ok. Maybe because of my english. :D
So... If you create an animation with Blender, this animation can be exported out to the ogre xml. (with the skeleton and mesh as well).
This animation obviously can be found in the bones file as well. And this embedded animation is works as expected. Shows the same animation what I can see in Blender player.

Regarding my problem I don't using these animation, due to the usage I wrote down below. 

3
Bones / Re: Some bones from the skeleton are twisted
« on: November 05, 2016, 11:27:32 am »
Hi Raft,

After some hours/days of debugging I've found the root cause of the issue. If I'm exporting out the model with animation from Blender it is working fine, so the skeleton is OK.
The problem was on the android side. Some information from my project: I'm writing a fitness application and the porpouse of this part of the app is to show various fitness exercises with the same man.
Therefore I can't use the animation from the .bones file. I have to create them at runtime from an external JSON string.

I'm sharing my code with you, to not let the other developers suffer with it in the future. Maybe it's not the best at the point of performance, but at least it is working as expected. :)
Code: [Select]
    public static List<JointChannel> parseAnimation(AnimatedGroup animatedObject, JSONObject animation) {
        List<JointChannel> result = new ArrayList<>();

        SkeletonHelper helper = new SkeletonHelper(animatedObject);

        try {
            double animationTime = animation.getDouble("length");
            int totalFrames = animation.getInt("tot_frames");
            float frameTime = (float) (animationTime / totalFrames);

            JSONArray jsonBones = animation.getJSONArray("joints");

            for (int jt_i = 0; jt_i < jsonBones.length(); jt_i++) {
                JSONObject jsonBone = jsonBones.getJSONObject(jt_i);

                Joint animatedJoint = helper.getJoint(jsonBone.getString("name"));

                JSONArray jsonKeyframes = jsonBone.getJSONArray("keyframes");

                Quaternion[] rotations = new Quaternion[jsonKeyframes.length()];
                SimpleVector[] translations = new SimpleVector[jsonKeyframes.length()];
                SimpleVector[] scales = new SimpleVector[jsonKeyframes.length()];
                float[] times = new float[jsonKeyframes.length()];


                Matrix OriginalRotationMatrix;
                SimpleVector boneTranslation;

                // First joint has no LOCAL bind pose. In case of first bone we have to use the GLOBAL position.
                if (animatedJoint.getIndex() == 0) {
                    OriginalRotationMatrix = animatedObject.get(0).getSkeletonPose().getGlobal(animatedJoint.getIndex());
                    boneTranslation = animatedObject.get(0).getSkeletonPose().getGlobal(animatedJoint.getIndex()).getTranslation();
                } else {
                    OriginalRotationMatrix = animatedObject.get(0).getSkeletonPose().getLocal(animatedJoint.getIndex());
                    boneTranslation = animatedObject.get(0).getSkeletonPose().getLocal(animatedJoint.getIndex()).getTranslation();
                }

                SimpleVector newTranslation = new SimpleVector(boneTranslation.x, boneTranslation.y, boneTranslation.z);

                SimpleVector JointXAxis = new SimpleVector();
                SimpleVector JointYAxis = new SimpleVector();
                SimpleVector JointZAxis = new SimpleVector();

                OriginalRotationMatrix.getXAxis(JointXAxis);
                OriginalRotationMatrix.getYAxis(JointYAxis);
                OriginalRotationMatrix.getZAxis(JointZAxis);

                for (int k_i = 0; k_i < jsonKeyframes.length(); k_i++) {

                    JSONObject jsonKeyframe = jsonKeyframes.getJSONObject(k_i);
                    JSONObject jsonTranslationVector = findVector(jsonKeyframe, "loc");
                    JSONObject jsonRotationVector = findVector(jsonKeyframe, "rot");

                    // we have to create another Matrix from the original to be able apply all the rotations on the same bind pose
                    Matrix rotationMatrix = new Matrix(OriginalRotationMatrix);

                    if (jsonRotationVector != null) {
                        // I had to switch the angles do get the same direction as in Blender.
                        rotationMatrix.rotateAxis(JointXAxis, (float) (jsonRotationVector.getDouble("x")*-1f));
                        rotationMatrix.rotateAxis(JointYAxis, (float) (jsonRotationVector.getDouble("y")*-1f));
                        rotationMatrix.rotateAxis(JointZAxis, (float) (jsonRotationVector.getDouble("z")*-1f));
                    }

                    if (jsonTranslationVector != null) {
                        // The translation vector will be filled only at the root bone. The bones just rotating.
                        newTranslation.x += jsonTranslationVector.getDouble("x");
                        newTranslation.y += jsonTranslationVector.getDouble("y");
                        newTranslation.z += jsonTranslationVector.getDouble("z");
                    }


                    //Creating channel data
                    rotations[k_i] = new Quaternion(rotationMatrix);
                    translations[k_i] = newTranslation;
                    scales[k_i] = new SimpleVector(1, 1, 1);
                    times[k_i] = jsonKeyframe.getInt("frame") * frameTime;
                }

                JointChannel channel = new JointChannel(animatedJoint.getIndex(), times, translations, rotations, scales);
                result.add(channel);
            }

            return result;
        } catch (JSONException e) {
            e.printStackTrace();
            return null;
        }

    }

Here's a sample animation JSON, just as an input:
Code: [Select]
{"joints": [{"name": "root", "keyframes": [{"loc": {"x": 0.0, "y": 0.0, "z": 0.0}, "rot": {"x": 0.0, "y": 0.0, "z": 0.0}, "frame": 0}, {"loc": {"x": 0.0, "y": 0.0, "z": 0.0}, "rot": {"x": 0.0, "y": 0.0, "z": 0.0}, "frame": 50}]}, {"name": "thigh_L", "keyframes": [{"loc": null, "rot": {"x": 0.0, "y": 0.0, "z": 0.0}, "frame": 0}, {"loc": null, "rot": {"x": 1.6144294738769531, "y": 0.0, "z": -0.21467548608779907}, "frame": 50}]}, {"name": "calf_L", "keyframes": [{"loc": null, "rot": {"x": 0.0, "y": 0.0, "z": 0.0}, "frame": 0}, {"loc": null, "rot": {"x": -1.8954274654388428, "y": 0.0, "z": 0.0}, "frame": 50}]}, {"name": "foot_L", "keyframes": [{"loc": null, "rot": {"x": 0.0, "y": 0.0, "z": 0.0}, "frame": 0}, {"loc": null, "rot": {"x": -0.8970991969108582, "y": 0.0, "z": 0.0}, "frame": 50}]}, {"name": "clavicle_L", "keyframes": [{"loc": null, "rot": {"x": 0.0, "y": -0.9093164801597595, "z": 0.715584933757782}, "frame": 0}, {"loc": null, "rot": {"x": -0.14696186780929565, "y": -0.7961800694465637, "z": -0.12130868434906006}, "frame": 50}]}, {"name": "upperarm_L", "keyframes": [{"loc": null, "rot": {"x": 0.4538916051387787, "y": 0.19377639889717102, "z": 0.48314473032951355}, "frame": 0}, {"loc": null, "rot": {"x": -0.41943061351776123, "y": 0.04430050030350685, "z": -0.19194363057613373}, "frame": 50}]}, {"name": "lowerarm_L", "keyframes": [{"loc": null, "rot": {"x": 0.4298973083496094, "y": -0.35149678587913513, "z": 0.05556275695562363}, "frame": 0}, {"loc": null, "rot": {"x": 2.1684257984161377, "y": -0.703183650970459, "z": 0.19366076588630676}, "frame": 50}]}], "name": "MaleBodyV2Action", "length": 2.0, "tot_frames": 50}

And a small snippet for the usage of the parser method below:
Code: [Select]
  MaleBody = loadMaleBody(R.raw.malebody_v2);
  MaleBody.setAutoApplyAnimation(true);
  SkinClip ExerciseClip = new SkinClip(MaleBody.get(0).getSkeleton(), ParseUtils.parseAnimation(MaleBody, new JSONObject("json string from input below")));
  SkinClipSequence clipSeq = new SkinClipSequence(ExerciseClip);
  MaleBody.setSkinClipSequence(clipSeq);

I hope will help for you guys in the future. Thank you Raft for the support and help. The procedural animation sample was really helpful at this time.
This is an awesome library, and I wasn't able to achieve my goals without this.


Regards,
Tangomajom

4
Bones / Re: Some bones from the skeleton are twisted
« on: November 02, 2016, 10:05:33 pm »
Hi Raft,

Sorry for late answer. I've finally was able to launch your code samples. ( as I'm a beginner  I had to learn first how to launch nativa java codes).  Anyway, the skeleton what you received it's wrong. I've exported out from Blender again and now looks fine. At least a clavicles are on the right place, but somehow the X and Y axis of the clavicle bones are switched. (Only that ones).

Quote
bones which are not exactly connected to it's parent
Nevermind. As I compared and played a bit with the skeleton I have realized that your OgreSample code and Blender visualize the bones differently. E.g.: Blender shows the head an tail of the bones as well, but your code shows only head of the bone, and only those bones are visible which have children. That's why the head bone is not visible. But this is not a problem I think, just confused me a bit.

The main question is still the same. Why are the bones are rotated, and why not the complete skeleton? And of course how to solve it?
Is there a good ogre skeleton editor software in the wide internet?

5
Bones / Re: Some bones from the skeleton are twisted
« on: November 02, 2016, 09:42:56 am »
Quote
can you please explain this? are there bones which have no parent (except root bone)
Of course, let me pick the clavicles as an example:
In blender I can see that the clavicles are the childs of Spine03, and I can see they connected to the tail of Spine03 (first picture from previous post).
However in Meshy the clavicle is connected to the head of Spine03. (second picture)

The skeleton xml is too big to attach it here. but here's the bone map and hierarchy:

Code: [Select]
<skeleton >
  <bones >
    <bone name="root" id="0" >
      <position y="0.000000" x="0.004884" z="-0.864401" />
      <rotation angle="3.125720" >
        <axis y="-0.001876" x="0.002568" z="0.999995" />
      </rotation>
    </bone>
    <bone name="pelvis" id="1" >
      <position y="0.017706" x="0.009123" z="0.837741" />
      <rotation angle="3.157657" >
        <axis y="0.577741" x="-0.002378" z="0.816217" />
      </rotation>
    </bone>
    <bone name="thigh_R" id="2" >
      <position y="0.081660" x="-0.115646" z="0.016301" />
      <rotation angle="3.056091" >
        <axis y="-0.162595" x="0.006344" z="0.986673" />
      </rotation>
    </bone>
    <bone name="calf_R" id="3" >
      <position y="0.432069" x="0.000000" z="0.000000" />
      <rotation angle="0.048844" >
        <axis y="0.818485" x="-0.506454" z="-0.271795" />
      </rotation>
    </bone>
    <bone name="foot_R" id="4" >
      <position y="0.390520" x="-0.000000" z="-0.000000" />
      <rotation angle="1.051425" >
        <axis y="0.035373" x="0.997835" z="0.055448" />
      </rotation>
    </bone>
    <bone name="toes_R" id="5" >
      <position y="0.169624" x="-0.000000" z="0.000000" />
      <rotation angle="3.128870" >
        <axis y="0.973478" x="0.029706" z="0.226845" />
      </rotation>
    </bone>
    <bone name="thigh_L" id="6" >
      <position y="0.081535" x="0.115647" z="0.016254" />
      <rotation angle="3.056110" >
        <axis y="0.162608" x="0.006301" z="-0.986671" />
      </rotation>
    </bone>
    <bone name="calf_L" id="7" >
      <position y="0.432112" x="0.000000" z="-0.000000" />
      <rotation angle="0.048815" >
        <axis y="-0.818230" x="-0.506691" z="0.271911" />
      </rotation>
    </bone>
    <bone name="foot_L" id="8" >
      <position y="0.390563" x="-0.000000" z="0.000000" />
      <rotation angle="1.051366" >
        <axis y="-0.035370" x="0.997835" z="-0.055445" />
      </rotation>
    </bone>
    <bone name="toes_L" id="9" >
      <position y="0.169629" x="0.000000" z="0.000000" />
      <rotation angle="0.464756" >
        <axis y="0.115608" x="0.981988" z="0.149451" />
      </rotation>
    </bone>
    <bone name="spine01" id="10" >
      <position y="0.177346" x="0.000000" z="-0.000000" />
      <rotation angle="0.427656" >
        <axis y="0.000075" x="1.000000" z="-0.000017" />
      </rotation>
    </bone>
    <bone name="spine02" id="11" >
      <position y="0.110510" x="-0.000000" z="0.000000" />
      <rotation angle="0.185709" >
        <axis y="0.000001" x="-1.000011" z="0.000000" />
      </rotation>
    </bone>
    <bone name="spine03" id="12" >
      <position y="0.116148" x="-0.000000" z="-0.000000" />
      <rotation angle="0.078377" >
        <axis y="-0.000002" x="0.999978" z="-0.000002" />
      </rotation>
    </bone>
    <bone name="clavicle_L" id="13" >
      <position y="0.170250" x="-0.000000" z="-0.000000" />
      <rotation angle="1.571824" >
        <axis y="0.002077" x="0.234202" z="-0.972186" />
      </rotation>
    </bone>
    <bone name="upperarm_L" id="14" >
      <position y="0.186862" x="-0.000000" z="0.000000" />
      <rotation angle="0.686020" >
        <axis y="-0.459979" x="-0.153060" z="-0.874639" />
      </rotation>
    </bone>
    <bone name="lowerarm_L" id="15" >
      <position y="0.263759" x="-0.000000" z="0.000000" />
      <rotation angle="0.144497" >
        <axis y="0.330465" x="-0.123323" z="0.935728" />
      </rotation>
    </bone>
    <bone name="hand_L" id="16" >
      <position y="0.282916" x="-0.000000" z="0.000000" />
      <rotation angle="1.743418" >
        <axis y="0.992426" x="0.118993" z="-0.030513" />
      </rotation>
    </bone>
    <bone name="thumb01_L" id="17" >
      <position y="0.016860" x="-0.016082" z="0.001996" />
      <rotation angle="2.183389" >
        <axis y="-0.834727" x="0.512873" z="0.200479" />
      </rotation>
    </bone>
    <bone name="thumb02_L" id="18" >
      <position y="0.042982" x="0.000000" z="-0.000000" />
      <rotation angle="0.130239" >
        <axis y="-0.406952" x="0.423240" z="0.809481" />
      </rotation>
    </bone>
    <bone name="thumb03_L" id="19" >
      <position y="0.037002" x="0.000000" z="0.000000" />
      <rotation angle="0.413834" >
        <axis y="0.034483" x="-0.996408" z="-0.077359" />
      </rotation>
    </bone>
    <bone name="index00_L" id="20" >
      <position y="0.037192" x="-0.000000" z="-0.000000" />
      <rotation angle="3.012851" >
        <axis y="-0.958519" x="0.261298" z="0.113864" />
      </rotation>
    </bone>
    <bone name="index01_L" id="21" >
      <position y="0.056785" x="-0.000000" z="-0.000000" />
      <rotation angle="0.829512" >
        <axis y="-0.533453" x="-0.548727" z="0.643682" />
      </rotation>
    </bone>
    <bone name="index02_L" id="22" >
      <position y="0.037158" x="0.000000" z="-0.000000" />
      <rotation angle="0.173344" >
        <axis y="0.076996" x="0.948542" z="0.307155" />
      </rotation>
    </bone>
    <bone name="index03_L" id="23" >
      <position y="0.024139" x="0.000000" z="-0.000000" />
      <rotation angle="0.189262" >
        <axis y="-0.174333" x="-0.980069" z="0.095293" />
      </rotation>
    </bone>
    <bone name="middle00_L" id="24" >
      <position y="0.037192" x="-0.000000" z="-0.000000" />
      <rotation angle="3.122542" >
        <axis y="0.991926" x="-0.098104" z="-0.080365" />
      </rotation>
    </bone>
    <bone name="middle01_L" id="25" >
      <position y="0.047485" x="-0.000000" z="0.000000" />
      <rotation angle="0.578610" >
        <axis y="-0.492799" x="-0.748925" z="0.443014" />
      </rotation>
    </bone>
    <bone name="middle02_L" id="26" >
      <position y="0.041070" x="0.000000" z="0.000000" />
      <rotation angle="0.167828" >
        <axis y="0.316871" x="0.934752" z="0.160737" />
      </rotation>
    </bone>
    <bone name="middle03_L" id="27" >
      <position y="0.029032" x="-0.000000" z="-0.000000" />
      <rotation angle="0.132120" >
        <axis y="-0.029757" x="-0.986498" z="-0.161075" />
      </rotation>
    </bone>
    <bone name="ring00_L" id="28" >
      <position y="0.037192" x="-0.000000" z="-0.000000" />
      <rotation angle="2.904945" >
        <axis y="0.991570" x="0.125271" z="-0.033103" />
      </rotation>
    </bone>
    <bone name="ring01_L" id="29" >
      <position y="0.042031" x="0.000000" z="0.000000" />
      <rotation angle="0.365672" >
        <axis y="0.138642" x="-0.908127" z="-0.395076" />
      </rotation>
    </bone>
    <bone name="ring02_L" id="30" >
      <position y="0.040239" x="-0.000000" z="0.000000" />
      <rotation angle="0.125652" >
        <axis y="-0.113431" x="0.944838" z="-0.307305" />
      </rotation>
    </bone>
    <bone name="ring03_L" id="31" >
      <position y="0.027510" x="0.000000" z="-0.000000" />
      <rotation angle="0.146784" >
        <axis y="-0.132122" x="-0.989528" z="0.058113" />
      </rotation>
    </bone>
    <bone name="pinky00_L" id="32" >
      <position y="0.037192" x="-0.000000" z="-0.000000" />
      <rotation angle="2.673930" >
        <axis y="0.932949" x="0.359854" z="0.010507" />
      </rotation>
    </bone>
    <bone name="pinky01_L" id="33" >
      <position y="0.045374" x="-0.000000" z="-0.000000" />
      <rotation angle="0.702573" >
        <axis y="0.492221" x="-0.356325" z="-0.794199" />
      </rotation>
    </bone>
    <bone name="pinky02_L" id="34" >
      <position y="0.032688" x="-0.000000" z="0.000000" />
      <rotation angle="0.118357" >
        <axis y="-0.002701" x="0.968474" z="-0.249115" />
      </rotation>
    </bone>
    <bone name="pinky03_L" id="35" >
      <position y="0.019855" x="-0.000000" z="-0.000000" />
      <rotation angle="0.198635" >
        <axis y="-0.052110" x="-0.977265" z="-0.205534" />
      </rotation>
    </bone>
    <bone name="clavicle_R" id="36" >
      <position y="0.199812" x="-0.033264" z="0.061997" />
      <rotation angle="1.772751" >
        <axis y="-0.075733" x="-0.032057" z="0.996613" />
      </rotation>
    </bone>
    <bone name="upperarm_R" id="37" >
      <position y="0.152543" x="-0.000000" z="-0.000000" />
      <rotation angle="0.428023" >
        <axis y="0.051732" x="0.423397" z="0.904466" />
      </rotation>
    </bone>
    <bone name="lowerarm_R" id="38" >
      <position y="0.263622" x="0.000000" z="0.000000" />
      <rotation angle="0.143737" >
        <axis y="-0.332338" x="-0.124178" z="-0.934948" />
      </rotation>
    </bone>
    <bone name="hand_R" id="39" >
      <position y="0.282921" x="0.000000" z="-0.000000" />
      <rotation angle="1.743419" >
        <axis y="-0.992481" x="0.118623" z="0.030159" />
      </rotation>
    </bone>
    <bone name="thumb01_R" id="40" >
      <position y="0.016851" x="0.016082" z="0.001999" />
      <rotation angle="2.183658" >
        <axis y="0.834654" x="0.513032" z="-0.200378" />
      </rotation>
    </bone>
    <bone name="thumb02_R" id="41" >
      <position y="0.042978" x="-0.000000" z="0.000000" />
      <rotation angle="0.130375" >
        <axis y="0.407649" x="0.423195" z="-0.809149" />
      </rotation>
    </bone>
    <bone name="thumb03_R" id="42" >
      <position y="0.036997" x="-0.000000" z="-0.000000" />
      <rotation angle="0.413836" >
        <axis y="-0.034358" x="-0.996407" z="0.077419" />
      </rotation>
    </bone>
    <bone name="index00_R" id="43" >
      <position y="0.037172" x="0.000000" z="-0.000000" />
      <rotation angle="3.013274" >
        <axis y="0.958492" x="0.261395" z="-0.113865" />
      </rotation>
    </bone>
    <bone name="index01_R" id="44" >
      <position y="0.056768" x="-0.000000" z="-0.000000" />
      <rotation angle="0.828851" >
        <axis y="0.531804" x="-0.549957" z="-0.643997" />
      </rotation>
    </bone>
    <bone name="index02_R" id="45" >
      <position y="0.037137" x="0.000000" z="-0.000000" />
      <rotation angle="0.196769" >
        <axis y="-0.475797" x="0.824788" z="-0.305554" />
      </rotation>
    </bone>
    <bone name="index03_R" id="46" >
      <position y="0.024126" x="-0.000000" z="0.000000" />
      <rotation angle="0.219170" >
        <axis y="0.524094" x="-0.850334" z="-0.047597" />
      </rotation>
    </bone>
    <bone name="middle00_R" id="47" >
      <position y="0.037172" x="0.000000" z="-0.000000" />
      <rotation angle="3.160929" >
        <axis y="0.991917" x="0.098146" z="-0.080419" />
      </rotation>
    </bone>
    <bone name="middle01_R" id="48" >
      <position y="0.047465" x="0.000000" z="0.000000" />
      <rotation angle="0.578959" >
        <axis y="0.492412" x="-0.749162" z="-0.443043" />
      </rotation>
    </bone>
    <bone name="middle02_R" id="49" >
      <position y="0.041048" x="-0.000000" z="-0.000000" />
      <rotation angle="0.173501" >
        <axis y="0.395327" x="0.913097" z="-0.099965" />
      </rotation>
    </bone>
    <bone name="middle03_R" id="50" >
      <position y="0.029016" x="-0.000000" z="0.000000" />
      <rotation angle="0.202310" >
        <axis y="-0.756365" x="-0.649586" z="0.077140" />
      </rotation>
    </bone>
    <bone name="ring00_R" id="51" >
      <position y="0.037172" x="0.000000" z="-0.000000" />
      <rotation angle="2.904867" >
        <axis y="-0.991560" x="0.125337" z="0.033143" />
      </rotation>
    </bone>
    <bone name="ring01_R" id="52" >
      <position y="0.042011" x="-0.000000" z="0.000000" />
      <rotation angle="0.362518" >
        <axis y="0.017680" x="-0.928076" z="0.371973" />
      </rotation>
    </bone>
    <bone name="ring02_R" id="53" >
      <position y="0.040217" x="0.000000" z="-0.000000" />
      <rotation angle="0.126428" >
        <axis y="-0.151300" x="0.926725" z="0.343959" />
      </rotation>
    </bone>
    <bone name="ring03_R" id="54" >
      <position y="0.027495" x="0.000000" z="0.000000" />
      <rotation angle="0.146042" >
        <axis y="0.073272" x="-0.994247" z="-0.078378" />
      </rotation>
    </bone>
    <bone name="pinky00_R" id="55" >
      <position y="0.037172" x="0.000000" z="-0.000000" />
      <rotation angle="2.673932" >
        <axis y="-0.932891" x="0.360005" z="-0.010530" />
      </rotation>
    </bone>
    <bone name="pinky01_R" id="56" >
      <position y="0.045358" x="-0.000000" z="-0.000000" />
      <rotation angle="0.663960" >
        <axis y="-0.393168" x="-0.412911" z="0.821538" />
      </rotation>
    </bone>
    <bone name="pinky02_R" id="57" >
      <position y="0.032670" x="-0.000000" z="-0.000000" />
      <rotation angle="0.131007" >
        <axis y="-0.426463" x="0.861088" z="0.276885" />
      </rotation>
    </bone>
    <bone name="pinky03_R" id="58" >
      <position y="0.019844" x="0.000000" z="-0.000000" />
      <rotation angle="0.206724" >
        <axis y="0.277492" x="-0.949614" z="0.145713" />
      </rotation>
    </bone>
    <bone name="neck" id="59" >
      <position y="0.229853" x="0.000000" z="0.075093" />
      <rotation angle="0.161672" >
        <axis y="-0.000018" x="1.000002" z="0.000534" />
      </rotation>
    </bone>
    <bone name="head" id="60" >
      <position y="0.119624" x="-0.000000" z="0.000000" />
      <rotation angle="0.071025" >
        <axis y="-0.000047" x="-1.000010" z="-0.002104" />
      </rotation>
    </bone>
  </bones>
  <bonehierarchy >
    <boneparent bone="pelvis" parent="root" />
    <boneparent bone="thigh_R" parent="pelvis" />
    <boneparent bone="calf_R" parent="thigh_R" />
    <boneparent bone="foot_R" parent="calf_R" />
    <boneparent bone="toes_R" parent="foot_R" />
    <boneparent bone="thigh_L" parent="pelvis" />
    <boneparent bone="calf_L" parent="thigh_L" />
    <boneparent bone="foot_L" parent="calf_L" />
    <boneparent bone="toes_L" parent="foot_L" />
    <boneparent bone="spine01" parent="pelvis" />
    <boneparent bone="spine02" parent="spine01" />
    <boneparent bone="spine03" parent="spine02" />
    <boneparent bone="clavicle_L" parent="spine03" />
    <boneparent bone="upperarm_L" parent="clavicle_L" />
    <boneparent bone="lowerarm_L" parent="upperarm_L" />
    <boneparent bone="hand_L" parent="lowerarm_L" />
    <boneparent bone="thumb01_L" parent="hand_L" />
    <boneparent bone="thumb02_L" parent="thumb01_L" />
    <boneparent bone="thumb03_L" parent="thumb02_L" />
    <boneparent bone="index00_L" parent="hand_L" />
    <boneparent bone="index01_L" parent="index00_L" />
    <boneparent bone="index02_L" parent="index01_L" />
    <boneparent bone="index03_L" parent="index02_L" />
    <boneparent bone="middle00_L" parent="hand_L" />
    <boneparent bone="middle01_L" parent="middle00_L" />
    <boneparent bone="middle02_L" parent="middle01_L" />
    <boneparent bone="middle03_L" parent="middle02_L" />
    <boneparent bone="ring00_L" parent="hand_L" />
    <boneparent bone="ring01_L" parent="ring00_L" />
    <boneparent bone="ring02_L" parent="ring01_L" />
    <boneparent bone="ring03_L" parent="ring02_L" />
    <boneparent bone="pinky00_L" parent="hand_L" />
    <boneparent bone="pinky01_L" parent="pinky00_L" />
    <boneparent bone="pinky02_L" parent="pinky01_L" />
    <boneparent bone="pinky03_L" parent="pinky02_L" />
    <boneparent bone="clavicle_R" parent="spine03" />
    <boneparent bone="upperarm_R" parent="clavicle_R" />
    <boneparent bone="lowerarm_R" parent="upperarm_R" />
    <boneparent bone="hand_R" parent="lowerarm_R" />
    <boneparent bone="thumb01_R" parent="hand_R" />
    <boneparent bone="thumb02_R" parent="thumb01_R" />
    <boneparent bone="thumb03_R" parent="thumb02_R" />
    <boneparent bone="index00_R" parent="hand_R" />
    <boneparent bone="index01_R" parent="index00_R" />
    <boneparent bone="index02_R" parent="index01_R" />
    <boneparent bone="index03_R" parent="index02_R" />
    <boneparent bone="middle00_R" parent="hand_R" />
    <boneparent bone="middle01_R" parent="middle00_R" />
    <boneparent bone="middle02_R" parent="middle01_R" />
    <boneparent bone="middle03_R" parent="middle02_R" />
    <boneparent bone="ring00_R" parent="hand_R" />
    <boneparent bone="ring01_R" parent="ring00_R" />
    <boneparent bone="ring02_R" parent="ring01_R" />
    <boneparent bone="ring03_R" parent="ring02_R" />
    <boneparent bone="pinky00_R" parent="hand_R" />
    <boneparent bone="pinky01_R" parent="pinky00_R" />
    <boneparent bone="pinky02_R" parent="pinky01_R" />
    <boneparent bone="pinky03_R" parent="pinky02_R" />
    <boneparent bone="neck" parent="spine03" />
    <boneparent bone="head" parent="neck" />
  </bonehierarchy>

I can find parent of clavicles. Is it possible that in the ogre skeleton I can't define more than on child for a bone? The Spine03 has three children (clavicle right and left and the neck)

6
Bones / Re: Some bones from the skeleton are twisted
« on: November 02, 2016, 07:22:45 am »
Thank you guys for the help. Unfortunately the page that raft linked is not responding. Do we have any alternative?
@AGP: I know that your topic is important for you, but please post your questions to your forum topic, just to not confuse us, or the others who will read this post in the future

So, to turn back to my topic:
I've tried to find some alternative for ogreMax, and I found an app called Meshy.(http://www.ogre3d.org/tikiwiki/Ogre+Meshy).

I think I found the problem, but the reason is still unknown for me. I don't know if the Meshy shows the bones different, or they really mixed up, but looks like the bones which are not exactly connected to it's parent are connected differently.
Please check the two attached picture from the original rig from Blender and the exported ogre format one.

I've double checked the skeleton xml and the bone hierarchy looks good. Do you have any idea why are the clavickle bones are connected to the head of the Spine bone instead of the tail?

7
Bones / Some bones from the skeleton are twisted
« on: November 01, 2016, 03:35:42 pm »
Hi Raft,

I would like to ask your help with a very tricky situation. I've created a model in Blender and I was able to load it to Android via the Ogre xml files and bones converter scripts. It works like charm.
Afterward I've tried to animate the bones individually from android to double check whether it has the same behaviour like in Blender. Most of the bones are moving as expected but looks like some of the bones are rotated and their relative axes are also mixed somehow.

For example if I'm rotating the clavickle bone around it's Y at Blender, the visual result on Android looks like when I rotated around it's X and vice versa. 

At first glance I thought the problem is with the different coordinate systems of Blender and JPCT, but if it's really the case, then why only just some of the bones are gone "mad"?

I think the problem is with the exported ogre xml. Unfortunately this forum denies any file which is bigger than 64kb, so I've uploaded it to my server slot: https://medev.hu/3d/MaleBody/MaleBody.rar .
Would be good if I can double check how the exported file look like, but I can't found any ogre xml importer or visualizer apps for Windows. 
I saw in your previous posts that you're using some kind of Ogre Visualizer app. Could you please give me the link for this app, and give me some info how to use it?

I would also appreciate if you can have a look at my attached files, maybe you can find something what I did not.


Thank you in advance,

8
Bones / Which matrix is the best to rotate a bone?
« on: April 19, 2016, 10:18:48 am »
Hi,

Maybe this sounds a bit stupid, but I can't find out by myself.
So I would like to apply an Euler rotation based animation to my imported rigged model. The animation in the Collada file is played correctly, but I would like to create the same animation programatically.

My idea is to create a quaternion from the original rotation of the bone, and then I'll use the Quaternion.rotateX/Y/Z methods, and then this modified quaternion will go to the JointChannel.
The only question is that how can I reach the current rotation matrix of the bone, to create the good quaternion from it.

I tried to use the SkeletonHelper.getBoneDirection(animatedJoint).getRotationMatrix(), and also the animatedObject.get(0).getSkeletonPose().getLocal(animatedJoint.getIndex()).getTranslation().getRotationMatrix(), and they inverts as well, but none of them produced the expected result.

Please give an advise.

Thanks in advance,

9
Bones / Re: SkinAnimation not displaying on android
« on: March 29, 2016, 12:22:38 pm »
Great! mCurrentPose.getLocal(<Index of joint>).getTranslation() solved the problem. Now everything is running perfectly. Thank you for your support and for this library as well. Good job! :)

10
Bones / Re: SkinAnimation not displaying on android
« on: March 29, 2016, 11:26:43 am »
Hi,

Thank you. After I fixed these, the animation played correctly. Meanwhile I found the reason of the low fps: my mesh was too detailed. It contained almost 140K of triangles, which killed my mobile... :D

You're right. These translations generated invalid positions. As you can see in the attachment the shin of my human model relocated to front of the body and to the level of hips... :D


Is there a best practice to get the current translation of a joint? I tried via Skeletonhelper ->GetJointDirection(),  Joint.getBindPose().getTranslation(), Joint.getInverseBindPose().getTranslation(), but none of them worked. If I can get the current position of the bone I guess I just need to copy it to the channel keyframes, to avoid any position change.

11
Bones / SkinAnimation not displaying on android
« on: March 26, 2016, 08:26:10 pm »
Hi Raft,

First of all sorry for my English. I try to do my best, but I'm not a professional. I'm also a beginer with 3D modelling, therefore I asked your help.

So the problem in nutshell:

I succesfully imported a rigged object from Blender to JPCT. I already find out how can I move and rotate the joints. The next step should be to create a skin animation.
Basicly I just would like to rotate the joints, so only the rotation quaternions will change in the keyframes. The translation and scale vectors don't need to be changed.
The results of my code is not what I expected. My character is still not moving.

Please have a look at to my code, possibly I'm not using your library right, or just missing some neccessary method call. 

This is how I apply the animation in the OnSurfaceChanged() method:
 
Code: [Select]
SkinClipSequence clipSeq = new SkinClipSequence(createSkinClip());
MaleBody.setSkinClipSequence(clipSeq);
MaleBody.animateSkin(0, 0);
MaleBody.applyAnimation();


And this is the createSkinClip method :

I'm just planning to rotate the shin of my character with 90 degrees and, then back to the init position.

Code: [Select]

private SkinClip createSkinClip() {

        List<JointChannel> jointChannels = new ArrayList<>();
        Joint shin = skeletonHelper.getJoint("shin.L");
        int animationLength = 3;

        SimpleVector jointStartDirection= skeletonHelper.getBoneDirection(shin);
        SimpleVector jointEndDirection =  new SimpleVector(jointStartDirection);
        jointEndDirection.rotateX((float) (Math.PI / 2));

        Quaternion quat = new Quaternion();
        quat.fromVectorToVector(jointStartDirection, jointStartDirection);
        Quaternion quat2 = new Quaternion();
        quat.fromVectorToVector(jointStartDirection,jointEndDirection);
        Quaternion quat3 = new Quaternion();
        quat.fromVectorToVector(jointEndDirection,jointStartDirection);

        float[] times = new float[animationLength];
        times[0] = 0.0f;
        times[1] = 1.0f;
        times[2] = 2.0f;
        SimpleVector[] translations = new SimpleVector[animationLength];
        translations[0] = shin.getBindPose().getTranslation();
        translations[1] = shin.getBindPose().getTranslation();
        translations[2] = shin.getBindPose().getTranslation();
        Quaternion[] rotations = new Quaternion[animationLength];
        rotations[0] = quat;
        rotations[1] = quat2;
        rotations[2] = quat3;
        SimpleVector[] scales = new SimpleVector[animationLength];
        scales[0] = new SimpleVector(1f,1f,1f);
        scales[1] = new SimpleVector(1f,1f,1f);
        scales[2] = new SimpleVector(1f,1f,1f);

        JointChannel chShin = new JointChannel(shin.getIndex(),times,translations,rotations,scales);

        jointChannels.add(chShin);

        SkinClip clip = new SkinClip(MaleBody.get(0).getSkeleton(),jointChannels);


        return clip;
    }

I added the animateSkin method to the OnDrawFrame() method, which runs at every frame.
My code look like this:

Code: [Select]
if(animtime >= 1.0f){
                animtime= 0.0f;
            }else{
                MaleBody.animateSkin(animtime,0);
                animtime+=0.01f;
            }

It is moving but it's runs on 7-10 fps, instead of 40-60 like without the animation. Am I used the animateSkin method wrong?


Thank you in advance,

Tamás O.

Pages: [1]