Anyone have an idea how to make bone animation?
Mind you I’ve only been coding OpenGL for three days so I might be totally off here.
You could have an object, a bone, which contains a couple of children, and a 4x4 matrix. Plus, of course, the faces it affects.
When you render the whole thing you start with the parent bone and apply the transformations of that, then you traverse all its children and which will traverse its children and so on, each time pushing the matrix stack and multiplying its own matrix by the current matrix.
So the bone-object should do the following:
glMatrixMultiply(M); //where M is its matrix
You start the rendering by simply calling the CBones::execute for the parent. CBones::RenderMe() is supposed to render all tris that are connected to the curren bone.
Oh and of course. You need to find a good way of initializing the tranformations matrices for all the bones (by a good exporting utillity from Character Studio or similar). Naturally.
As I said. I’m new to 3D-programming alltogether. I might have this all wrong but this is how I understand it from what I’ve read.
[This message has been edited by Caesar (edited 06-24-2000).]
Ever tried inverse kinematics?
Just a thought
I know what IK is, but I have NO idea how to implement it. My idea for a bone-animation was a simple memory-saver. If it would work that is =)
I haven’t been able to try my theory for myself, since I can’t even put a model (exported from 3DS or similar) in my scene (this is my fourth day of coding ogl) heh =).
Ok Caesar, this can work,but i think this:
You idea can work for a model composed separated 3D object. If you are an object enterely composed by a triangle? Look at every bot in all 3d game, it are an 1 object.
You algoritm can work but it need to expanded to contro triangle that refer to it, but this triangle are connected to triangle that are joined to another bone…
I’m think about that.
Thanks for help to every body
Hi what you are talking about is not Bones exactly, but skinning.
This is much more difficult, because each vertex got a weight of the Bones and then you have to multiply both bones to each vertex and ‘blend’ the position depending on the weight:
You have an vertex (may be on the elbow) He is part of Bone1 40 %(Upper Arm) and Bone2 60% (Lower Arm) Now you multiply the Vertex twice: first with Matrix of Bone1 and then with matrix of bone2(which is dependant of bone1, because bone2 is a child of bone1)
You got 2 results and you have to find the result like this:
ResultVertex=40%Bone1V + 60%Bone2V
I didn’t code this by myself, but on http://www.gdmag.com is a good tutorial about this issue 5/98 and Bones (I think)1 or 2 issues earlier
I have seen that someone use to get the trasfor matrix with get… function and alter it with proper function that resed it on opengl function.
Can you explain me ho do it well?
If i use bone, for example, i must associate one matrix at every bone, but first i must set the origin of this matrix to the joint position of the 2 bones.
How can od this.
Thanks in advanced peter
You have to use glPushMatrix() and glPopMatrix() …
You have to position your main Object(the father of all Bones eg the chest of a human body)
with the normal OpenGL-Statements glTransform(), glRotate()…
then you have to glPushMatrix() the matrix on the Matrix stack, remembering it for later… now you can transform the left arm relativ to the chest, elbow, wrist… when you come to the right arm, you want to place it relativ to your chest, right? not th the left wrist, where you actual are. Thats why you choose glPopMatrix(), to reset the matrix to this ‘Place’ (actually it is an orientation/place), where you starts (remember the glPushMatrix() So you can traverse your right arm… then your head, and legs. If your hierachy splits again( eg Hands depends on 5 fingers) then you have to push this Matrix again to the matrix stack.
[This message has been edited by PeterParker (edited 06-27-2000).]
Ok peter, this function put and get matrix from the “matrix internal list”, but i would know if, when i push a matrix, are the other transform and rotate operation relative to the pushed matrix?
And if i whant rotate an object relative an his vertex?
Thanks in advanced.
Lots of bonemovement can be found at http://darwin3d.com/gamedev
There is also a source for skeleton deformation: http://darwin3d.com/gamedev/gdm1099.zip
But i would to use a 3dstudio model, coz all the IK information are already builded.
Its possible ???
How can i do that ??