About Store Forum Documentation Contact



Post Reply 
Rotate Actor
Author Message
Babulesnik Offline
Member

Post: #1
Rotate Actor
It is necessary to turn the actor.I realise thus

Actor stakan_act;
stakan_act.matrix(Matrix3(stakan_act.matrix().rotateX(tik) )).pos(Vec(0,45,0));

How it is possible to make easier???

stakan_act.matrix().setRotateX(tik); -does not work.
01-04-2011 06:23 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #2
RE: Rotate Actor
I don't really want to start a new topic but this is more or less about matrix's so..
I am trying to rotate my character so it faces the general direction of the screen for my third person camera but right now it "rotates" the character in world space but i want to rotate it locally (like when you press q or e it turns the character).

This is what i have right now: Called in Player::update()

Code:
if(Kb.b(KB_K))
{
    //I don't know where to make use of screendir right now
    //ScreenToPosDir(Vec2(0,0), screenpos, screendir);  

    ctrl.actor.collision(false);
    ctrl.actor.gravity(false);

    //This rotates in world space, how do i rotate the character in local
    //space like pressing Q or E?
    matrix(Matrix(matrix().rotateY(0.001)));
}
I also tried
Code:
matrix(Matrix(matrix().pos,screendir));
matrix(Matrix(OrientP(pos(),screendir,Vec(0,0,1))));
Is there a better way to do this? Thanks!
(This post was last modified: 01-17-2011 01:15 AM by Dandruff.)
01-17-2011 12:33 AM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #3
RE: Rotate Actor
you want to use orientation [.orn()] for that

something like this, you'd have to modify this to work for you

Code:
Orient orientation = Orient(bone->actor.orn());
orientation*=Matrix3().setRotate(orientation.perp.x,0.01f);
bone->actor.orn(orientation)

*Edit* This method works for non-static actors like ragdoll bones
(This post was last modified: 01-17-2011 06:05 PM by llynx.)
01-17-2011 03:11 AM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #4
RE: Rotate Actor
Cool, thanks i am going to try it right now


Code:
Players[0].ctrl.actor.orn().asText();
Hmm, this seems to always return
"X: 1.000,0.000,0.000 Y: 0.000,1.000,0.000 Z: 0.000,0.000,1.000" no matter what direction i face.

What am i doing wrong?
(This post was last modified: 01-17-2011 07:33 AM by Dandruff.)
01-17-2011 03:41 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #5
RE: Rotate Actor
controller always has the same rotation, only chr::angle is changing
01-17-2011 03:02 PM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #6
RE: Rotate Actor
ah so like

Code:
Players[0].angle.set(Players[0].angle.x+0.05f,Players[0].angle.y);
01-17-2011 06:01 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #7
RE: Rotate Actor
Thanks llynx, this is exactly what i wanted smile
01-18-2011 04:06 AM
Find all posts by this user Quote this message in a reply
Post Reply