Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: bone interpolation? [Re: MrGuest] #310591
02/15/10 19:57
02/15/10 19:57
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
yes, but is it really innverse kinematic if i know the current bone angle plus the destination bone angle and wish to rotate from the current angle to destination.. i thought some vector maths could accomplish that?

Re: bone interpolation? [Re: darkinferno] #310599
02/15/10 20:42
02/15/10 20:42
Joined: Mar 2009
Posts: 112
Germany
K
KDuke Offline
Member
KDuke  Offline
Member
K

Joined: Mar 2009
Posts: 112
Germany
Well I wouldn't say this has to be IK as this would be to have a recursive relationship between every bone. Though you just want to rotate a single bone and don't need this relationship of bones taken into account as far as I understand.

Well I'd say that's tricky anyways. Doing this directly with vectors would require a rotation matrix if I remember correctly. Therefore working with pan, tilt and roll would be more appropriate.

Here's some untested pseudo-code for you.
Code:
/**
 * First of get the euler angles we start from!
 **/
ANGLE* StartAngle = nullvector;
ang_for_bone(StartAngle, player, "BoneName");

/**
 * Alright now get the euler angles of the destination.
 **/
VECTOR* DestVec = vector(you.x, you.y, you.z);
ANGLE* DestAngle = nullvector;
vec_to_ang(DestAngle, DestVec);

/**
 * Calculate the difference of the start and destination position.
 **/
ANGLE* DiffAngle = nullvector;
ang_diff(DiffAngle, StartAngle, DestAngle);

/**
 * Now we have everything we need! Rotate the bone.
 **/
ANGLE* StillToRotate = nullvector;
while(1) {
    ent_bonerotate(player, "BoneName", vector(
                     DiffAngle.pan * time_step,
                     DiffAngle.tilt * time_step,
                     DiffAngle.roll * time_step)
    );

    /**
     * We gotta check if we are close to our destination.
     **/

    /**
     * For that we first get the angle we still have to journey
     **/
    ang_for_bone(StartAngle, player, "BoneName");
    ang_diff(StillToRotate, StartAngle, DestAngle);

    /**
     * Now we see if we are near the destination.
     **/
    if( StillToRotate.pan < 1.0 && StillToRotate.pan > -1.0 &&
        StillToRotate.tilt < 1.0 && StillToRotate.tilt > -1.0 &&
        StillToRotate.roll < 1.0 && StillToRotate.roll > -1.0) {
        /**
         * We are pretty close to our destination! Though to make sure
         * we really reach the destination just snap the bone to it.
         **/
        <Your Bone snap code>
        // Don't forget to exit the while-loop!
        break;
    }
    wait(1);
}

/**
 * (Hopefully) be happy
 **/



This would be the way I would approach this stuff! Neither don't know if it really works nor if it is fast enough in realtime. Though I hope this gives you an idea how to approach the problem.

EDIT: By the way. Why do you actually want to interpolate bones manually?

greetings
K-Duke

Last edited by KDuke; 02/15/10 20:46.

Using A7 Free
Click and join the 3dgs irc community!
Room: #3dgs
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1