pass bNeedsNormals into RageCompiledGeometry
This commit is contained in:
+15
-3
@@ -94,11 +94,13 @@ void Model::LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBo
|
|||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
ASSERT( m_pGeometry == NULL );
|
// TRICKY: Load materials before geometry so we can figure out whether the materials require normals.
|
||||||
m_pGeometry = MODELMAN->LoadMilkshapeAscii( sMeshesPath );
|
|
||||||
|
|
||||||
LoadMaterialsFromMilkshapeAscii( sMaterialsPath );
|
LoadMaterialsFromMilkshapeAscii( sMaterialsPath );
|
||||||
|
|
||||||
|
ASSERT( m_pGeometry == NULL );
|
||||||
|
m_pGeometry = MODELMAN->LoadMilkshapeAscii( sMeshesPath, this->MaterialsNeedNormals() );
|
||||||
|
|
||||||
if( LoadMilkshapeAsciiBones( DEFAULT_ANIMATION_NAME, sBonesPath ) )
|
if( LoadMilkshapeAsciiBones( DEFAULT_ANIMATION_NAME, sBonesPath ) )
|
||||||
PlayAnimation( DEFAULT_ANIMATION_NAME );
|
PlayAnimation( DEFAULT_ANIMATION_NAME );
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@ void Model::LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBo
|
|||||||
{
|
{
|
||||||
m_vTempMeshes = m_pGeometry->m_Meshes;
|
m_vTempMeshes = m_pGeometry->m_Meshes;
|
||||||
m_pTempGeometry = DISPLAY->CreateCompiledGeometry();
|
m_pTempGeometry = DISPLAY->CreateCompiledGeometry();
|
||||||
m_pTempGeometry->Set( m_vTempMeshes );
|
m_pTempGeometry->Set( m_vTempMeshes, this->MaterialsNeedNormals() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,6 +764,16 @@ void Model::HandleCommand( const Command &command )
|
|||||||
EndHandleArgs;
|
EndHandleArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::MaterialsNeedNormals() const
|
||||||
|
{
|
||||||
|
FOREACH_CONST( msMaterial, m_Materials, m )
|
||||||
|
{
|
||||||
|
if( m->NeedsNormals() )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Chris Danford
|
* (c) 2003-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ public:
|
|||||||
void SetDefaultAnimation( CString sAnimation, float fPlayRate = 1 );
|
void SetDefaultAnimation( CString sAnimation, float fPlayRate = 1 );
|
||||||
bool m_bRevertToDefaultAnimation;
|
bool m_bRevertToDefaultAnimation;
|
||||||
|
|
||||||
|
bool MaterialsNeedNormals() const;
|
||||||
|
|
||||||
virtual void HandleCommand( const Command &command );
|
virtual void HandleCommand( const Command &command );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ ModelManager::~ModelManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RageModelGeometry* ModelManager::LoadMilkshapeAscii( CString sFile )
|
RageModelGeometry* ModelManager::LoadMilkshapeAscii( const CString& sFile, bool bNeedNormals )
|
||||||
{
|
{
|
||||||
std::map<CString, RageModelGeometry*>::iterator p = m_mapFileToModel.find(sFile);
|
std::map<CString, RageModelGeometry*>::iterator p = m_mapFileToModel.find(sFile);
|
||||||
if(p != m_mapFileToModel.end())
|
if(p != m_mapFileToModel.end())
|
||||||
@@ -38,7 +38,7 @@ RageModelGeometry* ModelManager::LoadMilkshapeAscii( CString sFile )
|
|||||||
}
|
}
|
||||||
|
|
||||||
RageModelGeometry* pModel = new RageModelGeometry;
|
RageModelGeometry* pModel = new RageModelGeometry;
|
||||||
pModel->LoadMilkshapeAscii( sFile );
|
pModel->LoadMilkshapeAscii( sFile, bNeedNormals );
|
||||||
|
|
||||||
m_mapFileToModel[sFile] = pModel;
|
m_mapFileToModel[sFile] = pModel;
|
||||||
return pModel;
|
return pModel;
|
||||||
@@ -75,12 +75,13 @@ void ModelManager::UnloadModel( RageModelGeometry *m )
|
|||||||
ASSERT(0); // we tried to delete a texture that wasn't loaded.
|
ASSERT(0); // we tried to delete a texture that wasn't loaded.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelManager::SetPrefs( ModelManagerPrefs prefs )
|
bool ModelManager::SetPrefs( const ModelManagerPrefs& prefs )
|
||||||
{
|
{
|
||||||
m_Prefs = prefs;
|
m_Prefs = prefs;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Chris Danford
|
* (c) 2003-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ public:
|
|||||||
ModelManager();
|
ModelManager();
|
||||||
~ModelManager();
|
~ModelManager();
|
||||||
|
|
||||||
RageModelGeometry* LoadMilkshapeAscii( CString sFile );
|
RageModelGeometry* LoadMilkshapeAscii( const CString& sFile, bool bNeedNormals );
|
||||||
void UnloadModel( RageModelGeometry *m );
|
void UnloadModel( RageModelGeometry *m );
|
||||||
// void ReloadAll();
|
// void ReloadAll();
|
||||||
|
|
||||||
bool SetPrefs( ModelManagerPrefs prefs );
|
bool SetPrefs( const ModelManagerPrefs& prefs ); // returns true if needs display to be reset
|
||||||
ModelManagerPrefs GetPrefs() { return m_Prefs; }
|
const ModelManagerPrefs& GetPrefs() { return m_Prefs; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public:
|
|||||||
float m_fTexVelocityY;
|
float m_fTexVelocityY;
|
||||||
BlendMode m_BlendMode;
|
BlendMode m_BlendMode;
|
||||||
|
|
||||||
|
bool NeedsNormals() const { return m_bSphereMapped; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int m_iCurState;
|
int m_iCurState;
|
||||||
@@ -83,6 +85,8 @@ struct msMaterial
|
|||||||
|
|
||||||
AnimatedTexture diffuse;
|
AnimatedTexture diffuse;
|
||||||
AnimatedTexture alpha;
|
AnimatedTexture alpha;
|
||||||
|
|
||||||
|
bool NeedsNormals() const { return diffuse.NeedsNormals() || alpha.NeedsNormals() ; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct msPositionKey
|
struct msPositionKey
|
||||||
|
|||||||
@@ -17,10 +17,15 @@ const int MAX_TEXTURE_UNITS = 2;
|
|||||||
class RageCompiledGeometry
|
class RageCompiledGeometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~RageCompiledGeometry() { }
|
virtual ~RageCompiledGeometry()
|
||||||
|
|
||||||
void Set( const vector<msMesh> &vMeshes )
|
|
||||||
{
|
{
|
||||||
|
m_bNeedsNormals = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set( const vector<msMesh> &vMeshes, bool bNeedsNormals )
|
||||||
|
{
|
||||||
|
m_bNeedsNormals = bNeedsNormals;
|
||||||
|
|
||||||
size_t totalVerts = 0;
|
size_t totalVerts = 0;
|
||||||
size_t totalTriangles = 0;
|
size_t totalTriangles = 0;
|
||||||
|
|
||||||
@@ -63,6 +68,7 @@ protected:
|
|||||||
int iTriangleCount;
|
int iTriangleCount;
|
||||||
};
|
};
|
||||||
vector<MeshInfo> m_vMeshInfo;
|
vector<MeshInfo> m_vMeshInfo;
|
||||||
|
bool m_bNeedsNormals;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RageDisplay
|
class RageDisplay
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ bool RageModelGeometry::HasAnyPerVertexBones() const
|
|||||||
|
|
||||||
#define THROW RageException::Throw( "Parse error in \"%s\" at line %d: '%s'", sPath.c_str(), iLineNum, sLine.c_str() );
|
#define THROW RageException::Throw( "Parse error in \"%s\" at line %d: '%s'", sPath.c_str(), iLineNum, sLine.c_str() );
|
||||||
|
|
||||||
void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
|
void RageModelGeometry::LoadMilkshapeAscii( const CString& _sPath, bool bNeedsNormals )
|
||||||
{
|
{
|
||||||
|
CString sPath = _sPath;
|
||||||
FixSlashesInPlace(sPath);
|
FixSlashesInPlace(sPath);
|
||||||
const CString sDir = Dirname( sPath );
|
const CString sDir = Dirname( sPath );
|
||||||
|
|
||||||
@@ -264,7 +265,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
|
|||||||
OptimizeBones();
|
OptimizeBones();
|
||||||
|
|
||||||
// send the finalized vertices to the graphics card
|
// send the finalized vertices to the graphics card
|
||||||
m_pCompiledGeometry->Set( m_Meshes );
|
m_pCompiledGeometry->Set( m_Meshes, bNeedsNormals );
|
||||||
|
|
||||||
f.Close();
|
f.Close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ public:
|
|||||||
RageModelGeometry ();
|
RageModelGeometry ();
|
||||||
virtual ~RageModelGeometry ();
|
virtual ~RageModelGeometry ();
|
||||||
|
|
||||||
public:
|
void LoadMilkshapeAscii( const CString& sMilkshapeAsciiFile, bool bNeedsNormals );
|
||||||
void LoadMilkshapeAscii( CString sMilkshapeAsciiFile );
|
|
||||||
void OptimizeBones();
|
void OptimizeBones();
|
||||||
bool HasAnyPerVertexBones() const;
|
bool HasAnyPerVertexBones() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user