pass bNeedsNormals into RageCompiledGeometry
This commit is contained in:
+16
-4
@@ -94,11 +94,13 @@ void Model::LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBo
|
||||
{
|
||||
Clear();
|
||||
|
||||
ASSERT( m_pGeometry == NULL );
|
||||
m_pGeometry = MODELMAN->LoadMilkshapeAscii( sMeshesPath );
|
||||
|
||||
// TRICKY: Load materials before geometry so we can figure out whether the materials require normals.
|
||||
|
||||
LoadMaterialsFromMilkshapeAscii( sMaterialsPath );
|
||||
|
||||
ASSERT( m_pGeometry == NULL );
|
||||
m_pGeometry = MODELMAN->LoadMilkshapeAscii( sMeshesPath, this->MaterialsNeedNormals() );
|
||||
|
||||
if( LoadMilkshapeAsciiBones( DEFAULT_ANIMATION_NAME, sBonesPath ) )
|
||||
PlayAnimation( DEFAULT_ANIMATION_NAME );
|
||||
|
||||
@@ -110,7 +112,7 @@ void Model::LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBo
|
||||
{
|
||||
m_vTempMeshes = m_pGeometry->m_Meshes;
|
||||
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;
|
||||
}
|
||||
|
||||
bool Model::MaterialsNeedNormals() const
|
||||
{
|
||||
FOREACH_CONST( msMaterial, m_Materials, m )
|
||||
{
|
||||
if( m->NeedsNormals() )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
void SetDefaultAnimation( CString sAnimation, float fPlayRate = 1 );
|
||||
bool m_bRevertToDefaultAnimation;
|
||||
|
||||
bool MaterialsNeedNormals() const;
|
||||
|
||||
virtual void HandleCommand( const Command &command );
|
||||
|
||||
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);
|
||||
if(p != m_mapFileToModel.end())
|
||||
@@ -38,7 +38,7 @@ RageModelGeometry* ModelManager::LoadMilkshapeAscii( CString sFile )
|
||||
}
|
||||
|
||||
RageModelGeometry* pModel = new RageModelGeometry;
|
||||
pModel->LoadMilkshapeAscii( sFile );
|
||||
pModel->LoadMilkshapeAscii( sFile, bNeedNormals );
|
||||
|
||||
m_mapFileToModel[sFile] = pModel;
|
||||
return pModel;
|
||||
@@ -75,12 +75,13 @@ void ModelManager::UnloadModel( RageModelGeometry *m )
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -32,12 +32,12 @@ public:
|
||||
ModelManager();
|
||||
~ModelManager();
|
||||
|
||||
RageModelGeometry* LoadMilkshapeAscii( CString sFile );
|
||||
RageModelGeometry* LoadMilkshapeAscii( const CString& sFile, bool bNeedNormals );
|
||||
void UnloadModel( RageModelGeometry *m );
|
||||
// void ReloadAll();
|
||||
|
||||
bool SetPrefs( ModelManagerPrefs prefs );
|
||||
ModelManagerPrefs GetPrefs() { return m_Prefs; }
|
||||
bool SetPrefs( const ModelManagerPrefs& prefs ); // returns true if needs display to be reset
|
||||
const ModelManagerPrefs& GetPrefs() { return m_Prefs; }
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ public:
|
||||
float m_fTexVelocityY;
|
||||
BlendMode m_BlendMode;
|
||||
|
||||
bool NeedsNormals() const { return m_bSphereMapped; }
|
||||
|
||||
private:
|
||||
|
||||
int m_iCurState;
|
||||
@@ -83,6 +85,8 @@ struct msMaterial
|
||||
|
||||
AnimatedTexture diffuse;
|
||||
AnimatedTexture alpha;
|
||||
|
||||
bool NeedsNormals() const { return diffuse.NeedsNormals() || alpha.NeedsNormals() ; }
|
||||
};
|
||||
|
||||
struct msPositionKey
|
||||
|
||||
@@ -17,10 +17,15 @@ const int MAX_TEXTURE_UNITS = 2;
|
||||
class RageCompiledGeometry
|
||||
{
|
||||
public:
|
||||
virtual ~RageCompiledGeometry() { }
|
||||
|
||||
void Set( const vector<msMesh> &vMeshes )
|
||||
virtual ~RageCompiledGeometry()
|
||||
{
|
||||
m_bNeedsNormals = false;
|
||||
}
|
||||
|
||||
void Set( const vector<msMesh> &vMeshes, bool bNeedsNormals )
|
||||
{
|
||||
m_bNeedsNormals = bNeedsNormals;
|
||||
|
||||
size_t totalVerts = 0;
|
||||
size_t totalTriangles = 0;
|
||||
|
||||
@@ -50,7 +55,7 @@ public:
|
||||
virtual void Allocate( const vector<msMesh> &vMeshes ) = 0; // allocate space
|
||||
virtual void Change( const vector<msMesh> &vMeshes ) = 0; // new data must be the same size as was passed to Set()
|
||||
virtual void Draw( int iMeshIndex ) const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
size_t GetTotalVertices() { if( m_vMeshInfo.empty() ) return 0; return m_vMeshInfo.back().iVertexStart + m_vMeshInfo.back().iVertexCount; }
|
||||
size_t GetTotalTriangles() { if( m_vMeshInfo.empty() ) return 0; return m_vMeshInfo.back().iTriangleStart + m_vMeshInfo.back().iTriangleCount; }
|
||||
@@ -63,6 +68,7 @@ protected:
|
||||
int iTriangleCount;
|
||||
};
|
||||
vector<MeshInfo> m_vMeshInfo;
|
||||
bool m_bNeedsNormals;
|
||||
};
|
||||
|
||||
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() );
|
||||
|
||||
void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
|
||||
void RageModelGeometry::LoadMilkshapeAscii( const CString& _sPath, bool bNeedsNormals )
|
||||
{
|
||||
CString sPath = _sPath;
|
||||
FixSlashesInPlace(sPath);
|
||||
const CString sDir = Dirname( sPath );
|
||||
|
||||
@@ -264,7 +265,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath )
|
||||
OptimizeBones();
|
||||
|
||||
// send the finalized vertices to the graphics card
|
||||
m_pCompiledGeometry->Set( m_Meshes );
|
||||
m_pCompiledGeometry->Set( m_Meshes, bNeedsNormals );
|
||||
|
||||
f.Close();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ public:
|
||||
RageModelGeometry ();
|
||||
virtual ~RageModelGeometry ();
|
||||
|
||||
public:
|
||||
void LoadMilkshapeAscii( CString sMilkshapeAsciiFile );
|
||||
void LoadMilkshapeAscii( const CString& sMilkshapeAsciiFile, bool bNeedsNormals );
|
||||
void OptimizeBones();
|
||||
bool HasAnyPerVertexBones() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user