Added a matrix read method.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1243 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
93bf946053
commit
6ae3b9e478
|
@ -656,11 +656,9 @@ bool CXMeshFileLoader::parseDataObjectTransformationMatrix(core::matrix4 &mat)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 i=0; i<4; ++i)
|
readMatrix(mat);
|
||||||
for (u32 j=0; j<4; ++j)
|
|
||||||
mat(i,j)=readFloat();
|
|
||||||
|
|
||||||
if (!checkForTwoFollowingSemicolons())
|
if (!checkForOneFollowingSemicolons())
|
||||||
{
|
{
|
||||||
os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING);
|
os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING);
|
||||||
return false;
|
return false;
|
||||||
|
@ -676,7 +674,6 @@ bool CXMeshFileLoader::parseDataObjectTransformationMatrix(core::matrix4 &mat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
|
bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
|
||||||
{
|
{
|
||||||
#ifdef _XREADER_DEBUG
|
#ifdef _XREADER_DEBUG
|
||||||
|
@ -920,13 +917,9 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
||||||
// world space coordinates of the mesh as affected by the bone
|
// world space coordinates of the mesh as affected by the bone
|
||||||
core::matrix4& MatrixOffset = joint->GlobalInversedMatrix;
|
core::matrix4& MatrixOffset = joint->GlobalInversedMatrix;
|
||||||
|
|
||||||
for (i=0; i<4; ++i)
|
readMatrix(MatrixOffset);
|
||||||
{
|
|
||||||
for (u32 j=0; j<4; ++j)
|
|
||||||
MatrixOffset(i,j) = readFloat();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkForTwoFollowingSemicolons())
|
if (!checkForOneFollowingSemicolons())
|
||||||
{
|
{
|
||||||
os::Printer::log("No finishing semicolon in Skin Weights found in x file", ELL_WARNING);
|
os::Printer::log("No finishing semicolon in Skin Weights found in x file", ELL_WARNING);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1437,36 +1430,19 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
|
||||||
joint->PositionKeys.reallocate(joint->PositionKeys.size()+animationDump.PositionKeys.size());
|
joint->PositionKeys.reallocate(joint->PositionKeys.size()+animationDump.PositionKeys.size());
|
||||||
for (n=0;n<animationDump.PositionKeys.size();++n)
|
for (n=0;n<animationDump.PositionKeys.size();++n)
|
||||||
{
|
{
|
||||||
ISkinnedMesh::SPositionKey *key=&animationDump.PositionKeys[n];
|
joint->PositionKeys.push_back(animationDump.PositionKeys[n]);
|
||||||
|
|
||||||
joint->PositionKeys.push_back(*key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
joint->ScaleKeys.reallocate(joint->ScaleKeys.size()+animationDump.ScaleKeys.size());
|
joint->ScaleKeys.reallocate(joint->ScaleKeys.size()+animationDump.ScaleKeys.size());
|
||||||
for (n=0;n<animationDump.ScaleKeys.size();++n)
|
for (n=0;n<animationDump.ScaleKeys.size();++n)
|
||||||
{
|
{
|
||||||
ISkinnedMesh::SScaleKey *key=&animationDump.ScaleKeys[n];
|
joint->ScaleKeys.push_back(animationDump.ScaleKeys[n]);
|
||||||
|
|
||||||
//key->scale*=joint->LocalMatrix.getScale();
|
|
||||||
|
|
||||||
joint->ScaleKeys.push_back(*key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
joint->RotationKeys.reallocate(joint->RotationKeys.size()+animationDump.RotationKeys.size());
|
joint->RotationKeys.reallocate(joint->RotationKeys.size()+animationDump.RotationKeys.size());
|
||||||
for (n=0;n<animationDump.RotationKeys.size();++n)
|
for (n=0;n<animationDump.RotationKeys.size();++n)
|
||||||
{
|
{
|
||||||
ISkinnedMesh::SRotationKey *key=&animationDump.RotationKeys[n];
|
joint->RotationKeys.push_back(animationDump.RotationKeys[n]);
|
||||||
|
|
||||||
core::matrix4 tmpMatrix;
|
|
||||||
|
|
||||||
tmpMatrix.setRotationRadians(
|
|
||||||
core::vector3df(key->rotation.X, key->rotation.Y, key->rotation.Z) );
|
|
||||||
|
|
||||||
tmpMatrix=joint->LocalMatrix*tmpMatrix;
|
|
||||||
|
|
||||||
//key->rotation = core::quaternion(tmpMatrix);
|
|
||||||
|
|
||||||
joint->RotationKeys.push_back(*key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1509,7 +1485,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
||||||
for (u32 i=0; i<numberOfKeys; ++i)
|
for (u32 i=0; i<numberOfKeys; ++i)
|
||||||
{
|
{
|
||||||
// read time
|
// read time
|
||||||
const u32 time = readInt();
|
const f32 time = (f32)readInt();
|
||||||
|
|
||||||
// read keys
|
// read keys
|
||||||
switch(keyType)
|
switch(keyType)
|
||||||
|
@ -1537,7 +1513,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
||||||
}
|
}
|
||||||
|
|
||||||
ISkinnedMesh::SRotationKey *key=AnimatedMesh->createRotationKey(joint);
|
ISkinnedMesh::SRotationKey *key=AnimatedMesh->createRotationKey(joint);
|
||||||
key->frame=(f32)time;
|
key->frame=time;
|
||||||
key->rotation.set(X,Y,Z,W);
|
key->rotation.set(X,Y,Z,W);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1565,13 +1541,13 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
||||||
if (keyType==2)
|
if (keyType==2)
|
||||||
{
|
{
|
||||||
ISkinnedMesh::SPositionKey *key=AnimatedMesh->createPositionKey(joint);
|
ISkinnedMesh::SPositionKey *key=AnimatedMesh->createPositionKey(joint);
|
||||||
key->frame=(f32)time;
|
key->frame=time;
|
||||||
key->position=vector;
|
key->position=vector;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ISkinnedMesh::SScaleKey *key=AnimatedMesh->createScaleKey(joint);
|
ISkinnedMesh::SScaleKey *key=AnimatedMesh->createScaleKey(joint);
|
||||||
key->frame=(f32)time;
|
key->frame=time;
|
||||||
key->scale=vector;
|
key->scale=vector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1589,41 +1565,36 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// read matrix
|
// read matrix
|
||||||
core::matrix4 Matrix;
|
core::matrix4 mat(core::matrix4::EM4CONST_NOTHING);
|
||||||
|
readMatrix(mat);
|
||||||
|
|
||||||
for (u32 m=0; m<4; ++m)
|
//mat=joint->LocalMatrix*mat;
|
||||||
for (u32 n=0; n<4; ++n)
|
|
||||||
Matrix(m,n) = readFloat();
|
|
||||||
|
|
||||||
|
if (!checkForOneFollowingSemicolons())
|
||||||
//Matrix=joint->LocalMatrix*Matrix;
|
|
||||||
|
|
||||||
if (!checkForTwoFollowingSemicolons())
|
|
||||||
{
|
{
|
||||||
os::Printer::log("No finishing semicolon after matrix animation key in x file", ELL_WARNING);
|
os::Printer::log("No finishing semicolon after matrix animation key in x file", ELL_WARNING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//core::vector3df rotation = Matrix.getRotationDegrees();
|
//core::vector3df rotation = mat.getRotationDegrees();
|
||||||
|
|
||||||
ISkinnedMesh::SRotationKey *keyR=AnimatedMesh->createRotationKey(joint);
|
ISkinnedMesh::SRotationKey *keyR=AnimatedMesh->createRotationKey(joint);
|
||||||
keyR->frame=(f32)time;
|
keyR->frame=time;
|
||||||
//keyR->rotation.set(rotation.X*core::DEGTORAD,rotation.Y*core::DEGTORAD,rotation.Z*core::DEGTORAD);
|
keyR->rotation= core::quaternion(mat);
|
||||||
keyR->rotation= core::quaternion(Matrix);
|
|
||||||
|
|
||||||
|
|
||||||
ISkinnedMesh::SPositionKey *keyP=AnimatedMesh->createPositionKey(joint);
|
ISkinnedMesh::SPositionKey *keyP=AnimatedMesh->createPositionKey(joint);
|
||||||
keyP->frame=(f32)time;
|
keyP->frame=time;
|
||||||
keyP->position=Matrix.getTranslation();
|
keyP->position=mat.getTranslation();
|
||||||
|
|
||||||
core::vector3df scale=Matrix.getScale();
|
core::vector3df scale=mat.getScale();
|
||||||
|
|
||||||
//if (scale.X==0) scale.X=1;
|
//if (scale.X==0) scale.X=1;
|
||||||
//if (scale.Y==0) scale.Y=1;
|
//if (scale.Y==0) scale.Y=1;
|
||||||
//if (scale.Z==0) scale.Z=1;
|
//if (scale.Z==0) scale.Z=1;
|
||||||
/*
|
/*
|
||||||
ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->createScaleKey(joint);
|
ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->createScaleKey(joint);
|
||||||
keyS->frame=(f32)time;
|
keyS->frame=time;
|
||||||
keyS->scale=scale;
|
keyS->scale=scale;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -2081,10 +2052,11 @@ bool CXMeshFileLoader::readVector3(core::vector3df& vec)
|
||||||
// read color without alpha value. Stops after second semicolon after blue value
|
// read color without alpha value. Stops after second semicolon after blue value
|
||||||
bool CXMeshFileLoader::readRGB(video::SColor& color)
|
bool CXMeshFileLoader::readRGB(video::SColor& color)
|
||||||
{
|
{
|
||||||
color.setRed( (u32)(readFloat()*255.f)) ;
|
video::SColorf tmpColor;
|
||||||
color.setGreen( (u32)(readFloat()*255.f)) ;
|
tmpColor.r = readFloat();
|
||||||
color.setBlue( (u32)(readFloat()*255.f)) ;
|
tmpColor.g = readFloat();
|
||||||
color.setAlpha( 255 );
|
tmpColor.b = readFloat();
|
||||||
|
color = tmpColor.toSColor();
|
||||||
return checkForOneFollowingSemicolons();
|
return checkForOneFollowingSemicolons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2092,10 +2064,21 @@ bool CXMeshFileLoader::readRGB(video::SColor& color)
|
||||||
// read color with alpha value. Stops after second semicolon after blue value
|
// read color with alpha value. Stops after second semicolon after blue value
|
||||||
bool CXMeshFileLoader::readRGBA(video::SColor& color)
|
bool CXMeshFileLoader::readRGBA(video::SColor& color)
|
||||||
{
|
{
|
||||||
color.setRed( (u32)(readFloat()*255)) ;
|
video::SColorf tmpColor;
|
||||||
color.setGreen( (u32)(readFloat()*255)) ;
|
tmpColor.r = readFloat();
|
||||||
color.setBlue( (u32)(readFloat()*255)) ;
|
tmpColor.g = readFloat();
|
||||||
color.setAlpha( (u32)(readFloat()*255)) ;
|
tmpColor.b = readFloat();
|
||||||
|
tmpColor.a = readFloat();
|
||||||
|
color = tmpColor.toSColor();
|
||||||
|
return checkForOneFollowingSemicolons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// read matrix from list of floats
|
||||||
|
bool CXMeshFileLoader::readMatrix(core::matrix4& mat)
|
||||||
|
{
|
||||||
|
for (u32 i=0; i<16; ++i)
|
||||||
|
mat[i] = readFloat();
|
||||||
return checkForOneFollowingSemicolons();
|
return checkForOneFollowingSemicolons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ private:
|
||||||
f32 readFloat();
|
f32 readFloat();
|
||||||
bool readVector2(core::vector2df& vec);
|
bool readVector2(core::vector2df& vec);
|
||||||
bool readVector3(core::vector3df& vec);
|
bool readVector3(core::vector3df& vec);
|
||||||
|
bool readMatrix(core::matrix4& mat);
|
||||||
bool readRGB(video::SColor& color);
|
bool readRGB(video::SColor& color);
|
||||||
bool readRGBA(video::SColor& color);
|
bool readRGBA(video::SColor& color);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue