# Vector representation VS Angle representation

8 replies to this topic

### #1rouncer

Senior Member

• Members
• 2725 posts

Posted 24 September 2010 - 08:39 AM

Im talking about skinning models. As in rigging them for animation.
(I reckon the whole industry is stupid, you should call it "rigging" not "skinning")

Like how do I limit the head rotation so it cant spin all the way around facing backwards.

If I do it with a vector stick man, then how am I supposed to restrict the bone.

I am indeed in knowledge that if I used a rotational angle tree I would be able to limit it between two scalars... its just I wanted to work with vectors.

Note my stickmen are just vertices and lines connecting them, then I bind the model with orientation matrices so it acts to the skeleton.
This gives me ragdoll physics, its just now im stuck in vector representation and I dont know what to do...

Id perhaps want mouselook in an first person situation, but I dont want you to be able to mouselook all the way around, and what if the body changes angles, id want to keep the head so it couldnt spin back.

I realize if I did it with an angle heirarchy this would work, but then I possibly couldnt direct the head in the look vector.
[EDIT] turned out I could [/EDIT]

So whats a solution?
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #2rouncer

Senior Member

• Members
• 2725 posts

Posted 24 September 2010 - 08:47 AM

Dont tell me itll take measuring angles from vectors, holy crap.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #3rouncer

Senior Member

• Members
• 2725 posts

Posted 24 September 2010 - 08:53 AM

Oh who cares, I know how to fix it now... I just have to measure the x of the vector and the y of the vector, and convert it to rotations.

Then I could go from there.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #4rouncer

Senior Member

• Members
• 2725 posts

Posted 24 September 2010 - 08:55 AM

Oh hang on I figured it out.

I just link the mouse vector to the actual body direction, then I can limit it to angles yes, Then when the body moves right I just move the look left.

Then I can restrict it to the shoulders.

So I guess the moral of this story is maybe you should use a bit of both.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #5.oisyn

DevMaster Staff

• Moderators
• 1842 posts

Posted 24 September 2010 - 09:25 AM

rouncer said:

Im talking about skinning models. As in rigging them for animation.
(I reckon the whole industry is stupid, you should call it "rigging" not "skinning")
Rigging is the process of defining a skeleton and assigning vertices to them. Skinning is the process of transforming the verts using the bone matrices. I have never seen those words used differently.

Anyway, you should read up on joint constraints. Angles aren't that useful either, as they only let you constraint the rotations on the X, Y and Z axis, and not on arbitrary axes. What you could do, is defining a constraint as an axis and a minimum and maximum value. You dotproduct the axis with the bone direction, and the result should be between min and max.
-
Currently working on: the 3D engine for Tomb Raider.

### #6rouncer

Senior Member

• Members
• 2725 posts

Posted 24 September 2010 - 10:09 AM

Whats it got to do with whats on the skin anyway? I thought "skinning" was more to do with sub surface scattering.

Guess what this does, it sets instance.si[1], which happens to be if the object spins left or right. only problem is, if you measure an angle of a vector to go left is to go to the nearest left, which could be right the complete other way on the circle... so this bit of logic picks the least difference, 2 ways to go around the circle and outputs "right" and "left."

   float angle1,angle2;

angle1=atan2(instance[j].walkvector.z,instance[j].walkvector.x);
angle2=atan2(actualvector.z,actualvector.x);

if(angle2<angle1)
{
if(angle2-angle1<(6.28f-angle2)+angle1) instance[j].si[1]=1; else instance[j].si[1]=2;
}
else
{
if(angle1-angle2<(6.28f-angle1)+angle2) instance[j].si[1]=2; else instance[j].si[1]=1;
}


you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #7rouncer

Senior Member

• Members
• 2725 posts

Posted 24 September 2010 - 10:16 AM

Shit, what you said made me think tho - so theres better ways than just YawPitchRoll matrices?
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #8rouncer

Senior Member

• Members
• 2725 posts

Posted 24 September 2010 - 10:46 AM

ehm excuse me

   if(angle2<angle1)
{
if(angle1-angle2<(6.28f-angle1)+angle2) instance[j].si[1]=1; else instance[j].si[1]=2;
}
else
{
if(angle2-angle1<(6.28f-angle2)+angle1) instance[j].si[1]=2; else instance[j].si[1]=1;
}


modification. :)
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #9.oisyn

DevMaster Staff

• Moderators
• 1842 posts

Posted 24 September 2010 - 11:00 AM

rouncer said:

Whats it got to do with whats on the skin anyway?
You pull the skin (the mesh) over the bones. Much like skinning an animal, although the other way around.

Quote

I thought "skinning" was more to do with sub surface scattering.
No it has nothing to do with that. That's just skin rendering.

rouncer said:

Shit, what you said made me think tho - so theres better ways than just YawPitchRoll matrices?
Why yaw-pitch-roll matrices if you could simply use general matrices. And some use quaternions, which are faster to multiply than matrices, which is especially handy in the hierarchical nature of skeletons.