cleanup
This commit is contained in:
+18
-20
@@ -274,7 +274,6 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
|
||||
CString sLine;
|
||||
int iLineNum = 0;
|
||||
int nFlags, j;
|
||||
|
||||
while( f.GetLine( sLine ) > 0 )
|
||||
{
|
||||
@@ -287,17 +286,16 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
// bones
|
||||
//
|
||||
int nNumBones = 0;
|
||||
if (sscanf (sLine, "Bones: %d", &nNumBones) == 1)
|
||||
if( sscanf (sLine, "Bones: %d", &nNumBones) == 1 )
|
||||
{
|
||||
m_mapNameToAnimation[sAniName] = msAnimation();
|
||||
msAnimation &Animation = m_mapNameToAnimation[sAniName];
|
||||
|
||||
int i;
|
||||
char szName[MS_MAX_NAME];
|
||||
|
||||
Animation.Bones.resize( nNumBones );
|
||||
|
||||
for (i = 0; i < nNumBones; i++)
|
||||
for( int i = 0; i < nNumBones; i++ )
|
||||
{
|
||||
msBone& Bone = Animation.Bones[i];
|
||||
|
||||
@@ -326,6 +324,8 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
RageVector3 Position, Rotation;
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
|
||||
int nFlags;
|
||||
if (sscanf (sLine, "%d %f %f %f %f %f %f",
|
||||
&nFlags,
|
||||
&Position[0], &Position[1], &Position[2],
|
||||
@@ -337,8 +337,6 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
memcpy( &Bone.Position, &Position, sizeof(Bone.Position) );
|
||||
memcpy( &Bone.Rotation, &Rotation, sizeof(Bone.Rotation) );
|
||||
|
||||
float fTime;
|
||||
|
||||
// position key count
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
@@ -348,10 +346,12 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
|
||||
Bone.PositionKeys.resize( nNumPositionKeys );
|
||||
|
||||
for (j = 0; j < nNumPositionKeys; j++)
|
||||
for( int j = 0; j < nNumPositionKeys; ++j )
|
||||
{
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
|
||||
float fTime;
|
||||
if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4)
|
||||
THROW;
|
||||
|
||||
@@ -370,10 +370,12 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
|
||||
Bone.RotationKeys.resize( nNumRotationKeys );
|
||||
|
||||
for (j = 0; j < nNumRotationKeys; j++)
|
||||
for( int j = 0; j < nNumRotationKeys; ++j )
|
||||
{
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
|
||||
float fTime;
|
||||
if (sscanf (sLine, "%f %f %f %f", &fTime, &Rotation[0], &Rotation[1], &Rotation[2]) != 4)
|
||||
THROW;
|
||||
|
||||
@@ -386,17 +388,13 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
|
||||
// Ignore "Frames:" in file. Calculate it ourself
|
||||
Animation.nTotalFrames = 0;
|
||||
for ( i = 0; i < (int)Animation.Bones.size(); i++)
|
||||
for( int i = 0; i < (int)Animation.Bones.size(); i++ )
|
||||
{
|
||||
msBone& Bone = Animation.Bones[i];
|
||||
{
|
||||
for( int j=0; j<(int)Bone.PositionKeys.size(); j++ )
|
||||
Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.PositionKeys[j].fTime );
|
||||
}
|
||||
{
|
||||
for( int j=0; j<(int)Bone.RotationKeys.size(); j++ )
|
||||
Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.RotationKeys[j].fTime );
|
||||
}
|
||||
for( unsigned j = 0; j < Bone.PositionKeys.size(); ++j )
|
||||
Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.PositionKeys[j].fTime );
|
||||
for( unsigned j = 0; j < Bone.RotationKeys.size(); ++j )
|
||||
Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.RotationKeys[j].fTime );
|
||||
}
|
||||
|
||||
PlayAnimation( sAniName );
|
||||
@@ -799,7 +797,7 @@ void Model::Update( float fDelta )
|
||||
Actor::Update( fDelta );
|
||||
AdvanceFrame( fDelta );
|
||||
|
||||
for( int i=0; i<(int)m_Materials.size(); i++ )
|
||||
for( unsigned i = 0; i < m_Materials.size(); ++i )
|
||||
{
|
||||
m_Materials[i].diffuse.Update( fDelta );
|
||||
m_Materials[i].alpha.Update( fDelta );
|
||||
@@ -810,13 +808,13 @@ void Model::Update( float fDelta )
|
||||
//
|
||||
if( m_pGeometry && m_pTempGeometry )
|
||||
{
|
||||
for (int i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++)
|
||||
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
|
||||
{
|
||||
msMesh &origMesh = m_pGeometry->m_Meshes[i];
|
||||
msMesh &tempMesh = m_vTempMeshes[i];
|
||||
vector<RageModelVertex> &origVertices = origMesh.Vertices;
|
||||
vector<RageModelVertex> &tempVertices = tempMesh.Vertices;
|
||||
for (unsigned j = 0; j < origVertices.size(); j++)
|
||||
for( unsigned j = 0; j < origVertices.size(); j++ )
|
||||
{
|
||||
RageVector3& tempPos = tempVertices[j].p;
|
||||
RageVector3& originalPos = origVertices[j].p;
|
||||
|
||||
+15
-61
@@ -5,52 +5,19 @@
|
||||
|
||||
#define MS_MAX_NAME 32
|
||||
|
||||
#ifndef byte
|
||||
typedef unsigned char byte;
|
||||
#endif /* byte */
|
||||
|
||||
#ifndef word
|
||||
typedef unsigned short word;
|
||||
#endif /* word */
|
||||
|
||||
#include "RageTypes.h"
|
||||
|
||||
|
||||
/* msFlag */
|
||||
typedef enum {
|
||||
eSelected = 1, eSelected2 = 2, eHidden = 4, eDirty = 8, eAveraged = 16, eUnused = 32
|
||||
} msFlag;
|
||||
|
||||
/* msVertex */
|
||||
/*
|
||||
typedef struct msVertex
|
||||
struct msTriangle
|
||||
{
|
||||
// byte nFlags; // we don't care about saving this flag
|
||||
RageVector3 Vertex;
|
||||
RageVector3 Normal;
|
||||
RageVector2 uv;
|
||||
char nBoneIndex;
|
||||
} msVertex;
|
||||
*/
|
||||
|
||||
/* msTriangle */
|
||||
typedef struct
|
||||
{
|
||||
// word nFlags; // we don't care about saving this flag
|
||||
word nVertexIndices[3];
|
||||
// word nNormalIndices[3]; // we don't care about this. Use the normals in each vertex
|
||||
// msVec3 Normal; // we don't care about per-triangle normals. Each vertex has its own
|
||||
// byte nSmoothingGroup; // we don't care about this, so don't save it
|
||||
} msTriangle;
|
||||
uint16_t nVertexIndices[3];
|
||||
};
|
||||
|
||||
|
||||
/* msMesh */
|
||||
typedef struct msMesh
|
||||
struct msMesh
|
||||
{
|
||||
msMesh();
|
||||
~msMesh();
|
||||
|
||||
// byte nFlags; // we don't care about saving this flag
|
||||
char szName[MS_MAX_NAME];
|
||||
char nMaterialIndex;
|
||||
|
||||
@@ -62,9 +29,8 @@ typedef struct msMesh
|
||||
char nBoneIndex; // -1 = no bone
|
||||
|
||||
vector<msTriangle> Triangles;
|
||||
} msMesh;
|
||||
};
|
||||
|
||||
/* msMaterial */
|
||||
class RageTexture;
|
||||
|
||||
// merge this into Sprite?
|
||||
@@ -103,7 +69,7 @@ private:
|
||||
vector<AnimatedTextureState> vFrames;
|
||||
};
|
||||
|
||||
typedef struct msMaterial
|
||||
struct msMaterial
|
||||
{
|
||||
int nFlags;
|
||||
CString sName;
|
||||
@@ -117,24 +83,21 @@ typedef struct msMaterial
|
||||
|
||||
AnimatedTexture diffuse;
|
||||
AnimatedTexture alpha;
|
||||
} msMaterial;
|
||||
};
|
||||
|
||||
/* msPositionKey */
|
||||
typedef struct msPositionKey
|
||||
struct msPositionKey
|
||||
{
|
||||
float fTime;
|
||||
RageVector3 Position;
|
||||
} msPositionKey;
|
||||
};
|
||||
|
||||
/* msRotationKey */
|
||||
typedef struct msRotationKey
|
||||
struct msRotationKey
|
||||
{
|
||||
float fTime;
|
||||
RageVector3 Rotation;
|
||||
} msRotationKey;
|
||||
};
|
||||
|
||||
/* msBone */
|
||||
typedef struct msBone
|
||||
struct msBone
|
||||
{
|
||||
int nFlags;
|
||||
char szName[MS_MAX_NAME];
|
||||
@@ -147,15 +110,7 @@ typedef struct msBone
|
||||
int nNumRotationKeys;
|
||||
int nNumAllocedRotationKeys;
|
||||
vector<msRotationKey> RotationKeys;
|
||||
} msBone;
|
||||
|
||||
/* msModel */
|
||||
//typedef struct msModel
|
||||
//{
|
||||
// vector<msMesh> Meshes;
|
||||
//
|
||||
// vector<msMaterial> Materials;
|
||||
//} msModel;
|
||||
};
|
||||
|
||||
struct msAnimation
|
||||
{
|
||||
@@ -169,20 +124,19 @@ struct msAnimation
|
||||
return -1;
|
||||
}
|
||||
|
||||
// int nFrame; // not used in SM. We keep track of this outside this structure.
|
||||
int nTotalFrames;
|
||||
|
||||
RageVector3 Position;
|
||||
RageVector3 Rotation;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct myBone_t
|
||||
{
|
||||
RageMatrix mRelative;
|
||||
RageMatrix mAbsolute;
|
||||
RageMatrix mRelativeFinal;
|
||||
RageMatrix mFinal;
|
||||
} myBone_t;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
|
||||
|
||||
strcpy( mesh.szName, szName );
|
||||
// mesh.nFlags = nFlags;
|
||||
mesh.nMaterialIndex = (byte)nIndex;
|
||||
mesh.nMaterialIndex = (uint8_t) nIndex;
|
||||
|
||||
mesh.nBoneIndex = -1;
|
||||
|
||||
@@ -161,7 +161,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
|
||||
}
|
||||
|
||||
// vertex.nFlags = nFlags;
|
||||
v.bone = (byte)nIndex;
|
||||
v.bone = (uint8_t) nIndex;
|
||||
RageVec3AddToBounds( v.p, m_vMins, m_vMaxs );
|
||||
}
|
||||
|
||||
@@ -210,8 +210,8 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW
|
||||
|
||||
word nIndices[3];
|
||||
word nNormalIndices[3];
|
||||
uint16_t nIndices[3];
|
||||
uint16_t nNormalIndices[3];
|
||||
if (sscanf (sLine, "%d %hd %hd %hd %hd %hd %hd %d",
|
||||
&nFlags,
|
||||
&nIndices[0], &nIndices[1], &nIndices[2],
|
||||
|
||||
Reference in New Issue
Block a user