added new test mesh that is rotated,
translation from model is now applied, still need to draw all modl from one mesh
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "Object.h"
|
||||
#include <iostream>
|
||||
#define PI (4.0*atan(1.0))
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
@@ -276,12 +277,18 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempScale[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempScale[2]), sizeof(float));
|
||||
|
||||
//TODO: rotation value is wrong
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[2]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[3]), sizeof(float));
|
||||
|
||||
//calculate x,y,z rotation
|
||||
tempRotation[0] = atan2(2 * (tempRotation[0] * tempRotation[1] + tempRotation[2] * tempRotation[3]),
|
||||
1 - 2 * (pow(tempRotation[1], 2) + pow(tempRotation[2], 2)));
|
||||
tempRotation[1] = asin(2 * (tempRotation[0] * tempRotation[2] - tempRotation[3] * tempRotation[1]));
|
||||
tempRotation[2] = atan2(2 * (tempRotation[0] * tempRotation[3] + tempRotation[1] * tempRotation[2]),
|
||||
1 - 2 * (pow(tempRotation[2], 2) + pow(tempRotation[3], 2))) - PI;
|
||||
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempTrans[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempTrans[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempTrans[2]), sizeof(float));
|
||||
|
||||
Reference in New Issue
Block a user