throw on model errors and don't fail silently
This commit is contained in:
+111
-222
@@ -51,6 +51,8 @@ void Model::Clear ()
|
|||||||
m_pCurAnimation = NULL;
|
m_pCurAnimation = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define THROW RageException::Throw( "Parse at line %d: '%s'", sLine.c_str() );
|
||||||
|
|
||||||
bool Model::LoadMilkshapeAscii( CString sPath )
|
bool Model::LoadMilkshapeAscii( CString sPath )
|
||||||
{
|
{
|
||||||
FixSlashesInPlace(sPath);
|
FixSlashesInPlace(sPath);
|
||||||
@@ -62,51 +64,47 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
|
|
||||||
Clear ();
|
Clear ();
|
||||||
|
|
||||||
bool bError = false;
|
CString sLine;
|
||||||
CString szLine;
|
int iLineNum = 0;
|
||||||
char szName[MS_MAX_NAME];
|
char szName[MS_MAX_NAME];
|
||||||
int nFlags, nIndex, i, j;
|
int nFlags, nIndex, i, j;
|
||||||
|
|
||||||
RageVec3ClearBounds( m_vMins, m_vMaxs );
|
RageVec3ClearBounds( m_vMins, m_vMaxs );
|
||||||
|
|
||||||
while( f.GetLine( szLine ) > 0 && !bError )
|
while( f.GetLine( sLine ) > 0 )
|
||||||
{
|
{
|
||||||
if (!strncmp (szLine, "//", 2))
|
iLineNum++;
|
||||||
|
|
||||||
|
if (!strncmp (sLine, "//", 2))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int nFrame;
|
int nFrame;
|
||||||
if (sscanf (szLine, "Frames: %d", &nFrame) == 1)
|
if (sscanf (sLine, "Frames: %d", &nFrame) == 1)
|
||||||
{
|
{
|
||||||
// ignore
|
// ignore
|
||||||
// m_pModel->nTotalFrames = nFrame;
|
// m_pModel->nTotalFrames = nFrame;
|
||||||
}
|
}
|
||||||
if (sscanf (szLine, "Frame: %d", &nFrame) == 1)
|
if (sscanf (sLine, "Frame: %d", &nFrame) == 1)
|
||||||
{
|
{
|
||||||
// ignore
|
// ignore
|
||||||
// m_pModel->nFrame = nFrame;
|
// m_pModel->nFrame = nFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nNumMeshes = 0;
|
int nNumMeshes = 0;
|
||||||
if (sscanf (szLine, "Meshes: %d", &nNumMeshes) == 1)
|
if (sscanf (sLine, "Meshes: %d", &nNumMeshes) == 1)
|
||||||
{
|
{
|
||||||
m_Meshes.resize( nNumMeshes );
|
m_Meshes.resize( nNumMeshes );
|
||||||
|
|
||||||
for (i = 0; i < nNumMeshes && !bError; i++)
|
for (i = 0; i < nNumMeshes; i++)
|
||||||
{
|
{
|
||||||
msMesh& mesh = m_Meshes[i];
|
msMesh& mesh = m_Meshes[i];
|
||||||
|
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// mesh: name, flags, material index
|
// mesh: name, flags, material index
|
||||||
if (sscanf (szLine, "\"%[^\"]\" %d %d",szName, &nFlags, &nIndex) != 3)
|
if (sscanf (sLine, "\"%[^\"]\" %d %d",szName, &nFlags, &nIndex) != 3)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy( mesh.szName, szName );
|
strcpy( mesh.szName, szName );
|
||||||
// mesh.nFlags = nFlags;
|
// mesh.nFlags = nFlags;
|
||||||
@@ -115,40 +113,30 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
//
|
//
|
||||||
// vertices
|
// vertices
|
||||||
//
|
//
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int nNumVertices = 0;
|
int nNumVertices = 0;
|
||||||
if (sscanf (szLine, "%d", &nNumVertices) != 1)
|
if (sscanf (sLine, "%d", &nNumVertices) != 1)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh.Vertices.resize( nNumVertices );
|
mesh.Vertices.resize( nNumVertices );
|
||||||
|
|
||||||
for (j = 0; j < nNumVertices; j++)
|
for (j = 0; j < nNumVertices; j++)
|
||||||
{
|
{
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
RageVector3 Vertex;
|
RageVector3 Vertex;
|
||||||
RageVector2 uv;
|
RageVector2 uv;
|
||||||
if (sscanf (szLine, "%d %f %f %f %f %f %d",
|
if (sscanf (sLine, "%d %f %f %f %f %f %d",
|
||||||
&nFlags,
|
&nFlags,
|
||||||
&Vertex[0], &Vertex[1], &Vertex[2],
|
&Vertex[0], &Vertex[1], &Vertex[2],
|
||||||
&uv[0], &uv[1],
|
&uv[0], &uv[1],
|
||||||
&nIndex
|
&nIndex
|
||||||
) != 7)
|
) != 7)
|
||||||
{
|
{
|
||||||
bError = true;
|
THROW
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msVertex& vertex = mesh.Vertices[j];
|
msVertex& vertex = mesh.Vertices[j];
|
||||||
@@ -164,35 +152,23 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
//
|
//
|
||||||
// normals
|
// normals
|
||||||
//
|
//
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int nNumNormals = 0;
|
int nNumNormals = 0;
|
||||||
if (sscanf (szLine, "%d", &nNumNormals) != 1)
|
if (sscanf (sLine, "%d", &nNumNormals) != 1)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<RageVector3> Normals;
|
vector<RageVector3> Normals;
|
||||||
Normals.resize( nNumNormals );
|
Normals.resize( nNumNormals );
|
||||||
for (j = 0; j < nNumNormals; j++)
|
for (j = 0; j < nNumNormals; j++)
|
||||||
{
|
{
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
RageVector3 Normal;
|
RageVector3 Normal;
|
||||||
if (sscanf (szLine, "%f %f %f", &Normal[0], &Normal[1], &Normal[2]) != 3)
|
if (sscanf (sLine, "%f %f %f", &Normal[0], &Normal[1], &Normal[2]) != 3)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
RageVec3Normalize( (RageVector3*)&Normal, (RageVector3*)&Normal );
|
RageVec3Normalize( (RageVector3*)&Normal, (RageVector3*)&Normal );
|
||||||
Normals[j] = Normal;
|
Normals[j] = Normal;
|
||||||
@@ -203,40 +179,30 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
//
|
//
|
||||||
// triangles
|
// triangles
|
||||||
//
|
//
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int nNumTriangles = 0;
|
int nNumTriangles = 0;
|
||||||
if (sscanf (szLine, "%d", &nNumTriangles) != 1)
|
if (sscanf (sLine, "%d", &nNumTriangles) != 1)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh.Triangles.resize( nNumTriangles );
|
mesh.Triangles.resize( nNumTriangles );
|
||||||
|
|
||||||
for (j = 0; j < nNumTriangles; j++)
|
for (j = 0; j < nNumTriangles; j++)
|
||||||
{
|
{
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
word nIndices[3];
|
word nIndices[3];
|
||||||
word nNormalIndices[3];
|
word nNormalIndices[3];
|
||||||
if (sscanf (szLine, "%d %hd %hd %hd %hd %hd %hd %d",
|
if (sscanf (sLine, "%d %hd %hd %hd %hd %hd %hd %d",
|
||||||
&nFlags,
|
&nFlags,
|
||||||
&nIndices[0], &nIndices[1], &nIndices[2],
|
&nIndices[0], &nIndices[1], &nIndices[2],
|
||||||
&nNormalIndices[0], &nNormalIndices[1], &nNormalIndices[2],
|
&nNormalIndices[0], &nNormalIndices[1], &nNormalIndices[2],
|
||||||
&nIndex
|
&nIndex
|
||||||
) != 8)
|
) != 8)
|
||||||
{
|
{
|
||||||
bError = true;
|
THROW
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// deflate the normals into vertices
|
// deflate the normals into vertices
|
||||||
@@ -260,124 +226,79 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
// materials
|
// materials
|
||||||
//
|
//
|
||||||
int nNumMaterials = 0;
|
int nNumMaterials = 0;
|
||||||
if (sscanf (szLine, "Materials: %d", &nNumMaterials) == 1)
|
if (sscanf (sLine, "Materials: %d", &nNumMaterials) == 1)
|
||||||
{
|
{
|
||||||
m_Materials.resize( nNumMaterials );
|
m_Materials.resize( nNumMaterials );
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
char szName[256];
|
char szName[256];
|
||||||
|
|
||||||
for (i = 0; i < nNumMaterials && !bError; i++)
|
for (i = 0; i < nNumMaterials; i++)
|
||||||
{
|
{
|
||||||
msMaterial& Material = m_Materials[i];
|
msMaterial& Material = m_Materials[i];
|
||||||
|
|
||||||
// name
|
// name
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
if (sscanf (sLine, "\"%[^\"]\"", szName) != 1)
|
||||||
break;
|
THROW
|
||||||
}
|
|
||||||
if (sscanf (szLine, "\"%[^\"]\"", szName) != 1)
|
|
||||||
{
|
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strcpy( Material.szName, szName );
|
strcpy( Material.szName, szName );
|
||||||
|
|
||||||
Material.bSphereMapped = ((CString)Material.szName).Find("sphere") != -1;
|
Material.bSphereMapped = ((CString)Material.szName).Find("sphere") != -1;
|
||||||
|
|
||||||
// ambient
|
// ambient
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
RageVector4 Ambient;
|
RageVector4 Ambient;
|
||||||
if (sscanf (szLine, "%f %f %f %f", &Ambient[0], &Ambient[1], &Ambient[2], &Ambient[3]) != 4)
|
if (sscanf (sLine, "%f %f %f %f", &Ambient[0], &Ambient[1], &Ambient[2], &Ambient[3]) != 4)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy( &Material.Ambient, &Ambient, sizeof(Material.Ambient) );
|
memcpy( &Material.Ambient, &Ambient, sizeof(Material.Ambient) );
|
||||||
|
|
||||||
// diffuse
|
// diffuse
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
RageVector4 Diffuse;
|
RageVector4 Diffuse;
|
||||||
if (sscanf (szLine, "%f %f %f %f", &Diffuse[0], &Diffuse[1], &Diffuse[2], &Diffuse[3]) != 4)
|
if (sscanf (sLine, "%f %f %f %f", &Diffuse[0], &Diffuse[1], &Diffuse[2], &Diffuse[3]) != 4)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy( &Material.Diffuse, &Diffuse, sizeof(Material.Diffuse) );
|
memcpy( &Material.Diffuse, &Diffuse, sizeof(Material.Diffuse) );
|
||||||
|
|
||||||
// specular
|
// specular
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
RageVector4 Specular;
|
RageVector4 Specular;
|
||||||
if (sscanf (szLine, "%f %f %f %f", &Specular[0], &Specular[1], &Specular[2], &Specular[3]) != 4)
|
if (sscanf (sLine, "%f %f %f %f", &Specular[0], &Specular[1], &Specular[2], &Specular[3]) != 4)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy( &Material.Specular, &Specular, sizeof(Material.Specular) );
|
memcpy( &Material.Specular, &Specular, sizeof(Material.Specular) );
|
||||||
|
|
||||||
// emissive
|
// emissive
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
RageVector4 Emissive;
|
RageVector4 Emissive;
|
||||||
if (sscanf (szLine, "%f %f %f %f", &Emissive[0], &Emissive[1], &Emissive[2], &Emissive[3]) != 4)
|
if (sscanf (sLine, "%f %f %f %f", &Emissive[0], &Emissive[1], &Emissive[2], &Emissive[3]) != 4)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy( &Material.Emissive, &Emissive, sizeof(Material.Emissive) );
|
memcpy( &Material.Emissive, &Emissive, sizeof(Material.Emissive) );
|
||||||
|
|
||||||
// shininess
|
// shininess
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
float fShininess;
|
float fShininess;
|
||||||
if (sscanf (szLine, "%f", &fShininess) != 1)
|
if (sscanf (sLine, "%f", &fShininess) != 1)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Material.fShininess = fShininess;
|
Material.fShininess = fShininess;
|
||||||
|
|
||||||
// transparency
|
// transparency
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
float fTransparency;
|
float fTransparency;
|
||||||
if (sscanf (szLine, "%f", &fTransparency) != 1)
|
if (sscanf (sLine, "%f", &fTransparency) != 1)
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Material.fTransparency = fTransparency;
|
Material.fTransparency = fTransparency;
|
||||||
|
|
||||||
// diffuse texture
|
// diffuse texture
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strcpy (szName, "");
|
strcpy (szName, "");
|
||||||
sscanf (szLine, "\"%[^\"]\"", szName);
|
sscanf (sLine, "\"%[^\"]\"", szName);
|
||||||
strcpy( Material.szDiffuseTexture, szName );
|
strcpy( Material.szDiffuseTexture, szName );
|
||||||
|
|
||||||
if( strcmp(Material.szDiffuseTexture, "")!=0 )
|
if( strcmp(Material.szDiffuseTexture, "")!=0 )
|
||||||
@@ -395,13 +316,10 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// alpha texture
|
// alpha texture
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strcpy (szName, "");
|
strcpy (szName, "");
|
||||||
sscanf (szLine, "\"%[^\"]\"", szName);
|
sscanf (sLine, "\"%[^\"]\"", szName);
|
||||||
strcpy( Material.szAlphaTexture, szName );
|
strcpy( Material.szAlphaTexture, szName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,20 +349,22 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
|||||||
if ( !f.Open(sPath) )
|
if ( !f.Open(sPath) )
|
||||||
RageException::Throw( "Model:: Could not open \"%s\": %s", sPath.c_str(), f.GetError().c_str() );
|
RageException::Throw( "Model:: Could not open \"%s\": %s", sPath.c_str(), f.GetError().c_str() );
|
||||||
|
|
||||||
bool bError = false;
|
CString sLine;
|
||||||
CString szLine;
|
int iLineNum = 0;
|
||||||
int nFlags, j;
|
int nFlags, j;
|
||||||
|
|
||||||
while( f.GetLine( szLine ) > 0 && !bError )
|
while( f.GetLine( sLine ) > 0 )
|
||||||
{
|
{
|
||||||
if (!strncmp (szLine, "//", 2))
|
iLineNum++;
|
||||||
|
|
||||||
|
if (!strncmp (sLine, "//", 2))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//
|
//
|
||||||
// bones
|
// bones
|
||||||
//
|
//
|
||||||
int nNumBones = 0;
|
int nNumBones = 0;
|
||||||
if (sscanf (szLine, "Bones: %d", &nNumBones) == 1)
|
if (sscanf (sLine, "Bones: %d", &nNumBones) == 1)
|
||||||
{
|
{
|
||||||
m_mapNameToAnimation[sAniName] = msAnimation();
|
m_mapNameToAnimation[sAniName] = msAnimation();
|
||||||
msAnimation &Animation = m_mapNameToAnimation[sAniName];
|
msAnimation &Animation = m_mapNameToAnimation[sAniName];
|
||||||
@@ -454,48 +374,41 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
|||||||
|
|
||||||
Animation.Bones.resize( nNumBones );
|
Animation.Bones.resize( nNumBones );
|
||||||
|
|
||||||
for (i = 0; i < nNumBones && !bError; i++)
|
for (i = 0; i < nNumBones; i++)
|
||||||
{
|
{
|
||||||
msBone& Bone = Animation.Bones[i];
|
msBone& Bone = Animation.Bones[i];
|
||||||
|
|
||||||
// name
|
// name
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
{
|
||||||
bError = true;
|
THROW;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (sscanf (szLine, "\"%[^\"]\"", szName) != 1)
|
if (sscanf (sLine, "\"%[^\"]\"", szName) != 1)
|
||||||
{
|
{
|
||||||
bError = true;
|
THROW;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
strcpy( Bone.szName, szName );
|
strcpy( Bone.szName, szName );
|
||||||
|
|
||||||
// parent
|
// parent
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
{
|
||||||
bError = true;
|
THROW;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
strcpy (szName, "");
|
strcpy (szName, "");
|
||||||
sscanf (szLine, "\"%[^\"]\"", szName);
|
sscanf (sLine, "\"%[^\"]\"", szName);
|
||||||
|
|
||||||
strcpy( Bone.szParentName, szName );
|
strcpy( Bone.szParentName, szName );
|
||||||
|
|
||||||
// flags, position, rotation
|
// flags, position, rotation
|
||||||
RageVector3 Position, Rotation;
|
RageVector3 Position, Rotation;
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW;
|
||||||
bError = true;
|
if (sscanf (sLine, "%d %f %f %f %f %f %f",
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (sscanf (szLine, "%d %f %f %f %f %f %f",
|
|
||||||
&nFlags,
|
&nFlags,
|
||||||
&Position[0], &Position[1], &Position[2],
|
&Position[0], &Position[1], &Position[2],
|
||||||
&Rotation[0], &Rotation[1], &Rotation[2]) != 7)
|
&Rotation[0], &Rotation[1], &Rotation[2]) != 7)
|
||||||
{
|
{
|
||||||
bError = true;
|
THROW;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Bone.nFlags = nFlags;
|
Bone.nFlags = nFlags;
|
||||||
memcpy( &Bone.Position, &Position, sizeof(Bone.Position) );
|
memcpy( &Bone.Position, &Position, sizeof(Bone.Position) );
|
||||||
@@ -504,32 +417,20 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
|||||||
float fTime;
|
float fTime;
|
||||||
|
|
||||||
// position key count
|
// position key count
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW;
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int nNumPositionKeys = 0;
|
int nNumPositionKeys = 0;
|
||||||
if (sscanf (szLine, "%d", &nNumPositionKeys) != 1)
|
if (sscanf (sLine, "%d", &nNumPositionKeys) != 1)
|
||||||
{
|
THROW;
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bone.PositionKeys.resize( nNumPositionKeys );
|
Bone.PositionKeys.resize( nNumPositionKeys );
|
||||||
|
|
||||||
for (j = 0; j < nNumPositionKeys; j++)
|
for (j = 0; j < nNumPositionKeys; j++)
|
||||||
{
|
{
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW;
|
||||||
bError = true;
|
if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4)
|
||||||
break;
|
THROW;
|
||||||
}
|
|
||||||
if (sscanf (szLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4)
|
|
||||||
{
|
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
msPositionKey key;
|
msPositionKey key;
|
||||||
key.fTime = fTime;
|
key.fTime = fTime;
|
||||||
@@ -538,32 +439,20 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// rotation key count
|
// rotation key count
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW;
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int nNumRotationKeys = 0;
|
int nNumRotationKeys = 0;
|
||||||
if (sscanf (szLine, "%d", &nNumRotationKeys) != 1)
|
if (sscanf (sLine, "%d", &nNumRotationKeys) != 1)
|
||||||
{
|
THROW;
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bone.RotationKeys.resize( nNumRotationKeys );
|
Bone.RotationKeys.resize( nNumRotationKeys );
|
||||||
|
|
||||||
for (j = 0; j < nNumRotationKeys; j++)
|
for (j = 0; j < nNumRotationKeys; j++)
|
||||||
{
|
{
|
||||||
if( f.GetLine( szLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
{
|
THROW;
|
||||||
bError = true;
|
if (sscanf (sLine, "%f %f %f %f", &fTime, &Rotation[0], &Rotation[1], &Rotation[2]) != 4)
|
||||||
break;
|
THROW;
|
||||||
}
|
|
||||||
if (sscanf (szLine, "%f %f %f %f", &fTime, &Rotation[0], &Rotation[1], &Rotation[2]) != 4)
|
|
||||||
{
|
|
||||||
bError = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
msRotationKey key;
|
msRotationKey key;
|
||||||
key.fTime = fTime;
|
key.fTime = fTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user