Simple skinning example?

Started by
4 comments, last by stdlib 9 years, 8 months ago

I'm using the latest version of OpenGL and SDL 2.0. Here is my current rendering code to render an object:


    for(a=0;a<obj->total_tri;a++) {
        if(!a || obj->tri[a].tex!=obj->tri[a-1].tex) {
            glBindTexture(GL_TEXTURE_2D,texture[obj->tri[a].tex]);
            glEnable(GL_TEXTURE_2D);
        }
        glBegin(GL_TRIANGLES);
            glTexCoord2f(obj->vt[obj->tri[a].vt1].u,obj->vt[obj->tri[a].vt1].v);
            glNormal3f(obj->vn[obj->tri[a].vn1].x,obj->vn[obj->tri[a].vn1].y,obj->vn[obj->tri[a].vn1].z);
            glVertex3f(obj->v[obj->tri[a].v1].x,obj->v[obj->tri[a].v1].y,obj->v[obj->tri[a].v1].z);

            glTexCoord2f(obj->vt[obj->tri[a].vt2].u,obj->vt[obj->tri[a].vt2].v);
            glNormal3f(obj->vn[obj->tri[a].vn2].x,obj->vn[obj->tri[a].vn2].y,obj->vn[obj->tri[a].vn2].z);
            glVertex3f(obj->v[obj->tri[a].v2].x,obj->v[obj->tri[a].v2].y,obj->v[obj->tri[a].v2].z);

            glTexCoord2f(obj->vt[obj->tri[a].vt3].u,obj->vt[obj->tri[a].vt3].v);
            glNormal3f(obj->vn[obj->tri[a].vn3].x,obj->vn[obj->tri[a].vn3].y,obj->vn[obj->tri[a].vn3].z);
            glVertex3f(obj->v[obj->tri[a].v3].x,obj->v[obj->tri[a].v3].y,obj->v[obj->tri[a].v3].z);
        glEnd();
    }

This renders objects correctly, but I am going to need to implement vertex buffer objects or whatever the most recent thing is. However, I will also need to implement skeletal animation.

All of the tutorials that I find do not do anything at a low level in C, and they make use of various libraries. Since I am using a custom format, though, these libraries will not be of much use.

Can anyone link to a simple tutorial that can explain this? What must be done is simple. There are two bones. The first bone rotates the entire object, while the second bone rotates half of the object. Skinning is to be used so some vertices from the second object stay at the end of the first object, like a snake.

A simple example using an object composed of two rectangles and with all of the values hard-coded will do. Thanks!

Advertisement

I would say don't bother with skeletal animation for now and just convert what you have already to using VBO's, as this could be a large chunk of work.

Once you have your code in a stable condition using the new approach then start to look at implementing skeletal animation.

JB

Thanks for the reply! I have been looking into VBOs, but I can't seem to incorporate this code without a crash occurring: http://www.opengl.org/wiki/VBO_-_just_examples

For now, it loads .obj files into a format that can be used to export to any format, so loading into a VBO would be simple if I could find a good VBO example. What I linked to seems to be simple, but it is crashing for me on the "glDrawElements" line. Most of the VBO examples I find are either incomplete code, or ten different header files that utilize over five libraries.

Do you have any links to concise code like this?: http://openglsamples.sourceforge.net/triangle.html

Thanks!

Personally I used http://open.gl/drawing . The tutorials and examples are very well set out and explained thoroughly.

If you are struggling to get it implemented with your current code then create a much simpler case and maybe just output some predefined triangles as shown on the website.

hope this helps

JB

If you are using glVertex3f and friends, then you are *not* using the latest version of OpenGL. You are, in fact, using legacy OpenGL. Jordan already beat me to it (darn you sir) and I do recommend his link.

If you prefer to use legacy OpenGL (2.1) over core OpenGL (3.0+), then okay. Occasionally, there may be a good reason for using legacy OpenGL. For my latest title, I used legacy OpenGL to keep portability to OpenGL ES 2.0 easy (but it was still a mistake I regret).

If you need a tutorial on bone animation, check out this these:

http://www.codesampler.com/oglsrc/oglsrc_11.htm#ogl_skinning

http://content.gpwiki.org/index.php/OpenGL:Tutorials:Basic_Bones_System

http://prideout.net/blog/?p=56

Hope this helps,

Shogun.

Thanks! These are very useful! I actually wrote an animation tool a while back that utilized CPU skinning, which was slow and glitchy, so I'm mostly just looking for skinning examples. This (http://www.codesampler.com/oglsrc/oglsrc_11.htm#ogl_skinning) is exactly what I was looking for recently, thanks! I found it a long time ago, but I couldn't seem to find it again until you linked to it. Thanks!

This topic is closed to new replies.

Advertisement