Bone Point Manipulation
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
Bone Point Manipulation
Hey,
I'm wanting to access the point in between two bones (and/or at the end/start of a bone). I have no idea how to do this, any help would be appreciated.
ie.
o====o====o====o
where:
o is a point between a bone, and ==== is the bone.
i want to find the o parts (world or local coords)
Thanks in advance,
dartsman
I'm wanting to access the point in between two bones (and/or at the end/start of a bone). I have no idea how to do this, any help would be appreciated.
ie.
o====o====o====o
where:
o is a point between a bone, and ==== is the bone.
i want to find the o parts (world or local coords)
Thanks in advance,
dartsman
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
A bone is an abstract concept, it doesn't actually look like a bone. The bone definition is actually the 'joint' you see when drawing them in the modeller - the lines joining them are just to help you visualise, they are not really there.
Bones just define a space, like any node. You're inferring that the 'bone' goes from one joint to the next - what that's actually doing though is joining a bone and it's parent. If you want to do this, use childBone->_getDerivedPosition() - parentBone->_getDerivedPosition() to get the line between one bone and another, what you interpret to be the actual bone (but isn't). Just interpolate from the parent to the child using that value as a difference.
Bones just define a space, like any node. You're inferring that the 'bone' goes from one joint to the next - what that's actually doing though is joining a bone and it's parent. If you want to do this, use childBone->_getDerivedPosition() - parentBone->_getDerivedPosition() to get the line between one bone and another, what you interpret to be the actual bone (but isn't). Just interpolate from the parent to the child using that value as a difference.
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
hehe, yeah, i'll show u what i have so far...
So that should be setting everything right, and i know that the names of the bones are correct, as i modelled the mesh and put the bones on it. Also it doesn't crash, being a good sign of things working
Later on i try and access the points of the bones and then move them to a point that i have (on a line). I'm using...
But what happens is that the bone position isn't at the same position as the lineEnd point. and it doesn't seem to be at any common angle either, like 90, 180, 270 etc.
Any help would be great, thanks.
Code: Select all
Ogre::SceneNode *node = m_sceneManager->getRootSceneNode()->createChildSceneNode();
Ogre::Entity *entity = m_sceneManager->createEntity("bone", "boneTest.mesh");
entity->setMaterialName("Examples/Grass");
node->attachObject(entity);
//node->setScale(0.15f, 0.15f, 0.15f);
entity->setDisplaySkeleton(true);
Ogre::Skeleton *skeleton = entity->getSkeleton();
Ogre::Bone *bone;
for(int i = 1; i < 8; i++)
{
char buf[80];
sprintf(buf, "Bone0%d", i);
bone = skeleton->getBone(string(buf));
bone->setManuallyControlled(true);
bone->setInheritScale(true);
}
Later on i try and access the points of the bones and then move them to a point that i have (on a line). I'm using...
Code: Select all
Ogre::Entity *entity = m_sceneManager->getEntity("bone");
Ogre::Skeleton *skeleton = entity->getSkeleton();
Ogre::Bone *bone;
bone = skeleton->getBone("Bone01");
bone->setPosition(lineEnd.position);
Any help would be great, thanks.
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
yeah, i just realised that, cause when i move a bone, then i move the next one it will move the second one by both the first and the second. How can i get it to work??
The line is in world coordinates but the bones seem to need to be updated by the local space. Do i need to keep an accumalated positions, of all the positions that it has been moved before??
Thanks again for the help.
The line is in world coordinates but the bones seem to need to be updated by the local space. Do i need to keep an accumalated positions, of all the positions that it has been moved before??
Thanks again for the help.
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
- sjcomp
- Gnome
- Posts: 315
- Joined: Sat Apr 23, 2005 2:35 pm
- Location: Dover, NH
- Contact:
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
-
- Gnoblar
- Posts: 11
- Joined: Mon Jun 06, 2005 1:40 pm
Are you home yet?
I am interested in seeing that solution of yours.
Can you post it please?
Can you post it please?
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
lol, sorry about not post like a month or two ago.
anywho, heres the bone manipulation code for updating a bone to a point.
bone = skeleton->getBone("Bipe01");
bone->setManuallyControlled(true);
Ogre::Matrix4 mat = bone->_getFullTransform().inverse();
Ogre::Vector3 position(0.0f, 1.0f, 0.0f);
Ogre::Vector3 temp = mat * position;
bone->translate(temp, Ogre::Node::TransformSpace::TS_LOCAL);
that should work... havn't used it in a month or two.
What are you going to use it for?
anywho, heres the bone manipulation code for updating a bone to a point.
bone = skeleton->getBone("Bipe01");
bone->setManuallyControlled(true);
Ogre::Matrix4 mat = bone->_getFullTransform().inverse();
Ogre::Vector3 position(0.0f, 1.0f, 0.0f);
Ogre::Vector3 temp = mat * position;
bone->translate(temp, Ogre::Node::TransformSpace::TS_LOCAL);
that should work... havn't used it in a month or two.
What are you going to use it for?
-
- Gnoblar
- Posts: 11
- Joined: Mon Jun 06, 2005 1:40 pm
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
kool...
how are you doing orientation?? i'm finding that orientation is the annoying part. if you could post any code for orientation then that'd be great.
so far i'm thinking of using quaternions (cause they rock) and using a base unit quaternion as a reference point. from the base point the new orientation (quaternion) can be calculated with 2 cross products and a direction vector.
if anyone knows of another way of doing this i'd really like to know, code examples or just a description is fine.
i should have it done by monday though, i might post code, or else just a description (most people learn better from doing it themselves, though code is always great to get the theory down to practice).
how are you doing orientation?? i'm finding that orientation is the annoying part. if you could post any code for orientation then that'd be great.
so far i'm thinking of using quaternions (cause they rock) and using a base unit quaternion as a reference point. from the base point the new orientation (quaternion) can be calculated with 2 cross products and a direction vector.
if anyone knows of another way of doing this i'd really like to know, code examples or just a description is fine.
i should have it done by monday though, i might post code, or else just a description (most people learn better from doing it themselves, though code is always great to get the theory down to practice).
- dartsman
- Kobold
- Posts: 38
- Joined: Sat Jul 02, 2005 2:40 pm
- Location: Queensland, Australia
- Contact:
hey... well it's been a while. I did get that working, unfortunately it didn't end up in the end game. But I do have some some screenshots of the test app...
you can see it at....
http://www.projectnresource.com/phpbb/v ... c.php?t=88
Credits are at the bottom of the above post...
you can see it at....
http://www.projectnresource.com/phpbb/v ... c.php?t=88
Credits are at the bottom of the above post...