About Store Forum Documentation Contact



Post Reply 
Head Orientation
Author Message
iamcreasy Offline
Member

Post: #1
Head Orientation
I have made a model with a skeleton
.
Code:
    Orient &head = cskel.getBone("head").orn;
    head*=Matrix3().setRotateZ(Sin(Time.time()*1.5));

I am trying to code to move its head manually.(Just like the tutorial)

But it doesn't work.Am I missing something?There was a green arrow with the head of the skeleton.Is it something to do with the orientation.


Attached File(s) Image(s)
   
(This post was last modified: 06-01-2010 07:18 AM by iamcreasy.)
05-31-2010 10:18 PM
Find all posts by this user Quote this message in a reply
Yurci Offline
Member

Post: #2
RE: Head Orientation
Arrow on the head show position for camera (First person)
Quote:cskel.getBone("head")

Arrows on hands show position to for example put equip item.
(This post was last modified: 05-31-2010 10:39 PM by Yurci.)
05-31-2010 10:38 PM
Visit this user's website Find all posts by this user Quote this message in a reply
iamcreasy Offline
Member

Post: #3
RE: Head Orientation
So, i dont need to think about that green arrow while trying to custom animate the head...ok

but how do I do it?

Does every bone has a local rotation axis?Is the straight line shows Y axis?


Attached File(s) Image(s)
   
06-01-2010 07:37 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #4
RE: Head Orientation
yeah, this is the Orient::perp (Y axis)
06-01-2010 07:21 PM
Find all posts by this user Quote this message in a reply
iamcreasy Offline
Member

Post: #5
RE: Head Orientation
Can you please tell me how do I orient the head manually?

just like the code in the picture or posted before.
06-02-2010 10:58 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #6
RE: Head Orientation
You need to add this line:

Code:
cskel.updateMatrix(MatrixIdentity).updateVelocities();
06-02-2010 06:24 PM
Find all posts by this user Quote this message in a reply
iamcreasy Offline
Member

Post: #7
RE: Head Orientation
(06-02-2010 06:24 PM)Driklyn Wrote:  You need to add this line:

Code:
cskel.updateMatrix(MatrixIdentity).updateVelocities();

According to tutorial, updateVelocities()'s use is "this is needed for Motion Blur effect".

So, it is not needed.
Thought, i checked it and as i suspected.It dont work.
06-03-2010 07:39 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #8
RE: Head Orientation
I suppose you don't need updateVelocities() if you're not planning on using motion blur, but you still need updateMatrix().

Those three lines are all you need. If you are using a first-person camera for the character you are trying this on, try switching to third-person.
06-03-2010 07:52 AM
Find all posts by this user Quote this message in a reply
iamcreasy Offline
Member

Post: #9
RE: Head Orientation
Code:
cskel.clear();    

Orient &head=cskel.getBone("head").orn;                 head*=Matrix3().setRotateZ(Sin(Time.time()*1.5));

if(Kb.b(KB_W))cskel.animate(L"obj/chr/dino/walk_forward.anim", Time.time());    

cskel.updateMatrix(MatrixIdentity);

this is the code that i used....it's walk_forward.anim works...but head orientation doesn't.

Complete source code and the mesh is attached.


Attached File(s)
.rar  dino.rar (Size: 398.81 KB / Downloads: 3)
06-03-2010 03:11 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #10
RE: Head Orientation
Apparently there has to be some sort of animation already loaded on the skeleton for it to work.

Change this:
Code:
cskel.clear();    

Orient &head=cskel.getBone("head").orn;
head*=Matrix3().setRotateZ(Sin(Time.time()*1.5));

if(Kb.b(KB_W))cskel.animate(L"obj/chr/dino/walk_forward.anim", Time.time());

To this:
Code:
cskel.clear();    
cskel.animate(L"obj/chr/dino/walk_forward.anim", Time.time());

Orient &head=cskel.getBone("head").orn;
head*=Matrix3().setRotateZ(Sin(Time.time()*1.5));

And it will work.
06-04-2010 04:56 AM
Find all posts by this user Quote this message in a reply
iamcreasy Offline
Member

Post: #11
RE: Head Orientation
(06-04-2010 04:56 AM)Driklyn Wrote:  To this:
Code:
cskel.clear();    
cskel.animate(L"obj/chr/dino/walk_forward.anim", Time.time());

Orient &head=cskel.getBone("head").orn;
head*=Matrix3().setRotateZ(Sin(Time.time()*1.5));

And it will work.

gosh......thanks a lot. grin

I thought, I will never be able to figure out the problem.

But, still I dont understand, you are saying that "some sort of animation already loaded on the skeleton for it to work."..but why that should be a problem?Cause, multiple animation can be there in a single skeleton..right?

Moreover, It(ckel.animate) required a key press...so, that line shouldn't exits or execute before that...so, by default the head should be moving...if we think of your's saying that "there is already another animation on the skeleton"

Again, when I use following code
Code:
cskel.clear();    

Orient &head=cskel.getBone("head").orn;  
head*=Matrix3().setRotateZ(Sin(Time.time()*1.5)); /
    
cskel.updateMatrix(MatrixIdentity);
(removed the ckel.animate line)

This should animate the head because, there is no other animation.

Put this logic aside, I dont find a reason why nothing happens?

Why all the animation's has to work together?and why the "head animation" has to be coupled with another animation(.anim file) to make it work?
06-04-2010 05:50 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #12
RE: Head Orientation
Couldn't tell you the exact reasoning, but I would imagine that if there is no animation set to the skeleton, the engine skips over it entirely so it doesn't have to waste processing power or something along those lines.

After calling cskel.clear(), cskel.getBone("head") seems to have no effect until an animation is set. This probably won't be too much of a problem though because your character should always have some kind of animation set to it.

Just figured out by looking at a different tutorial that it is possible to do without an animation.

All you need is this one line:
Code:
cskel.getBone("head").rot.axis.z = Sin(Time.time()*1.5);
06-04-2010 06:57 AM
Find all posts by this user Quote this message in a reply
iamcreasy Offline
Member

Post: #13
RE: Head Orientation
yeh..it worked.smile[/align]

I actually needed that.Because, when your character is standing still and you are looking at different direction with mouse, then you may want to move it's head independently.
06-04-2010 07:10 AM
Find all posts by this user Quote this message in a reply
Post Reply