• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Ronan085

How do i implement linear interpolation

11 posts in this topic

Hey 

 

Does anybody know how to properly implement linear interpolation for skeletal animation i just cant seem to get it to work

Ive been getting some very interesting results when ive tried different ways eg model exploding apart when the animations starts, random translations and rotations happening

If anybody wants to see any of the codes from my attempts at it just ask smile.png

 

Any help would be greatly appreciated.

0

Share this post


Link to post
Share on other sites
How are you representing the transformation that brings you from the frame of reference of the parent bone to the frame of reference of this bone? You probably want to use quaternions for the rotation part, and then use slerp or nlerp.
2

Share this post


Link to post
Share on other sites

The equation for linear interpolation is quite easy.

 

x = x_start + ((x_final - x_start) * time) 

 

 

where time is a number between 0 and 1.

 

However; as Alvaro said, this equation doesn't work well with rotations. For rotations, you should look into quaternions.

 

Here's an article with some information. 

Edited by Squared'D
1

Share this post


Link to post
Share on other sites

@Álvaro The file format im using is based off collada so the transformations are represented by 4x4 matrixs

 

@Squared'D ya ive been using that equation but the result are not what im expecting, my file file format has specified that all transformation interpolation should be linear

0

Share this post


Link to post
Share on other sites

@Squared'D ya ive been using that equation but the result are not what im expecting, my file file format has specified that all transformation interpolation should be linear

rotating around something is not linear, since a rotation imply's movement in an arc around a point, rather than a straight line. doing slerp(sperhical linear interpolation) isn't easy with matrixs, quaternions simplify the mathematics(but are a bit hard to understand if you don't know complex numbers(still it can be a bit difficult to comprehend even then imo)) Edited by slicer4ever
1

Share this post


Link to post
Share on other sites

@Squared'D ya ive been using that equation but the result are not what im expecting, my file file format has specified that all transformation interpolation should be linear

rotating around something is not linear, since a rotation imply's movement in an arc around a point, rather than a straight line. doing slerp(sperhical linear interpolation) isn't easy with matrixs, quaternions simplify the mathematics(but are a bit hard to understand if you don't know complex numbers(still it can be a bit difficult to comprehend even then imo))

 

 

How are you representing the transformation that brings you from the frame of reference of the parent bone to the frame of reference of this bone? You probably want to use quaternions for the rotation part, and then use slerp or nlerp.

 

Ok so where do i get this rotation information if the only transformation information i have is stored in one matrix

0

Share this post


Link to post
Share on other sites

I have noobish questions if you don't mind me learn something, since this is somehow related.

 

1.

Affine transformation matrix is like "world" matrix used to transform vertices?

For example i want to transform some point with that kind of matrix (dx, row major):

pout->x = pm->m[0][0] * pin->x + pm->m[1][0] * pin->y + pm->m[2][0] * pin->z + pm->m[3][0];
pout->y = pm->m[0][1] * pin->x + pm->m[1][1] * pin->y + pm->m[2][1] * pin->z + pm->m[3][1];
pout->z = pm->m[0][2] * pin->x + pm->m[1][2] * pin->y + pm->m[2][2] * pin->z + pm->m[3][2];

 

2.

Non-affine is like projection (and view?) matrix?

So to transform point with that it is bit different:

FLOAT norm;
norm = 1.0f / (pm->m[0][3] * pin->x + pm->m[1][3] * pin->y + pm->m[2][3] *pin->z + pm->m[3][3]);
pout->x = (pm->m[0][0] * pin->x + pm->m[1][0] * pin->y + pm->m[2][0] * pin->z + pm->m[3][0]) * norm;
pout->y = (pm->m[0][1] * pin->x + pm->m[1][1] * pin->y + pm->m[2][1] * pin->z + pm->m[3][1]) * norm;
pout->z = (pm->m[0][2] * pin->x + pm->m[1][2] * pin->y + pm->m[2][2] * pin->z + pm->m[3][2]) * norm;

 

3. For directions/vectors i can remove adding translation part of matrix?

 

Thank you for your time.

0

Share this post


Link to post
Share on other sites

Some googling for "matrix to quaternion conversion" turned up http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ which goes through the math and presents Java and C++ code for building a quaternion from a rotation matrix. Similar googling can be performed for "quaternion slerp" and "quaternion to matrix conversion".

 

really nice article thanks, thankfully XNAMath has a nice function XMQuaternionSlerp() so that will save me a ton of work;

 

Ok so where do i get this rotation information if the only transformation information i have is stored in one matrix

The 4x4 matrix of an affine transformation is compose of a 3x3 matrix that represents a linear mapping (in the case of posture data this is a rotation) and a translation vector (a column to the right of the 3x3 matrix or a row below it, depending on whether you are using column vectors or row vectors). The other four components are always "0 0 0 1".

Extract the rotation and the translation separately and convert the rotation to a quaternion (see JTippetts's post above).

 

thanks i was very clueless about how the different information was sorted in the matrix, any idea where the scaling information is

0

Share this post


Link to post
Share on other sites

[...] any idea where the scaling information is

It's also in the 3x3 matrix. That matrix can be any linear mapping, which besides rotations also allow for things like scalings, taking mirror images and shearing mappings. But I prefer to force them to be rotations for most situations.
0

Share this post


Link to post
Share on other sites
FWIW: one trick I had used before for interpolating matrices directly was to identify a common rotation axis, and then rotate all of the vectors in the matrix (as points) along this axis.

typically this axis was found/approximated by finding which unit axis changed the least during the movement, interpolating this axis (by treating it as an arc along the plane formed by its 2 positions and the origin), and then using this interpolated axis to rotate the matrix by (trying to rotate the source-matrix into the destination matrix).

(there may be better ways to calculate this axis though).

the math gets hairy, and there may be a better and more accurate ways to do this, but in my uses it seemed to work ok (much better than linearly interpolating them at least...).

(I can imaging a few ugly hacks though to possibly boost accuracy, but decided against elaborating on them). Edited by cr88192
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0