split out DrawMesh
cleanup
This commit is contained in:
+33
-50
@@ -438,25 +438,15 @@ void Model::DrawPrimitives()
|
|||||||
{
|
{
|
||||||
DISPLAY->SetTextureModeModulate();
|
DISPLAY->SetTextureModeModulate();
|
||||||
|
|
||||||
for (int i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++)
|
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
|
||||||
{
|
{
|
||||||
msMesh *pMesh = &m_pGeometry->m_Meshes[i];
|
const msMesh *pMesh = &m_pGeometry->m_Meshes[i];
|
||||||
const RageCompiledGeometry* TempGeometry = m_pTempGeometry ? m_pTempGeometry : m_pGeometry->m_pGeometry;
|
|
||||||
|
|
||||||
// apply mesh-specific bone (if any)
|
|
||||||
if( pMesh->nBoneIndex != -1 )
|
|
||||||
{
|
|
||||||
DISPLAY->PushMatrix();
|
|
||||||
|
|
||||||
RageMatrix &mat = m_vpBones[pMesh->nBoneIndex].mFinal;
|
|
||||||
DISPLAY->PreMultMatrix( mat );
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY->TexturePushMatrix();
|
DISPLAY->TexturePushMatrix();
|
||||||
|
|
||||||
if( pMesh->nMaterialIndex != -1 ) // has a material
|
if( pMesh->nMaterialIndex != -1 ) // has a material
|
||||||
{
|
{
|
||||||
// apply material
|
// apply material
|
||||||
msMaterial& mat = m_Materials[ pMesh->nMaterialIndex ];
|
msMaterial& mat = m_Materials[ pMesh->nMaterialIndex ];
|
||||||
|
|
||||||
RageColor Emissive = mat.Emissive;
|
RageColor Emissive = mat.Emissive;
|
||||||
@@ -469,15 +459,13 @@ void Model::DrawPrimitives()
|
|||||||
|
|
||||||
DISPLAY->SetMaterial( Emissive, Ambient, Diffuse, mat.Specular, mat.fShininess );
|
DISPLAY->SetMaterial( Emissive, Ambient, Diffuse, mat.Specular, mat.fShininess );
|
||||||
|
|
||||||
float fScrollX = 0;
|
|
||||||
float fScrollY = 0;
|
|
||||||
if( mat.diffuse.m_fTexVelocityX != 0 || mat.diffuse.m_fTexVelocityY != 0 )
|
if( mat.diffuse.m_fTexVelocityX != 0 || mat.diffuse.m_fTexVelocityY != 0 )
|
||||||
{
|
{
|
||||||
fScrollX = mat.diffuse.m_fTexVelocityX * mat.diffuse.GetSecondsIntoAnimation() / mat.diffuse.GetAnimationLengthSeconds();
|
float fScrollX = mat.diffuse.m_fTexVelocityX * mat.diffuse.GetSecondsIntoAnimation() / mat.diffuse.GetAnimationLengthSeconds();
|
||||||
fScrollY = mat.diffuse.m_fTexVelocityY * mat.diffuse.GetSecondsIntoAnimation() / mat.diffuse.GetAnimationLengthSeconds();
|
float fScrollY = mat.diffuse.m_fTexVelocityY * mat.diffuse.GetSecondsIntoAnimation() / mat.diffuse.GetAnimationLengthSeconds();
|
||||||
DISPLAY->SetTextureWrapping( true );
|
DISPLAY->SetTextureWrapping( true );
|
||||||
|
DISPLAY->TextureTranslate( fScrollX, fScrollY, 0 );
|
||||||
}
|
}
|
||||||
DISPLAY->TextureTranslate( fScrollX, fScrollY, 0 );
|
|
||||||
|
|
||||||
// render the first pass with texture 1
|
// render the first pass with texture 1
|
||||||
DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() );
|
DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() );
|
||||||
@@ -505,16 +493,10 @@ void Model::DrawPrimitives()
|
|||||||
DISPLAY->SetSphereEnironmentMapping( false );
|
DISPLAY->SetSphereEnironmentMapping( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw it
|
DrawMesh( i );
|
||||||
DISPLAY->DrawCompiledGeometry( TempGeometry, i, m_pGeometry->m_Meshes );
|
|
||||||
DISPLAY->SetSphereEnironmentMapping( false );
|
DISPLAY->SetSphereEnironmentMapping( false );
|
||||||
|
|
||||||
DISPLAY->TexturePopMatrix();
|
DISPLAY->TexturePopMatrix();
|
||||||
|
|
||||||
if( pMesh->nBoneIndex != -1 )
|
|
||||||
{
|
|
||||||
DISPLAY->PopMatrix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,10 +507,9 @@ void Model::DrawPrimitives()
|
|||||||
{
|
{
|
||||||
DISPLAY->SetTextureModeGlow();
|
DISPLAY->SetTextureModeGlow();
|
||||||
|
|
||||||
for (int i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++)
|
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
|
||||||
{
|
{
|
||||||
msMesh *pMesh = &m_pGeometry->m_Meshes[i];
|
const msMesh *pMesh = &m_pGeometry->m_Meshes[i];
|
||||||
const RageCompiledGeometry* TempGeometry = m_pTempGeometry ? m_pTempGeometry : m_pGeometry->m_pGeometry;
|
|
||||||
|
|
||||||
// apply material
|
// apply material
|
||||||
RageColor emissive = RageColor(0,0,0,0);
|
RageColor emissive = RageColor(0,0,0,0);
|
||||||
@@ -537,12 +518,7 @@ void Model::DrawPrimitives()
|
|||||||
RageColor specular = RageColor(0,0,0,0);
|
RageColor specular = RageColor(0,0,0,0);
|
||||||
float shininess = 1;
|
float shininess = 1;
|
||||||
|
|
||||||
DISPLAY->SetMaterial(
|
DISPLAY->SetMaterial( emissive, ambient, diffuse, specular, shininess );
|
||||||
emissive,
|
|
||||||
ambient,
|
|
||||||
diffuse,
|
|
||||||
specular,
|
|
||||||
shininess );
|
|
||||||
DISPLAY->ClearAllTextures();
|
DISPLAY->ClearAllTextures();
|
||||||
|
|
||||||
if( pMesh->nMaterialIndex != -1 )
|
if( pMesh->nMaterialIndex != -1 )
|
||||||
@@ -554,25 +530,32 @@ void Model::DrawPrimitives()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply mesh-specific bone (if any)
|
DrawMesh( i );
|
||||||
if( pMesh->nBoneIndex != -1 )
|
|
||||||
{
|
|
||||||
DISPLAY->PushMatrix();
|
|
||||||
|
|
||||||
RageMatrix &mat = m_vpBones[pMesh->nBoneIndex].mFinal;
|
|
||||||
DISPLAY->PreMultMatrix( mat );
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY->DrawCompiledGeometry( TempGeometry, i, m_pGeometry->m_Meshes );
|
|
||||||
|
|
||||||
if( pMesh->nBoneIndex != -1 )
|
|
||||||
{
|
|
||||||
DISPLAY->PopMatrix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Model::DrawMesh( int i ) const
|
||||||
|
{
|
||||||
|
const msMesh *pMesh = &m_pGeometry->m_Meshes[i];
|
||||||
|
|
||||||
|
// apply mesh-specific bone (if any)
|
||||||
|
if( pMesh->nBoneIndex != -1 )
|
||||||
|
{
|
||||||
|
DISPLAY->PushMatrix();
|
||||||
|
|
||||||
|
const RageMatrix &mat = m_vpBones[pMesh->nBoneIndex].mFinal;
|
||||||
|
DISPLAY->PreMultMatrix( mat );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw it
|
||||||
|
const RageCompiledGeometry* TempGeometry = m_pTempGeometry ? m_pTempGeometry : m_pGeometry->m_pGeometry;
|
||||||
|
DISPLAY->DrawCompiledGeometry( TempGeometry, i, m_pGeometry->m_Meshes );
|
||||||
|
|
||||||
|
if( pMesh->nBoneIndex != -1 )
|
||||||
|
DISPLAY->PopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
void Model::SetDefaultAnimation( CString sAnimation, float fPlayRate )
|
void Model::SetDefaultAnimation( CString sAnimation, float fPlayRate )
|
||||||
{
|
{
|
||||||
m_sDefaultAnimation = sAnimation;
|
m_sDefaultAnimation = sAnimation;
|
||||||
|
|||||||
+13
-2
@@ -10,8 +10,18 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include "RageModelGeometry.h"
|
#include "RageModelGeometry.h"
|
||||||
|
|
||||||
struct msModel;
|
/* This is a static class that holds and renders model data; it can be shared among
|
||||||
|
* multiple Models. (Note that geometry data is stored and refcounted separately;
|
||||||
|
* that can */
|
||||||
|
/* XXX: dumb name */
|
||||||
|
/* class ModelHolder : public Actor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
|
RageModelGeometry *m_pGeometry;
|
||||||
|
|
||||||
|
} */
|
||||||
|
|
||||||
class Model : public Actor
|
class Model : public Actor
|
||||||
{
|
{
|
||||||
@@ -19,7 +29,6 @@ public:
|
|||||||
Model ();
|
Model ();
|
||||||
virtual ~Model ();
|
virtual ~Model ();
|
||||||
|
|
||||||
public:
|
|
||||||
void Clear ();
|
void Clear ();
|
||||||
void Load( CString sFile );
|
void Load( CString sFile );
|
||||||
|
|
||||||
@@ -63,6 +72,8 @@ private:
|
|||||||
vector<msMesh> m_vTempMeshes;
|
vector<msMesh> m_vTempMeshes;
|
||||||
RageCompiledGeometry* m_pTempGeometry;
|
RageCompiledGeometry* m_pTempGeometry;
|
||||||
|
|
||||||
|
void DrawMesh( int i ) const;
|
||||||
|
|
||||||
float m_fCurFrame;
|
float m_fCurFrame;
|
||||||
CString m_sDefaultAnimation;
|
CString m_sDefaultAnimation;
|
||||||
float m_fDefaultAnimationRate;
|
float m_fDefaultAnimationRate;
|
||||||
|
|||||||
Reference in New Issue
Block a user