x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Converting OpenGL transform matrix to FRotator

I want to convert an OpenGL transform matrix into an FRotator.

I go about this by getting the base axis from the OpenGL matrix and using the UKismetMathLibrary::MakeRotationFromAxes, but I am not getting correct results:

double matrix[16]; ... FVector X(matrix[0], matrix[1], matrix[2]); // OpenGL X FVector Y(matrix[4], matrix[5], matrix[6]); // OpenGL Y FVector Z(matrix[8], matrix[9], matrix[10]); // OpenGL Z

FRotator Rotation = UKismetMathLibrary::MakeRotationFromAxes(X, Y, Z); // Forward, Right, Up

This is clearly not working for anyting other than the identity matrix. When I sett the matrix to identity and getting X = 1,0,0 Y = 0,1,0 and Z = 0,0,1 for base axes this yields an FRotator with Pitch = 0, Yaw = 0 and Roll = 0, which is what I would expect.

What am i missing here?

Product Version: UE 4.9
Tags:
more ▼

asked Oct 13 '15 at 11:50 PM in C++ Programming

avatar image

aseton
1 1 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

UE4 has it's own matrix implementation + it has some diffrent version of it if you look on refrence

https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Math/FMatrix/index.html

In fact what function that you are using, just normalizeing vectors and make FMatrix out of it and then make FRotator out of it:

 FRotator UKismetMathLibrary::MakeRotationFromAxes(FVector Forward, FVector Right, FVector Up)
 {
     Forward.Normalize();
     Right.Normalize();
     Up.Normalize();
 
     FMatrix RotMatrix(Forward, Right, Up, FVector::ZeroVector);
 
     return RotMatrix.Rotator();
 }

Maybe if you take it to FMatrix and it if you look on it's function set it will let you move fearther with it. Personallly.... i'm noob in matrixes, so other then that i can't help you

more ▼

answered Oct 14 '15 at 04:00 AM

avatar image

Shadowriver
37.2k 936 172 1116

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question