View Full Version : Attach joints to other joints programmatically

16-08-2012, 09:02 PM

i'm experimenting some coding with Delphi and GLScene. So far i managed to load an SMD model and various animations: I don't have a particular project in mind, but i'm amazed by the simplicity and power of this framework. The next step i'm trying to accomplish is to load a weapon and attach it to my character's hand at runtime.
Both the character's hand and the sword have a joint, but i don't know how to get them together.

I already tried to use something like WeaponActor.Matrix := CharActor.Skeleton.BoneByName('Weapon_R_Bone').Glo balMatrix but that's not what i'm looking for.

http://i47.tinypic.com/2czu0wo.png (http://i47.tinypic.com/2czu0wo.png)

The hilt of the sword, which contains the bone "Sword_Hilt", should be in the character's hand "Weapon_R_Bone".

I searched inside the source code of the libraries for something like "AttachToBone" to no avail ???

Does anyone know how to attach joints programmatically in GLScene? :-[

25-08-2012, 01:57 PM
An update for the post above, i managed to correctly handle the sword's movement by commenting the "Syncronize" part and calculating the Matrix of the weapon's actor in the OnProgress event of the Cadencer


Procedure TFormProgramma.AggiornaPosizioneArma(Sender: TObject; const deltaTime, newTime: Double);
MatriceArma: TMatrix4f;
//if i simply use something like
//Arma.Matrix := Actor.Skeleton.BoneByName('Weapon_R_Bone').GlobalM atrix;
//the sword's hilt assumes the right rotation, but wrong position as it floats just
//above the hand's bone, so i look for another bone as a reference for the right
//coordinates: the Bip01_R_Finger0Nub seems to be the right choice
MatriceArma[0] := Actor.Skeleton.BoneByName('Weapon_R_Bone').GlobalM atrix[0];
MatriceArma[1] := Actor.Skeleton.BoneByName('Weapon_R_Bone').GlobalM atrix[1];
MatriceArma[2] := Actor.Skeleton.BoneByName('Weapon_R_Bone').GlobalM atrix[2];
MatriceArma[3] := Actor.Skeleton.BoneByName('Bip01_R_Finger0Nub').Gl obalMatrix[3];
Arma.Matrix := MatriceArma;

26-08-2012, 11:08 PM
Looking good! :) Glad you worked it out...