0

Hey guys,

I am trying to read a skel file and create a skeleton from it, but I don't understand how to do the joint class. Here is what i have now:

this is the main class.

public static void main(String[] args) {
       // Frame frame = new Frame("Simple JOGL Application");
       // GLCanvas canvas = new GLCanvas();

      /*  canvas.addGLEventListener(new SkelProjectJOGL());
        frame.add(canvas);
        frame.setSize(640, 480);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
                // make sure the call to Animator.stop() completes before
                // exiting
                new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();*/

        String skel = "";

        try {
            byte[] buffer = new byte[(int) new File("test.skel").length()];
            BufferedInputStream f = new BufferedInputStream(new FileInputStream("test.skel"));
            f.read(buffer);
            skel = new String(buffer);
            //System.out.println("This is the file content:" + skel);
        } catch (java.io.IOException e) {
            System.out.println("Can't find test.skel");
        }

        StringTokenizer t = new StringTokenizer(skel);
        while (t.hasMoreTokens())
        {
            //Stack root_stk = new Stack();
            //if (t.nextToken().equals("balljoint") )
                System.out.println(t.nextToken());
            //System.out.println("here");
            /*if (t.nextToken().equals("root")) {
                
                if (t.nextToken().equals("{")) {
                    System.out.println(t.nextToken());
                   // while (!t.nextToken().equals("}"))
                     //   System.out.println(t.nextToken());
                        //root_stk.push(t.nextToken());
                }
            }*/

           // System.out.println(root_stk);


            //else
              //  System.out.println("No balljoint found");
        }
    }

here is the data in the .skel file:
balljoint root {
offset 0 0 0
boxmin -0.2 -0.3 -0.15
boxmax 0.2 0.3 0.15
pose 0 0.1 0
balljoint head {
offset 0 0.3 0
boxmin -0.1 0 -0.1
boxmax 0.1 0.2 0.1
}
balljoint hip_l {
offset -0.1 -0.3 0
boxmin -0.05 -0.3 -0.05
boxmax 0.05 0 0.05
balljoint knee_l {
offset 0 -0.3 0
boxmin -0.05 -0.3 -0.05
boxmax 0.05 0 0.05
}
}
balljoint hip_r {
offset 0.1 -0.3 0
boxmin -0.05 -0.3 -0.05
boxmax 0.05 0 0.05
balljoint knee_r {
offset 0 -0.3 0
boxmin -0.05 -0.3 -0.05
boxmax 0.05 0 0.05
rotxlimit -2 0
rotylimit 0 0
rotzlimit 0 0
pose -3 1 2
}
}
}

Any help please? Thanks a lot.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by emilo35
0

First of all, you have to understand what you are doing. From what I learned by googling around for a bit, I suggest you create a class named SkeletonJoint or something similar. It should have positions for each of the properties offset, boxmin, boxmax and pose (Optionally you can keep a string of it's name too). Also it should have pointers to its child nodes.

When you read the skeleton file, you can figure out the relationship between child/parent nodes by looking at the brackets. If a joint B is declared within the brackets of joint A, then joint B is a child of A.

Now, when you've read the skel-file and built a parent/child structure out of it, you are ready to operate on it. Some properties that are good to know is that whenever a node changes, it also affects its children, but not its parent.

offset = Joint's position relative to its parent
boxmin, boxmax = corners that defines the joints physical cube-representation
pose = Contains data on how to currently pose this node. You only have to assign non-zero values to this property in the skel-file if you want your skeleton to have a specific default pose. (Since you will probably want to play around with this when animating your model)
balljoint = Flags that a child joint is coming up next

Now this should pretty much round it up. If you are still unsure what to do, I suggest you step back to studying Java, Basic OpenGL operations and matrix calculus.

As for the content of this post, I reserve myself for eventual misunderstandings and even misleading statements, since I just extracted this from google.

Sources:
CSE 169: Computer Animation, University of California, San Diego
NeHe OpenGL, Article 03: Skeletal Animation, By Paul Frazee

Best of luck to you!
Emil Olofsson

0

I created a joint class, but I still don't understand the parent child relationship and I can't even create one quadric yet! This is my joint class. How do I go from here?

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.yourorghere;
import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
import java.io.*;
import java.util.*;
/**
 *
 * @author Debbie
 */
public class SkeletonJoint {
    String name = " ";
    float[] offset = new float[3];
    float[] boxmin = new float[3];
    float[] boxmax = new float[3];
    float[] pose = new float[3];

    public SkeletonJoint() {

    }

    public void setName(String Jname) {
        name = Jname;
    }

    public String getName() {
        return name;
    }

    public void setOffset(float x, float y, float z) {
        offset[0] = x;
        offset[1] = y;
        offset[2] = z;
    }

    public float[] getOffset() {
        return offset;
    }

    public void setBoxMin(float x, float y, float z) {
        boxmin[0] = x;
        boxmin[1] = y;
        boxmin[2] = z;

    }

    public float[] getBoxmin() {
        return boxmin;
    }

    public void setBoxMax(float x, float y, float z) {
        boxmax[0] = x;
        boxmax[1] = y;
        boxmax[2] = z;

    }

    public float[] getBoxmax() {
        return boxmax;
    }

    public void setPose(float x, float y, float z) {
        pose[0] = x;
        pose[1] = y;
        pose[2] = z;

    }

    public void draw() {
       // Gl gl = = drawable.getGL();
    }

    public float[] getPose() {
        return pose;
    }

}
0

I suggest you add an ArrayList or similar of type SkeletonJoint as a member of your SkeletonJoint class. This one stores all children of the current joint.

If you take a close look at your skeleton file, you will see that some joints are declared within the brackets of other joints, right? Those are the children of the joint that surrounds them. Those should be added to the SkeletonJoint ArrayList member of their parent. Then you add a method SkeletonJoint getChild(int index) and int getChildren() so that you easily can iterate over your structure.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.