Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Getting Bone's world position?
Topic Started: Mar 26 2009, 01:37 PM (439 Views)
Satyr
Member Avatar
Captain Gobblecoque
[ *  *  *  *  *  * ]
Hey all, I have been working on a little zombie shooter, and i have a bone for muzzle flashes and light in my view model for my gun, but i do not know how to get the x,y and z of that bone.

i looked at the align weapon to hand example, but it looks like it involves setting up a transformation matrix and adjusting the values until they are correct, which is not really what i had in mind, specially if i want multiple weapons.

any help would be appreciated, thanks.
The feeling of homesickness never goes away when you return to your parents home from years of being away.

same goes with the smell of ash and smoke from the day you set it ablaze.
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Try the following:
Code:
 
var BoneIndex,BoneMatrix,PosVect,BoneX,BoneY,BoneZ;

BoneIndex=GetBoneIndex("bone name");
BoneMatrix=GetBoneTransformation(-1,BoneIndex);
PosVect=ComputeMatrixTranslation(-1,BoneMatrix);
BoneX=GetVector(PosVect,1);
BoneY=GetVector(PosVect,2);
BoneZ=GetVector(PosVect,3);

ReleaseMatrix(BoneMatrix);
ReleaseVector(PosVect);
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Satyr
Member Avatar
Captain Gobblecoque
[ *  *  *  *  *  * ]
Due to the circumstances of me loosing my entire project folder. I cant really check to see what it does.

Plus the code doesn't really make too much sense, because of the matrix and vector usage, which i have not used ever.

so can you explain what happens through the code, shouldn't be too hard, and would help this small child rest in peace wrapped up in the new found knowledge as to how to use vectors and matrices. :P

Give a programmer a snippet, fill one space in a project, Teach the programmer how to make the snippet, fill that space in unlimited amounts of projects.
The feeling of homesickness never goes away when you return to your parents home from years of being away.

same goes with the smell of ash and smoke from the day you set it ablaze.
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
thisisagoodnameisntit
Mar 31 2009, 01:51 PM
Due to the circumstances of me loosing my entire project folder. I cant really check to see what it does.

Plus the code doesn't really make too much sense, because of the matrix and vector usage, which i have not used ever.

so can you explain what happens through the code, shouldn't be too hard, and would help this small child rest in peace wrapped up in the new found knowledge as to how to use vectors and matrices. :P

Give a programmer a snippet, fill one space in a project, Teach the programmer how to make the snippet, fill that space in unlimited amounts of projects.
Yes, I should have explained a bit more, so I'll try to do that now ^_^ .
Code:
 
var BoneIndex,BoneMatrix,PosVect,BoneX,BoneY,BoneZ;

//get the index of the bone...
BoneIndex=GetBoneIndex("bone name");
//...which is needed to retrieve its transformation matrix,
//which describes its position, orientation and scaling
BoneMatrix=GetBoneTransformation(-1,BoneIndex);
//since the location of the bone origin is needed, it is
//extracted from the transformation matrix as a vector,...
PosVect=ComputeMatrixTranslation(-1,BoneMatrix);
//...whose components are the coordinates of that location
BoneX=GetVector(PosVect,1);
BoneY=GetVector(PosVect,2);
BoneZ=GetVector(PosVect,3);

ReleaseMatrix(BoneMatrix);
ReleaseVector(PosVect);

So you need the name of the bone you're using (which you gave it in your modelling program), to get access to its transformation matrix. This matrix contains information about its location, orientation and scaling.
Since all you need to know is the position (x,y,z) of the bone, you use ComputeMatrixTranslation(...) which gives you just that, as a vector. The components of that vector (which you get using GetVector(...)) are the x, y and z of the bone, respectively.

Better ;) ?

A deeper explanation of vectors and matrices is beyond the scope of my job description :P .
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Satyr
Member Avatar
Captain Gobblecoque
[ *  *  *  *  *  * ]
thanks for the help dude, got it working. pretty understandable now =D
The feeling of homesickness never goes away when you return to your parents home from years of being away.

same goes with the smell of ash and smoke from the day you set it ablaze.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply