Bone Point Manipulation

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Bone Point Manipulation

Post by dartsman » Thu Sep 22, 2005 3:39 am

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
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Thu Sep 22, 2005 1:50 pm

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.
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Thu Sep 22, 2005 3:03 pm

ok cool... i'll give that a go.

thanks and keep up the good work on OGRE, this rendering engine is awesome.
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Sun Sep 25, 2005 3:06 am

that worked, but now i have another problem, i need to set the position of the bone manually. I have a line that i move, and the bones need to be updated by that line.

I've tried "bone->setPosition(lineEnd.position);" but it isn't updating it right. I'm pretty sure theres something i've missed.
0 x

User avatar
bal
Greenskin
Posts: 100
Joined: Thu Dec 09, 2004 7:29 pm
Location: Geluwe, Belgium

Post by bal » Sun Sep 25, 2005 10:25 am

Have you called bone->setManuallyControlled(true) ?
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Sun Sep 25, 2005 1:53 pm

hehe, yeah, i'll show u what i have so far...

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);
	}
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...

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);
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.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Sun Sep 25, 2005 6:04 pm

setPosition is relative to the parent bone. Make sure the position you're setting is in the same space.
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Mon Sep 26, 2005 2:51 am

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.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Mon Sep 26, 2005 1:33 pm

Easiest way is to call bone->_getFullTransform().Inverse() and apply that to your world position. That will map it back into local space.
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Mon Sep 26, 2005 2:23 pm

Cool, thanks heaps, i got it working.

thanks again
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Tue Sep 27, 2005 7:11 am

If anyone needs to know the solution i can post it up here.
0 x

User avatar
sjcomp
Gnome
Posts: 315
Joined: Sat Apr 23, 2005 2:35 pm
Location: Dover, NH
Contact:

Post by sjcomp » Tue Sep 27, 2005 10:53 pm

It would be nice to see the solution! Thanks.
0 x
Regards, Alexander. http://sjcomp.com

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Thu Sep 29, 2005 3:52 am

ok, i'll post it once i get home. can't remember it off by heart.
0 x

moramatte
Gnoblar
Posts: 11
Joined: Mon Jun 06, 2005 1:40 pm

Are you home yet?

Post by moramatte » Sat Nov 19, 2005 8:50 am

I am interested in seeing that solution of yours.
Can you post it please?
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Sat Nov 19, 2005 3:05 pm

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?
0 x

moramatte
Gnoblar
Posts: 11
Joined: Mon Jun 06, 2005 1:40 pm

Post by moramatte » Sun Nov 20, 2005 2:00 am

Thank you.

Well, my situation could be described as the trunk of an elephant. The user should be able to click on a location on the ground and the leading bone of the trunk should be placed there. The user should get the impression of controlling what the elephant is touching.
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Sun Nov 20, 2005 2:20 am

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).
0 x

User avatar
dartsman
Kobold
Posts: 38
Joined: Sat Jul 02, 2005 2:40 pm
Location: Queensland, Australia
Contact:

Post by dartsman » Fri Jun 30, 2006 2:10 pm

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...
0 x

Post Reply