Armature proposal

Animation tools, character animation, non linear animation

Moderators: jesterKing, stiv

Money_YaY!
Posts: 876
Joined: Wed Oct 23, 2002 2:47 pm

Postby Money_YaY! » Tue Feb 17, 2004 1:56 am

beatabix wrote:Money_YAY! - why don't you just have a little delve around in the display code, see if you can replace the funny 3D kite things with some different OpenGL calls.

strangely enough, i'm with you on this one, I usually think you just spout a constant stream of crap.

I would prefer a proper set of 3D objects to represent a skeleton, rather than those outdated what-ama-hedrons. I want to get a sense of volume without resorting to adding another mesh in my scene.

later
BEAT



:D :D Okay true I speek alot about features and crap. But whatever it takes to get ideas made. I will poke into the code some more but I have to learn more of it before I really know what I am doing.

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Tue Feb 17, 2004 2:49 am

function draw_bone line 1352 in editarmature.c (should probably be split in editarmature and drawarmature).

Martin
Life is what happens to you when you're busy making other plans.
- John Lennon

Money_YaY!
Posts: 876
Joined: Wed Oct 23, 2002 2:47 pm

Postby Money_YaY! » Tue Feb 17, 2004 3:24 am

theeth wrote:function draw_bone line 1352 in editarmature.c (should probably be split in editarmature and drawarmature).

Martin


drawarmature.c or drawobject.c I do not have my source files downloaded right now so I am going through the web database CVS and I see no drawarmature.c but I found editarmature.c

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Tue Feb 17, 2004 4:00 am

I was merely talking to myself. I think the drawing method *should* be split from editarmature, it is not done yet.

Martin
Life is what happens to you when you're busy making other plans.

- John Lennon

Money_YaY!
Posts: 876
Joined: Wed Oct 23, 2002 2:47 pm

Postby Money_YaY! » Tue Feb 17, 2004 5:48 am

theeth wrote:I was merely talking to myself. I think the drawing method *should* be split from editarmature, it is not done yet.

Martin


Ok then, what draws the bone ? All I see is colors and alot of repeating lines of code, nothing like x2 y2 z2 and other 3d mesh cords. I am tring to figure this out piece by piece. And your help is always very much thanked.

I see this.

Code: Select all

//   Draw a line from our root to the parent's tip
   if (bone->parent && !(bone->flag & (BONE_IK_TOPARENT|BONE_HIDDEN)) ){
      float childMat[4][4];
      float boneMat[4][4];
      float tip[3], root[3];
      get_objectspace_bone_matrix(bone->parent, boneMat, 0, 1);
      get_objectspace_bone_matrix(bone, childMat, 1, 1);
      
      VECCOPY (tip, boneMat[3]);
      VECCOPY   (root, childMat[3]);
      
      if (flag & ARM_POSEMODE)
         glLoadName (-1);
      setlinestyle(3);
      glBegin(GL_LINES);
      glVertex3fv(tip);
      glVertex3fv(root);
      glEnd();
      setlinestyle(0);
   }
   
   
   /* Draw this bone in objectspace */
   delta[0]=bone->tail[0]-bone->head[0];
   delta[1]=bone->tail[1]-bone->head[1];
   delta[2]=bone->tail[2]-bone->head[2];
   length = sqrt (delta[0]*delta[0] + delta[1]*delta[1] + delta[2]*delta[2] );
   
   /* Incorporates offset, rest rotation, user rotation and parent coordinates*/
   get_objectspace_bone_matrix(bone, M_objectspacemat, 1, 1);
   
   if (!(bone->flag & BONE_HIDDEN)){
      glPushMatrix();
      glMultMatrixf(M_objectspacemat);
      
      
      if (flag & ARM_POSEMODE)
         draw_bone(flag, (bone->parent && bone->parent->flag & BONE_HIDDEN) ? (bone->flag & ~BONE_IK_TOPARENT) : (bone->flag), *index, bone->name, length);
      else
         draw_bone(flag, (bone->parent && bone->parent->flag & BONE_HIDDEN) ? (bone->flag & ~BONE_IK_TOPARENT) : (bone->flag), -1, bone->name, length);
      glPopMatrix();
   }
   (*index)++;

   /* Draw the children */
   for (cbone= bone->childbase.first; cbone; cbone=cbone->next){
      draw_bonechildren (cbone, flag, index);
   }
}

static void draw_bone (int armflag, int boneflag, unsigned int id, char *name, float length)
{
   float vec[2];
   float   bulge;
   float   pointsize;
   /*
   FIXME: This routine should probably draw the bones in screenspace using
   the projected start & end points of the transformed bone
   */
   
   pointsize = length;
   if (pointsize<0.1)
      pointsize=0.1;

   /*   Draw a 3d octahedral bone   */
   
   bulge=length*0.1;

   if (id!=-1)
      glLoadName((GLuint) id );

   glPushMatrix();

   /*   Draw root point if we have no IK parent */
   if (!(boneflag & BONE_IK_TOPARENT)){
      if (id != -1)
         glLoadName (id | BONESEL_ROOT);
      if (armflag & ARM_EDITMODE){
         if (boneflag & BONE_ROOTSEL)
            cpack (B_YELLOW);
         else
            cpack (B_PURPLE);
      }
      draw_boneverti (0, 0, 0, pointsize, 0);
   }


theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Tue Feb 17, 2004 7:19 am

This:

Code: Select all

      glBegin(GL_LINES);
      glVertex3fv(tip);
      glVertex3fv(root);
      glEnd();

and all similar pieces.

Martin
Life is what happens to you when you're busy making other plans.

- John Lennon

Monkeyboi
Posts: 561
Joined: Tue Nov 26, 2002 1:24 pm
Location: Copenhagen, Denmark
Contact:

Postby Monkeyboi » Tue Feb 17, 2004 2:16 pm

theeth wrote:glBegin(GL_LINES);
glVertex3fv(tip);
glVertex3fv(root);
glEnd();


Uh-hu? Seems a little too simple to me. Sometimes when I look into code I almost think I understand, other times it just seems like nonesence to me. It seems that the code is often relating to other parts or different files which makes it hard to understand. I guess I should just look at it more, I might get it eventually.

Money_YaY!
Posts: 876
Joined: Wed Oct 23, 2002 2:47 pm

Postby Money_YaY! » Tue Feb 17, 2004 3:06 pm

Monkeyboi wrote:
theeth wrote:glBegin(GL_LINES);
glVertex3fv(tip);
glVertex3fv(root);
glEnd();


Uh-hu? Seems a little too simple to me. Sometimes when I look into code I almost think I understand, other times it just seems like nonesence to me. It seems that the code is often relating to other parts or different files which makes it hard to understand. I guess I should just look at it more, I might get it eventually.


Same here, I was expecting different code , oh well, will try today.

lightning
Posts: 52
Joined: Sat May 17, 2003 9:06 pm

Postby lightning » Tue Feb 17, 2004 3:25 pm

You guys might want to look at the docs Jesterking posted somewhere... He says that he rendered them with doxygen and they supposedly have loads of stuff for people getting into the code
The dawn of a new error...

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Tue Feb 17, 2004 4:14 pm

That piece of code draws a line from the triple-float coordinates tip to the triple-float coordinates root. You can't really get more simpler than that.

Martin
Life is what happens to you when you're busy making other plans.

- John Lennon

jesterKing
Site Admin
Posts: 1848
Joined: Fri Oct 18, 2002 12:48 pm
Location: Finland

Postby jesterKing » Tue Feb 17, 2004 4:37 pm

lightning wrote:You guys might want to look at the docs Jesterking posted somewhere... He says that he rendered them with doxygen and they supposedly have loads of stuff for people getting into the code


But don't forget it is a "mere" crossreference (which took 4 days to get rendered). So don't expect any indepth analyses of code!

/jesterKing

beatabix
Posts: 73
Joined: Fri Oct 18, 2002 1:12 am

Postby beatabix » Tue Feb 17, 2004 6:52 pm

OK Money,
here is a little explanation of some of the code. Please bear in mind that C is not a language that i'm very familiar with, and i haven't delved in OGL for about half a year.

this is the part of the draw_bone function that draws the kite shaped thingamy-hedrons:

Code: Select all

   /*   Section 1*/
   glBegin(GL_LINE_STRIP);
   vec[0]= vec[1]= 0;
   glVertex2fv(vec);
   
   vec[0]= -bulge; vec[1]= bulge;
   glVertex2fv(vec);
   
   vec[0]= 0; vec[1]= length;
   glVertex2fv(vec);
   
   vec[0]= bulge; vec[1]= bulge;
   glVertex2fv(vec);
   
   vec[0]= 0; vec[1]= 0;
   glVertex2fv(vec);
   glEnd();


now, i'll try to take you through it piece by piece...
glBegin(GL_LINE_STRIP) means that we are beginning a sequence of OpenGL commands to draw something onto the screen. glEnd(), suprise suprise, signifies the end of the sequence. GL_LINE_STRIP creates a sequence of connected lines from point to point. Everthing in between is executed when the screen is refreshed, or whatever.

vec[0]= vec[1]= 0; then glVertex2fv(vec); sets the start of the line strip to the root of the bone. vec is an array with two values, both initially set to 0, the root.

Now, I know what you're thinking - isn't this 3D? how can the shape be displayed with only 2 values?

Well, lines are of course 2D, so can only take 2 values per vertex (glVertex2fv() - an OpenGL vertex with 2 floating point values). The depth comes from the matrix, i think. This sort of stuff always messed me up with OGL, which is why i stopped attempting to program.

Anyway, next comes vec[0]= -bulge; vec[1]= bulge; glVertex2fv(vec);. The bulge value is established earlier in the function, related to the length of the bone (bulge=length*0.1;). Draw a line from the first point (0,0), to the second (-bulge, bulge).

It should be obvious what happens next. Line to the tip, back up to the opposite bulge, then finally to the root. et voila! half of our octahedron is complete.

you can follow the function along as it draws the other parts (tip -> do some reading on the GL transform functions on www.opengl.org).
From there, you're on your own, Mr Money.

There are plenty of things you can do to play around. For example, try changing the line bulge=length*0.1 to a lower value, like *0.05, to make the bones really skinny, like in other apps.

please take all of this with a pinch of salt. I am not so good with C, so this could all be complete crap.
later

ilac
Posts: 180
Joined: Mon Oct 14, 2002 8:24 am

Postby ilac » Wed Feb 18, 2004 12:52 am

beatabix wrote:here is a little explanation of some of the code.


Interesting! thanks! :D

Money_YaY!
Posts: 876
Joined: Wed Oct 23, 2002 2:47 pm

Postby Money_YaY! » Wed Feb 18, 2004 1:01 am

okay I am poking at it, The first idea I get is , can we make the current armature solid ?

The second is , I am looking for some links to data sheets to study the code, but I am turning up nil. All I can find are simple examples that others have created but they look the exact same as Blenders minus a few ball axis and emptys.
So studying these it shows theres have more features , weird. It makes mad miffed when I see people working on there own separte program when they could have worked in blender.
Like so. http://www.darwin3d.com/gdm1998.htm#gdm0598 and http://www.darwin3d.com/gdm1999.htm#gdm1099

The third is trying to find 3d box code in a draw. I know that a cube is X2 Y2 Z2 but as for drawing it I get lost.
I'M STILL learning ! Help MEeeeeeee :D

Anyhoo, pokea pokea....

beatabix
Posts: 73
Joined: Fri Oct 18, 2002 1:12 am

Postby beatabix » Wed Feb 18, 2004 11:06 am

Anything involving drawing to the screen is created in OpenGL.
Read the OGL reference manual & the OGL programming guide -

http://www.opengl.org/documentation/blue_book_1.0/
http://www.opengl.org/documentation/red_book_1.0/

To make the bones solid, my guess is that you would have to replace GL_LINE_STRIP with GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN. You could reuse the bulge variable, etc.

Now, to do this, you would also have to change the matrix used, do some transformations or whatever, but that's beyond my current ability.

later

EDIT: the forum bug has eaten my next post, so until it resolves, find it here
Last edited by beatabix on Wed Feb 18, 2004 1:45 pm, edited 1 time in total.


Return to “Animation”

Who is online

Users browsing this forum: No registered users and 1 guest