This commit is contained in:
Glenn Maynard
2004-08-19 00:42:31 +00:00
parent 39988e2d93
commit cc5dfc9653
3 changed files with 37 additions and 85 deletions
+14 -16
View File
@@ -274,7 +274,6 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
CString sLine; CString sLine;
int iLineNum = 0; int iLineNum = 0;
int nFlags, j;
while( f.GetLine( sLine ) > 0 ) while( f.GetLine( sLine ) > 0 )
{ {
@@ -292,12 +291,11 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
m_mapNameToAnimation[sAniName] = msAnimation(); m_mapNameToAnimation[sAniName] = msAnimation();
msAnimation &Animation = m_mapNameToAnimation[sAniName]; msAnimation &Animation = m_mapNameToAnimation[sAniName];
int i;
char szName[MS_MAX_NAME]; char szName[MS_MAX_NAME];
Animation.Bones.resize( nNumBones ); Animation.Bones.resize( nNumBones );
for (i = 0; i < nNumBones; i++) for( int i = 0; i < nNumBones; i++ )
{ {
msBone& Bone = Animation.Bones[i]; msBone& Bone = Animation.Bones[i];
@@ -326,6 +324,8 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
RageVector3 Position, Rotation; RageVector3 Position, Rotation;
if( f.GetLine( sLine ) <= 0 ) if( f.GetLine( sLine ) <= 0 )
THROW; THROW;
int nFlags;
if (sscanf (sLine, "%d %f %f %f %f %f %f", if (sscanf (sLine, "%d %f %f %f %f %f %f",
&nFlags, &nFlags,
&Position[0], &Position[1], &Position[2], &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.Position, &Position, sizeof(Bone.Position) );
memcpy( &Bone.Rotation, &Rotation, sizeof(Bone.Rotation) ); memcpy( &Bone.Rotation, &Rotation, sizeof(Bone.Rotation) );
float fTime;
// position key count // position key count
if( f.GetLine( sLine ) <= 0 ) if( f.GetLine( sLine ) <= 0 )
THROW; THROW;
@@ -348,10 +346,12 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
Bone.PositionKeys.resize( nNumPositionKeys ); Bone.PositionKeys.resize( nNumPositionKeys );
for (j = 0; j < nNumPositionKeys; j++) for( int j = 0; j < nNumPositionKeys; ++j )
{ {
if( f.GetLine( sLine ) <= 0 ) if( f.GetLine( sLine ) <= 0 )
THROW; THROW;
float fTime;
if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4) if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4)
THROW; THROW;
@@ -370,10 +370,12 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
Bone.RotationKeys.resize( nNumRotationKeys ); Bone.RotationKeys.resize( nNumRotationKeys );
for (j = 0; j < nNumRotationKeys; j++) for( int j = 0; j < nNumRotationKeys; ++j )
{ {
if( f.GetLine( sLine ) <= 0 ) if( f.GetLine( sLine ) <= 0 )
THROW; THROW;
float fTime;
if (sscanf (sLine, "%f %f %f %f", &fTime, &Rotation[0], &Rotation[1], &Rotation[2]) != 4) if (sscanf (sLine, "%f %f %f %f", &fTime, &Rotation[0], &Rotation[1], &Rotation[2]) != 4)
THROW; THROW;
@@ -386,18 +388,14 @@ void Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
// Ignore "Frames:" in file. Calculate it ourself // Ignore "Frames:" in file. Calculate it ourself
Animation.nTotalFrames = 0; 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]; msBone& Bone = Animation.Bones[i];
{ for( unsigned j = 0; j < Bone.PositionKeys.size(); ++j )
for( int j=0; j<(int)Bone.PositionKeys.size(); j++ )
Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.PositionKeys[j].fTime ); Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.PositionKeys[j].fTime );
} for( unsigned j = 0; j < Bone.RotationKeys.size(); ++j )
{
for( int j=0; j<(int)Bone.RotationKeys.size(); j++ )
Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.RotationKeys[j].fTime ); Animation.nTotalFrames = max( Animation.nTotalFrames, (int)Bone.RotationKeys[j].fTime );
} }
}
PlayAnimation( sAniName ); PlayAnimation( sAniName );
} }
@@ -799,7 +797,7 @@ void Model::Update( float fDelta )
Actor::Update( fDelta ); Actor::Update( fDelta );
AdvanceFrame( 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].diffuse.Update( fDelta );
m_Materials[i].alpha.Update( fDelta ); m_Materials[i].alpha.Update( fDelta );
@@ -810,7 +808,7 @@ void Model::Update( float fDelta )
// //
if( m_pGeometry && m_pTempGeometry ) 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 &origMesh = m_pGeometry->m_Meshes[i];
msMesh &tempMesh = m_vTempMeshes[i]; msMesh &tempMesh = m_vTempMeshes[i];
+15 -61
View File
@@ -5,52 +5,19 @@
#define MS_MAX_NAME 32 #define MS_MAX_NAME 32
#ifndef byte
typedef unsigned char byte;
#endif /* byte */
#ifndef word
typedef unsigned short word;
#endif /* word */
#include "RageTypes.h" #include "RageTypes.h"
struct msTriangle
/* msFlag */
typedef enum {
eSelected = 1, eSelected2 = 2, eHidden = 4, eDirty = 8, eAveraged = 16, eUnused = 32
} msFlag;
/* msVertex */
/*
typedef struct msVertex
{ {
// byte nFlags; // we don't care about saving this flag uint16_t nVertexIndices[3];
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;
/* msMesh */ struct msMesh
typedef struct msMesh
{ {
msMesh(); msMesh();
~msMesh(); ~msMesh();
// byte nFlags; // we don't care about saving this flag
char szName[MS_MAX_NAME]; char szName[MS_MAX_NAME];
char nMaterialIndex; char nMaterialIndex;
@@ -62,9 +29,8 @@ typedef struct msMesh
char nBoneIndex; // -1 = no bone char nBoneIndex; // -1 = no bone
vector<msTriangle> Triangles; vector<msTriangle> Triangles;
} msMesh; };
/* msMaterial */
class RageTexture; class RageTexture;
// merge this into Sprite? // merge this into Sprite?
@@ -103,7 +69,7 @@ private:
vector<AnimatedTextureState> vFrames; vector<AnimatedTextureState> vFrames;
}; };
typedef struct msMaterial struct msMaterial
{ {
int nFlags; int nFlags;
CString sName; CString sName;
@@ -117,24 +83,21 @@ typedef struct msMaterial
AnimatedTexture diffuse; AnimatedTexture diffuse;
AnimatedTexture alpha; AnimatedTexture alpha;
} msMaterial; };
/* msPositionKey */ struct msPositionKey
typedef struct msPositionKey
{ {
float fTime; float fTime;
RageVector3 Position; RageVector3 Position;
} msPositionKey; };
/* msRotationKey */ struct msRotationKey
typedef struct msRotationKey
{ {
float fTime; float fTime;
RageVector3 Rotation; RageVector3 Rotation;
} msRotationKey; };
/* msBone */ struct msBone
typedef struct msBone
{ {
int nFlags; int nFlags;
char szName[MS_MAX_NAME]; char szName[MS_MAX_NAME];
@@ -147,15 +110,7 @@ typedef struct msBone
int nNumRotationKeys; int nNumRotationKeys;
int nNumAllocedRotationKeys; int nNumAllocedRotationKeys;
vector<msRotationKey> RotationKeys; vector<msRotationKey> RotationKeys;
} msBone; };
/* msModel */
//typedef struct msModel
//{
// vector<msMesh> Meshes;
//
// vector<msMaterial> Materials;
//} msModel;
struct msAnimation struct msAnimation
{ {
@@ -169,20 +124,19 @@ struct msAnimation
return -1; return -1;
} }
// int nFrame; // not used in SM. We keep track of this outside this structure.
int nTotalFrames; int nTotalFrames;
RageVector3 Position; RageVector3 Position;
RageVector3 Rotation; RageVector3 Rotation;
}; };
typedef struct struct myBone_t
{ {
RageMatrix mRelative; RageMatrix mRelative;
RageMatrix mAbsolute; RageMatrix mAbsolute;
RageMatrix mRelativeFinal; RageMatrix mRelativeFinal;
RageMatrix mFinal; RageMatrix mFinal;
} myBone_t; };
#endif #endif
+4 -4
View File
@@ -127,7 +127,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
strcpy( mesh.szName, szName ); strcpy( mesh.szName, szName );
// mesh.nFlags = nFlags; // mesh.nFlags = nFlags;
mesh.nMaterialIndex = (byte)nIndex; mesh.nMaterialIndex = (uint8_t) nIndex;
mesh.nBoneIndex = -1; mesh.nBoneIndex = -1;
@@ -161,7 +161,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
} }
// vertex.nFlags = nFlags; // vertex.nFlags = nFlags;
v.bone = (byte)nIndex; v.bone = (uint8_t) nIndex;
RageVec3AddToBounds( v.p, m_vMins, m_vMaxs ); RageVec3AddToBounds( v.p, m_vMins, m_vMaxs );
} }
@@ -210,8 +210,8 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
if( f.GetLine( sLine ) <= 0 ) if( f.GetLine( sLine ) <= 0 )
THROW THROW
word nIndices[3]; uint16_t nIndices[3];
word nNormalIndices[3]; uint16_t nNormalIndices[3];
if (sscanf (sLine, "%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],