PDA

View Full Version : Can one translate a single vertex?



CodeFoo
07-28-2010, 12:55 PM
So basically, I am looking for a way to cheat at skinning my model since I understand the concepts but not the implementation of doing it the legitimate way. Currently I have my skin in Blender and can export coords as .raw just fine, and my hierarchical skeleton is in openGL (C++).

My idea is simple, most likely overly so:

I can line up my Blender skin coords with my skeloten joints with some fancy checking algorithms and essentially map every vertex to one bone, and now i want to say "every skin vertex associated with this bone, move with that bone's hierarchical transforms."

This works all well and good EXCEPT when i get to the dividing line of the joint. My problem boils down to the fact that i'd LIKE to do something like the following:




glBegin(GL_QUADS);
glVertexf(top-right...);
glVertexf(bottom-right...);
glPushMatrix();
glRotatef(joint_angle);
glVertex(top-left);
glVertex(bottom-left);
glPopMatrix();
glEnd();


Which compiles but doesn't seem to do anything other than giving me the initial rectangle when I try it on a much smaller scale than an entire skin mesh.

Any ideas? I realize that even if i get this working as I want it will be a pretty lame approximation of true skinning, which is the end goal. So if anyone knows of any beginner-intermediate resources for skinning, preferably related pretty closely to openGL (concrete examples would be nice), that'd be appreciated.

Also, if it ends up that the whole package would be easier done in Blender alone, please let me know so I do not waste undue amounts of time. My professor is sort of married to openGL but at the end of the day a usable model is more important than any program preference.

kyle_
07-28-2010, 01:06 PM
http://www.opengl.org/sdk/docs/man/xhtml/glPushMatrix.xml

"GL_INVALID_OPERATION is generated if glPushMatrix or glPopMatrix is executed between the execution of glBegin and the corresponding execution of glEnd."

Rosario Leonardi
07-28-2010, 01:24 PM
You can't use push/popMatrix inside begin/end block. The matrix is an attribute that have the same value for the mesh. You can't transform some vertex with a matrix and other vertex with another matrix.
If you want to do that you must draw more than one mesh.

Basically you are saying that you have one mesh with some basic skinning, with only one move for vertex.
You must use a vertex shaders. You can pass the matrix as uniform, and then use a vertex attribute to select the right matrix.

ps: in this simple case you also consider software skinning

CodeFoo
08-02-2010, 01:31 PM
Thanks for reply.

Should I learn vertex shaders for the Blender side and import the information to openGL or work with animation solely in openGL? Neither prospect seems particularly simple to my newbie brain...

Thanks,

-CF