About Store Forum Documentation Contact



Post Reply 
Skeleton
Author Message
Seba Offline
Member

Post: #1
Skeleton
In character, skeleton is automatically joined with mesh. How join skeleton with mesh. I create extend structure. Have mesh, CSkeleton, but i can't move skeleton to mesh. I see skeleton in center of the map and i can move mesh to skeleton but can't move and attach skeleton to mesh.
08-05-2010 10:13 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Skeleton
I don't understand, please try look in tutorials "animation"
if that wont help please paste your codes
08-05-2010 10:23 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #3
RE: Skeleton
Ok i look to tutorials and now i found the solution. Srry fo trouble. My mistake.
08-05-2010 10:49 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #4
RE: Skeleton
1) I have skeleton in my Item. I create it using this code:
Quote:skeleton->create(*obj.skeleton());
Then i wan't to transforme one bone from character skeleton using this skeleton. I use to this transformation that code in Player::update():
Quote: if(inv.slot[SLOT_ARM_R].valid())
{
if(OrientP *weapon=inv.slot[SLOT_ARM_R]().skeleton->findPoint("secondHand"))
{
cskel.clear();
cskel.transformInWorldSpace(cskel.findBoneI("HandL"),Matrix().setPos(weapon->pos)/*.setPosDir(weapon->pos,weapon->perp,weapon->dir)*/,true);
//cskel.updateMatrix(matrix())
//.updateVelocities();
}
}
But this bone from character is in different position than point in my item skeleton.

2) When i draw Item::skeleton i didn't see it with mesh. Did i need transform it manually?

3) Why if i have Item in hand the update function didn't run?
08-06-2010 08:42 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Skeleton
did you look at Bloody Massacre? there's holding items in hand, and adjusting the bones matrixes
08-07-2010 12:10 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #6
RE: Skeleton
I look i have item placed in hand like in BM. But i have skeleton in my ITEM, and i need position of one point in this skeleton to try put second hand in this position. But when i get point position and update Chr::cskel the hand didn't go to the correct position. Hand is placed in different position.
Quote: if(OrientP *weapons=weapon.cskel.findPoint("secondHand"))
{
cskel.clear();
cskel.transformInWorldSpace(cskel.findBoneI("HandR"),Matrix().setPos(weapons->pos),true);
}
cskel.updateMatrix(ctrl.actor.matrix()) // update all matrixes
.updateVelocities(); // update all bone velocities

When i use code to place bullet nothing change. Hand is in the same position.
08-07-2010 02:10 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #7
RE: Skeleton
Ok i made some improvements but i don't know why
Quote:void PLAYER::animateUpdateMatrix(Matrix &body_matrix)
Didn't executed. In BM I didn't found any external code to make it work.
08-07-2010 06:34 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #8
RE: Skeleton
(07-07-2010 10:32 PM)Esenthel Wrote:  -IMPORTANT: Vec, Matrix and other mathematical objects are now passed as "const type &x" (instead of old "type &x") to comply with GCC compiler for upcoming Mac/iPhone/iPad ports (please revise your codes, especially custom game object classes and their virtual method overriding to match parameter declarations as in base class methods)

You're missing the const. Same thing happened to me when it got changed.

Code:
void PLAYER::animateUpdateMatrix(C Matrix &body_matrix)
08-07-2010 07:54 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #9
RE: Skeleton
This work now. But i can't transform Player::cskel HandL to place where Item::skeleton point is. I use this code any advice?
Quote: if(inv.slot[SLOT_ARM_R].valid())
{
if(SkelPoint *point33=inv.slot[SLOT_ARM_R]().skeleton->findPoint("secondHand"))
{
Vec skelPos;
skelPos=point33->pos/**inv.slot[SLOT_ARM_R]().matrixScaled()*/;
cskel.clear();
cskel.transformInWorldSpace(cskel.findBoneI("HandL"),Matrix().setPos(skelPos),true);
}
}
This code is placed in:
Quote:void PLAYER::animateUpdateMatrix(C Matrix &body_matrix)
08-07-2010 09:33 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #10
RE: Skeleton
How to use:
Quote:cskel.transformInWorldSpace(sac.hand_l,transform,true);

I want to transform position of the bone by position of my point in Item::skeleton. The point is in good position but hand don't want to move to that point why?

Use that code:
Quote: if(SkelPoint *point33=inv.slot[SLOT_ARM_R]().skeleton->findPoint("secondHand"))
{
skelPos=point33->pos*inv.slot[SLOT_ARM_R]().matrixScaled();
Matrix transform; transform.setPos(skelPos);
cskel.transformInWorldSpace(sac.hand_l,transform,true);
}
Placed in:
Quote:void PLAYER::animateUpdateMatrix(C Matrix &body_matrix)
(This post was last modified: 08-08-2010 09:43 PM by Seba.)
08-08-2010 09:42 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: Skeleton
paster your full code of void PLAYER::animateUpdateMatrix(C Matrix &body_matrix)
check in debugging if
skelPos=point33->pos*inv.slot[SLOT_ARM_R]().matrixScaled();
Matrix transform; transform.setPos(skelPos);
cskel.transformInWorldSpace(sac.hand_l,transform,true);

gets executed
08-09-2010 10:05 AM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #12
RE: Skeleton
Code:
Quote:void PLAYER::animateUpdateMatrix(C Matrix &body_matrix)
{
__super::animateUpdateMatrix(body_matrix); // call default setting skeleton matrix

// now skeleton matrixes are set to their final positions, and we can access their positions and orientations in world space
// we'll use it for inverse kinematics - orienting weapons to face them towards the player looking direction

Vec &desired_dir=cskel.getPoint("head").dir; // this is the desired weapon direction in world space

if(inv.slot[SLOT_ARM_L].valid()) // if has item in left hand
{
if(OrientP *point=cskel.findPoint("HandL"))
{
Vec current_dir=-point->cross(); // this is the current weapon direction in world space
Matrix3 transform; transform.setRotation(current_dir,desired_dir,1); // create matrix which transforms current direction into desired direction
cskel.transformInWorldSpace(sac.arm_lu,transform); // call this method to perform a world space transformation
}
}
if(inv.slot[SLOT_ARM_R].valid()) // if has item in right hand
{
if(OrientP *point=cskel.findPoint("HandR"))
{
Vec current_dir=-point->cross(); // this is the current weapon direction in world space
Matrix3 transform; transform.setRotation(current_dir,desired_dir,1); // create matrix which transforms current direction into desired direction
cskel.transformInWorldSpace(sac.arm_ru,transform); // call this method to perform a world space transformation
}
if(SkelPoint *point=inv.slot[SLOT_ARM_R]().skeleton->findPoint("secondHand"))
{
skelPos=point->pos*inv.slot[SLOT_ARM_R]().matrixScaled();
Matrix transform; transform.setPos(skelPos);
cskel.transformInWorldSpace(sac.arm_lu,transform,true);
}
}
}

This part of code execute. I attach some screens. Red dot should be placed in skeleton position:
[Image: svst.th.jpg]
[Image: szkieletm16.th.jpg]
08-09-2010 11:16 AM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #13
RE: Skeleton
Now i placed red dot in right position. But hand didn't transform to that place.
08-09-2010 05:02 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #14
RE: Skeleton
if(SkelPoint *point=inv.slot[SLOT_ARM_R]().skeleton->findPoint("secondHand"))
{
skelPos=point->pos*inv.slot[SLOT_ARM_R]().matrixScaled();
Matrix transform; transform.setPos(skelPos);
cskel.transformInWorldSpace(sac.arm_lu,transform,true);
}

is this causing the error?
'transform' is relative transformation to apply on already animated bone, it's a little bit more complex then set position and expect the bone would go there
08-09-2010 07:25 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #15
RE: Skeleton
This part of code works but transformation that is used there didn't put hand in right position.

Quote:it's a little bit more complex then set position and expect the bone would go there

Any advice, or i have to try all idea i have?
I want make Inverse Kinematics using that function.
08-09-2010 07:36 PM
Find all posts by this user Quote this message in a reply
Post Reply