setInheritOrientation what is happen

Problems building or running the engine, queries about how to use features etc.
Post Reply
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

setInheritOrientation what is happen

Post by mielle »

Hi,
what mean when i make like that

Code: Select all

 skel->getBone(i)->setInheritOrientation(true);
what is happen when i set it to true


i know that "inherit If true, this node's orientation will be affected by its parent's orientation. If false, it will not be affected. "

is that mean that the bone(i) (child) have the same angle as it's parent ? or that mean that the child track the prent motion

exemple

if we have bone1 parent of bone2 and bone 2 parent of bone3

if we make for all the bones "skel->getBone(i)->setInheritOrientation(true);"
what happend if i make

Code: Select all

 skel->getBone("bone1")->setOrientation(quat);
what will happen for bone2 and bone 3 what is the orientation of those bones

thanks
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: setInheritOrientation what is happen

Post by Kojack »

True is the default state of inherit orientation, so doing setInheritOrientation(true) won't change anything.

If inherit orientation is true, then the bone's orientation is local to it's parent bone. So when the parent rotates, the child rotates too.
If inherit orientation is false, then the bone's orientation isn't local to it's parent. Rotating a parent bone has no effect on the orientation of a child bone.
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

if inherit orientation is true, then the bone's orientation is local to it's parent bone. So when the parent rotates, the child rotates too.
ok , i understand that , but if as i said
we have root parent bone1 parent of bone2 and bone2 parent of bone3
and when we setorentation of bone1 , and we haven't bone2 and bone3 orientation , what's the orientation value of bone2 and bone3?
they not have the same angle of the bone1 no?

when we said they inheret the orientation of their parent bone1 , what that mean exactelly ?

the orientation of the bone1 is relative to the root (it's parent) so , bone2 it's orientation will be the same as bone1 relative to the root ?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: setInheritOrientation what is happen

Post by Kojack »

and when we setorentation of bone1 , and we haven't bone2 and bone3 orientation , what's the orientation value of bone2 and bone3?
If bones 2 and 3 have identity transforms (the default for a node, but a bone will have whatever your modelling program set it to) then setting the orientation of bone1 will make bones 2 and 3 have the same orientation.
For example, if bone1 is your shoulder and bone2 is your elbow. Let's say your elbow is straight (identity orientation). When you point your upper arm to the north, your forearm points the same way. The forearm is inheriting the orientation of the upper arm. If the elbow was bent 90 degrees, then the orientation of your forearm would always be 90 degrees bent from whatever your upper arm was.
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

If bones 2 and 3 have identity transforms
when i load my skeleton.mesh i have character in T pose, so i gues yes they are in the identity transform
but a bone will have whatever your modelling program set it to
ok, so i can use beor setting the bone1 orientation , we make
bone2->getOreination , and bone3-<getorientation to see the initial orientation
then setting the orientation of bone1 will make bones 2 and 3 have the same orientation.
so if the the bone1 have (10,30,10) euler angle relative to it's parent the root for exemple
bone will have (10,30,10) relative to bone1 ? or relative to the root (parent of bon1)
bone3 will have (10,30,10) relative to bone2?
is it true to make that and will give us real pose ?
If the elbow was bent 90 degrees, then the orientation of your forearm would always be 90 degrees bent from whatever your upper arm was.
yes that i know it if i set the orientation of the bone2 he will not inherit the oriantion of it's parent
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: setInheritOrientation what is happen

Post by Kojack »

when i load my skeleton.mesh i have character in T pose, so i gues yes they are in the identity transform
Maybe. If the character was modeled in a t pose then the bones might be identity. It depends on how the bones are placed in the modelling program. If you look in the data for the sinbad character, he has roughly a t pose, but his bones aren't at identity. They are all rotated by some amount (probably to match the direction each bone is facing in blender when it's attached to the mesh, except relative to it's parent bone).
so if the the bone1 have (10,30,10) euler angle relative to it's parent the root for exemple
bone will have (10,30,10) relative to bone1 ? or relative to the root (parent of bon1)
bone3 will have (10,30,10) relative to bone2?
If inherit orientation is true, then bone2's world/derived orientation is a combination of bone1's world/derived orientation and bone2's local orientation. Bone3's derived orientation is a combination of bone2's derived orientation with bone3's local orientation.
In your numbers above, if bones 2 and 3 are identity then bone2 is (0,0,0) relative to bone1 and bone3 is (0,0,0) relative to bone2 (and bone1). But their absolute (not relative) orientations would all be (10,30,10).
(Hmm, this is beginning to sound more confusing than it started out as. I shouldn't talk about orientation math just after waking up and before caffeine)

The actual code in ogre (inside of Node::updateFromParentImpl):

Code: Select all

const Quaternion& parentOrientation = mParent->_getDerivedOrientation();
            if (mInheritOrientation)
            {
                // Combine orientation with that of parent
                mDerivedOrientation = parentOrientation * mOrientation;
            }
			else
            {
                // No inheritance
                mDerivedOrientation = mOrientation;
            }
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

thanks for the description
so to recapitulate
the bone2 boen3 orientation in the world space= bone1 orientation in the local space(it's oientation relative to it's father)
that if the bone and bone3 are in the identity transform
am i true ?
but if ye i am true when i see this

Code: Select all

mDerivedOrientation = parentOrientation * mOrientation;
i found that the bone2 and bone3 orientation in the world space= bone1 orientation in the world space not it's orientation in the local space relative to it's parent
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

as i see there is contraduction between what you said to me
In your numbers above, if bones 2 and 3 are identity then bone2 is (0,0,0) relative to bone1 and bone3 is (0,0,0) relative to bone2 (and bone1). But their absolute (not relative) orientations would all be (10,30,10).
because that mean
the bone2 boen3 orientation in the world space= bone1 orientation in the local space
!!!
and

Code: Select all

const Quaternion& parentOrientation = mParent->_getDerivedOrientation();
            if (mInheritOrientation)
            {
                // Combine orientation with that of parent
                mDerivedOrientation = parentOrientation * mOrientation;
            }
         else
            {
                // No inheritance
                mDerivedOrientation = mOrientation;
            }
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: setInheritOrientation what is happen

Post by Kojack »

Let's try it visually.
We'll assume the bones only have one angle here to make it easier.

The initial bone hierarchy: Bone1 and Bone2 have identity orientations (0 degrees rotation). Bone3 has a 15 degree rotation, to make it more interesting.
Image

This is what happens when only Bone1 is rotated by 45 degrees with Inherit Orientation set to true.
Bone2 is still identity (0 degrees) locally, if you do getOrientation on it it will still be identity. But it's derived (world) orientation is it's parent's derived orientation + it's local orientation, which equals 45 degrees.
Bone3 is still 15 degrees locally. But it's derived orientation is Bone2's derived orientation (45) + it's local orientation (15), which equals 60.
Image

This is what happens when only Bone1 is rotated by 45 degrees with Inherit Orientation set to false.
Both Bone2 and Bone3 keep the same local and derived orientation.
Image


If these were scenenodes, that would be all there is to it. But bones have an extra wrinkle that makes things trickier. A skeleton is inside of a scenenode, but doesn't know about it as such. So really the term world probably isn't the best one to use. Neither is derived, because for scenenodes derived is the world transform. So if you want the true world orientation of a bone you need to get it's derived orientation (which thinks the skeleton is the world) and transform it by the scenenode's derived orientation.
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

Ok that look good
BUT i have another problem (or another question)

assume that we have kinematic like in the first picture
where
The initial bone angle :
bone1 and bone2 angle =0
and bone3=15

and we make setinherit true


after that we make like that

Code: Select all

bone1->setOrientation(quat1)
bone3->setOrientation(quat2)
we set the bone1 bone3:
bone1 45 degree
bone3 50 degree (local space ) [/quote]



in this case we haven't the bone2 angle

what happen here ?
is that problem ?

or
it's not problem and the angle will be like that

bone1 45 degree;
bone2 global 45 degree
bone3 will be 50 degree (local) and the global (50,60)??????????????,,
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

EDIT

i forget to warn you that
when i set the bone3 orientation (local)
bone3->setOrientation(quat2)
bone3 50 degree (local space )
this 50 degree is relative to bone1 and note relative to bone2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

so it's impossible to get the local and global angle of bone2 and bone3?????????
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

in the case that i described in my last reply
it's impossible to get the bone2 orientation no?
and if we make set inherit as true and we let the same bone3 angle it will be wrong no?
because the we have bone3 local angle relative to bone1 and not to bone2
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

hi again i found solution but it's just for particul case

when we have
bone0 bone1 bone2 and bone3
and when we have bone3 orinetation relative to bone0
in this case we don't use setOrientation() but we use _setDerivedOrientation

I have now another problem when we have like that

bone0
orientation of bone1 relative to bone0
orientation of bone3 relative to bone2

in this case we can't use for bone3 we can't use set<position because the orientation that we have it's not relative to the parent bone2
and we can't use _setDerivedOrientation because it's not relative to the first bone !!!!!!!!!!!!!!!!!

have you an idea in this case how we must work ?
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

here
in this case we can't use for bone3 we can't use set<position
i just made error , i want to say we can't use setOrienttaion

and i made another error
orientation of bone3 relative to bone2
in this case there is no problem ,
i wanted to said that i have
orientation of bone3 relative to bone1


i used like that

Code: Select all

bone3-<_setDerivedOrientation(orientation of bone3 relative to bone1+global orienttaon of bone2)
but i am not sure if it's fine
mielle
Greenskin
Posts: 113
Joined: Mon Feb 25, 2013 11:12 am
x 1

Re: setInheritOrientation what is happen

Post by mielle »

i try it and it does not work
i will opend another subject with appropriate title to find somone help me
thanks again
Post Reply