Jump to content

  • Log In with Google      Sign In   
  • Create Account


Errors displaying MD5MESH file in Java


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 CyanPrime   Members   -  Reputation: 104

Like
0Likes
Like

Posted 18 January 2012 - 05:40 PM

I've been working on creating a MD5 model viewer in Java, and while I've managed to read the data, and format it I can't for the life of me figure out why I can't display it properly. I'm following the instructions here. but it's just giving me a garbled mess. Can anyone help me? First I'd like to post the important parts of my code:

private void render(){
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT |
        GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glLoadIdentity();

        GL11.glTranslatef(0, 0, -500);
        GL11.glColor3f(1.0f, 1.0f, 1.0f);//white
        int meshNum = 0;
        texture.bind();
        GL11.glBegin(GL11.GL_TRIANGLES);
        for(int i = 0; i < model.meshes.get(meshNum).numTris; i++){
            Tri t = model.meshes.get(meshNum).tris.get(i);

            GL11.glTexCoord2f(0,0);     GL11.glVertex3f(model.vertices.get(t.vert1).x,model.vertices.get(t.vert1).y,model.vertices.get(t.vert1).z);
            GL11.glTexCoord2f(1,0);     GL11.glVertex3f(model.vertices.get(t.vert2).x,model.vertices.get(t.vert2).y,model.vertices.get(t.vert2).z);

            GL11.glTexCoord2f(1,1);     GL11.glVertex3f(model.vertices.get(t.vert3).x,model.vertices.get(t.vert3).y,model.vertices.get(t.vert3).z);

        }
        GL11.glEnd();
    }

And

public void computeVertices(Mesh m){
        for(int i = 0; i < m.numVerts; i++){
            Vector3f pos = new Vector3f(0,0,0);
            int start = m.verts.get(i).weightIndex;
            int count = m.verts.get(i).weightElement;

            for(int j = count; j < count + start; j++){
                Joint  joint = joints.get(m.weights.get(j).jointIndex);
                Vector3f temp = joint.pos;
                Vector3f wt = applyQuat(m.weights.get(j).pos, joint.orient);
                Vector3f.add(temp, wt, temp);
                temp.scale(m.weights.get(j).value);
                Vector3f.add(pos, temp, pos);
            }

            vertices.add(pos);
        }
    }


My blog I set up just now has more links, like the full source code, and what not. I don't want to link all those links here cause I think it'd be too many links, so I'll just direct you to here if you need more info.

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS