3D Object Rotation problem

Skeletons, animations, shaders, texturing, converting, fixing and anything else related to read game models
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

3D Object Rotation problem

Post by h3x3r »

Hi there. I need figure out something guys. I find out Positions but can't figure out Rotation. There are values but they don't make any sense. I tried multiple them by 360.0 with not good results.
On the image i manually set the most correct object rotation but can't find these values. Are they converted somehow? I serached for floats, doubles and nothing. It's possible that rotation are writen in integrers/shorts and converted with float modifier?
Image
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: 3D Object Rotation problem

Post by h3x3r »

Another example... As you can see object without any rotation has whole number.
Image
Image
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: 3D Object Rotation problem

Post by h3x3r »

Found something... Maybe it is that case. But can't figure out how to convert it as Template for 010 HEX Editor. I think the order is x,y,z and it has something with "Tait-Bryan angles". All what i need is convert these values to degrees. If someone has an idea please help. Thanks in advance!

Code: Select all

// Checks if a matrix is a valid rotation matrix.
bool isRotationMatrix(Mat &R)
{
    Mat Rt;
    transpose(R, Rt);
    Mat shouldBeIdentity = Rt * R;
    Mat I = Mat::eye(3,3, shouldBeIdentity.type());

    return  norm(I, shouldBeIdentity) < 1e-6;

}

// Calculates rotation matrix to euler angles
// The result is the same as MATLAB except the order
// of the euler angles ( x and z are swapped ).
Vec3f rotationMatrixToEulerAngles(Mat &R)
{

    assert(isRotationMatrix(R));

    float sy = sqrt(R.at<double>(0,0) * R.at<double>(0,0) +  R.at<double>(1,0) * R.at<double>(1,0) );

    bool singular = sy < 1e-6; // If

    float x, y, z;
    if (!singular)
    {
        x = atan2(R.at<double>(2,1) , R.at<double>(2,2));
        y = atan2(-R.at<double>(2,0), sy);
        z = atan2(R.at<double>(1,0), R.at<double>(0,0));
    }
    else
    {
        x = atan2(-R.at<double>(1,2), R.at<double>(1,1));
        y = atan2(-R.at<double>(2,0), sy);
        z = 0;
    }
    return Vec3f(x, y, z);

}

Structure of file is like:
Image
Got it. Order is Z,Y,X
Image
Now how to write code for 010 template to parse and output results???