Sunday, December 15, 2019

Representation of linear transformation of matrix

Let say there is a 3x3 matrix

[m11 m12 m13]
[m21 m22 m23]
[m31 m32 m33]

[m11 m12 m13] is a row vector

[m21 m22 m23] is a row vector

[m31 m32 m33] is a row vector

and which of above are basis vectors in 3D space. i, j, k in standard form.

[m11 m12 m13] is a row vector and i

[m21 m22 m23] is a row vector and j

[m31 m32 m33] is a row vector and k

using linear transformation we can write a vector v like down below.

v = vx*i + vy*j + vz*k

if we apply some transform(matrix) into vector V and we can visualize it.

for instance we have 

[1 0 0]
[0 1 0] == matrix A
[0 0 1]

it is an identity matrix and if we multiply vector v with matrix.

vA

we will get v because A is an identity matrix.

if matrix A is like down below.

[0.75 0.75 0]
[0 1 0]
[0 0 1]

vector v or shape of model will be scaled, shrink.



Using this representation, we can guess what the shape will look like when we apply some transformations. (Sorry! I'm not good at drawing)

Representation of vector and multiplication.

There are two ways to represent of vector.

row vector and column vector.

[x y z] is a row vector

[x]
[y]
[z]

is a column vector.

When we multiple a vector with matrix, should be careful.

For instance we want to apply matrix A, B then C in order and there is a vector 'v'
depending on the representation of vector, we use it differently.

if the v is a row vector then we should use vABC.
if the v is a column vector then we should use CBAv.

Many books and game engine uses differently. so you should be careful when you use it.

1. Check representation of vector.
2. Check an order of matrix and then apply it to the vector carefully.

Wednesday, December 4, 2019

about vector interpolation

Many of you guys already know that vector interpolation might have different result than you think.

As you can see the below image, red arrow is a forward vector and green arrow is a right vector of the character.

If you interpolate forward vector to right vector, you will get below image.


This is because I didn't account of angle of vector. If I account of angle of vector then I'll get different result like down below.


In unreal engine 4, There are related functions exist.

FMath::RInterpTo is for linear interpolation.
FQuat::Slerp is for spherical linear interpolation.

Friday, November 29, 2019

Animation programming in UE4 and about GetEvaluateGraphExposedInputs

My input data was missed in my custom AnimNode and find out that I missed a call function.

GetEvaluateGraphExposedInputs().Execute(Context);

What GetEvaluateGraphExposedInputs().Execute(Context) does is copy all the input data into AnimNode. (That's why there is some cost...)

If you look at the AnimNodeBase.cpp and line 675 there are function FExposedValueHandler::Execute function.

Wednesday, November 27, 2019

Applying a transform into Normal vector.


Applying a transform into normal vector
When we apply a transform into normal vector, we can't use N * M. Because we don't want scale effect like below.


We represent basic transform like below. 




We want to apply R(rotation) only not S(scale). Our expected transform needs to be like below.



If we take inverse of rotation matrix and then take transpose, result matrix will be same as original rotation matrix. so we can represent above formula like below.


As we know, scale transform is a diagonal matrix. If we take a transpose of it, result will be same as original scale transform.


Our expected matrix can be like this.

In the transpose matrix, there is a property.


matrix can be represented like below.


In the inverse matrix, there is a property.


matrix can be represented like below.


R1 * S * R2 is a transform matrix M. As a result, we can have a matrix down below.


The transform matrix what we want is Mwant and it is a inverse of original matrix M and take transpose.

I'm making a motion matching solution.

Motion Matching is very popular now a days. I think motion matching is very similar as feature match system in Game AI field. I applied this system to FIFA when I was in EA Canada. CPU AI could use skill when they find similar situations. I'm not an animation engineer but I'm trying to implement it for fun. :)


Tuesday, November 26, 2019

Use Ue4's DrawDebugSphere in AnimNode

When we use DrawDebugSphere function for debugging, it is working well but when you are trying to use it in anim node's function it will be a problem.

Basically AnimNode will be updated multithreaded so if you want to use DrawDebugSphere in AnimNode then you should use AnimDrawDebugSphere instead.

It will reserve all the command in local TArray and then processed correctly.


Context.AnimInstanceProxy->AnimDrawDebugSphere(outTransform.GetLocation(), 3.f, 32, FColor::Green, false, 1.0f);


Use like above.

Task in UnrealEngine

 https://www.youtube.com/watch?v=1lBadANnJaw