From 7de8269a674aa5a1f8c162971fef9e3a074a362c Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 16 Apr 2004 05:09:02 +0000 Subject: [PATCH] pack all geometry for a Model into one set of vertex buffers --- stepmania/src/Model.cpp | 82 ++++----- stepmania/src/Model.h | 12 +- stepmania/src/ModelTypes.cpp | 2 - stepmania/src/ModelTypes.h | 21 +-- stepmania/src/RageDisplay.cpp | 6 +- stepmania/src/RageDisplay.h | 76 +++++--- stepmania/src/RageDisplay_D3D.cpp | 111 +++++------- stepmania/src/RageDisplay_D3D.h | 6 +- stepmania/src/RageDisplay_Null.cpp | 79 +------- stepmania/src/RageDisplay_Null.h | 6 +- stepmania/src/RageDisplay_OGL.cpp | 267 ++++++++++++++++------------ stepmania/src/RageDisplay_OGL.h | 6 +- stepmania/src/RageModelGeometry.cpp | 68 ++++--- stepmania/src/RageModelGeometry.h | 6 +- stepmania/src/RageTypes.h | 26 +-- 15 files changed, 356 insertions(+), 418 deletions(-) diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 835dd3c360..5484332ef0 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -35,8 +35,8 @@ Model::Model () m_bRevertToDefaultAnimation = false; m_fDefaultAnimationRate = 1; m_fCurAnimationRate = 1; - m_iRefCount = 1; - m_bUseTempVertices = false; +// m_iRefCount = 1; + m_pTempGeometry = NULL; } Model::~Model () @@ -56,12 +56,8 @@ void Model::Clear () m_mapNameToAnimation.clear(); m_pCurAnimation = NULL; - for (unsigned i = 0; i < m_vpTempVerticesByMesh.size(); i++) - { - RageModelVertexArray *&pTemp = m_vpTempVerticesByMesh[i]; - DISPLAY->DeleteRageModelVertexArray( pTemp ); - } - m_vpTempVerticesByMesh.clear(); + if( m_pTempGeometry ) + DISPLAY->DeleteCompiledGeometry( m_pTempGeometry ); } void Model::Load( CString sFile ) @@ -122,9 +118,9 @@ void Model::LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBo for (int i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++) { msMesh& mesh = m_pGeometry->m_Meshes[i]; - for (int j = 0; j < (int)mesh.Vertices->sizeVerts(); j++) + for (int j = 0; j < (int)mesh.Vertices.size(); j++) { - if( mesh.Vertices->Bone(j) != -1 ) + if( mesh.Vertices[j].bone != -1 ) { bHasAnyPerVertexBones = true; break; @@ -132,23 +128,11 @@ void Model::LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBo } } - m_bUseTempVertices = bHasAnyPerVertexBones; - if( m_bUseTempVertices ) + if( bHasAnyPerVertexBones ) { - m_vpTempVerticesByMesh.resize( m_pGeometry->m_Meshes.size() ); - for (unsigned i = 0; i < m_pGeometry->m_Meshes.size(); i++) - { - msMesh &mesh = m_pGeometry->m_Meshes[i]; - RageModelVertexArray *&pOrig = mesh.Vertices; - RageModelVertexArray *&pTemp = m_vpTempVerticesByMesh[i]; - pTemp = DISPLAY->CreateRageModelVertexArray(); - pTemp->resizeVerts( pOrig->sizeVerts() ); - pTemp->resizeTriangles( pOrig->sizeTriangles() ); - - // copy triangles - for (unsigned j = 0; j < pOrig->sizeTriangles(); j++) - pTemp->Triangle(j) = pOrig->Triangle(j); - } + m_vTempMeshes = m_pGeometry->m_Meshes; + m_pTempGeometry = DISPLAY->CreateCompiledGeometry(); + m_pTempGeometry->Set( m_vTempMeshes ); } } @@ -469,7 +453,7 @@ void Model::DrawPrimitives() for (int i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++) { msMesh *pMesh = &m_pGeometry->m_Meshes[i]; - const RageModelVertexArray* TempVertices = m_bUseTempVertices ? m_vpTempVerticesByMesh[i] : pMesh->Vertices; + const RageCompiledGeometry* TempGeometry = m_pTempGeometry ? m_pTempGeometry : m_pGeometry->m_pGeometry; if( pMesh->nMaterialIndex != -1 ) // has a material { @@ -532,7 +516,7 @@ void Model::DrawPrimitives() DISPLAY->PreMultMatrix( mat ); } - DISPLAY->DrawIndexedTriangles( TempVertices ); + DISPLAY->DrawCompiledGeometry( TempGeometry, i, m_pGeometry->m_Meshes ); DISPLAY->SetSphereEnironmentMapping( false ); if( pMesh->nBoneIndex != -1 ) @@ -552,7 +536,7 @@ void Model::DrawPrimitives() for (int i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++) { msMesh *pMesh = &m_pGeometry->m_Meshes[i]; - const RageModelVertexArray* pTempVertices = m_bUseTempVertices ? m_vpTempVerticesByMesh[i] : pMesh->Vertices; + const RageCompiledGeometry* TempGeometry = m_pTempGeometry ? m_pTempGeometry : m_pGeometry->m_pGeometry; // apply material if( pMesh->nMaterialIndex != -1 ) @@ -592,7 +576,7 @@ void Model::DrawPrimitives() DISPLAY->ClearAllTextures(); } - DISPLAY->DrawIndexedTriangles( pTempVertices ); + DISPLAY->DrawCompiledGeometry( TempGeometry, i, m_pGeometry->m_Meshes ); } } } @@ -656,12 +640,12 @@ void Model::PlayAnimation( CString sAniName, float fPlayRate ) for (i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++) { msMesh *pMesh = &m_pGeometry->m_Meshes[i]; - RageModelVertexArray* Vertices = pMesh->Vertices; - for (unsigned j = 0; j < Vertices->sizeVerts(); j++) + vector &Vertices = pMesh->Vertices; + for (unsigned j = 0; j < Vertices.size(); j++) { // int nBoneIndex = (pMesh->nBoneIndex!=-1) ? pMesh->nBoneIndex : bone; - RageVector3 &pos = Vertices->Position(j); - Sint8 bone = Vertices->Bone(j); + RageVector3 &pos = Vertices[j].p; + Sint8 bone = Vertices[j].bone; if (bone != -1) { pos[0] -= m_vpBones[bone].mAbsolute.m[3][0]; @@ -833,23 +817,23 @@ void Model::Update( float fDelta ) // // process per-vertex bones // - if( m_pGeometry && m_bUseTempVertices ) + if( m_pGeometry && m_pTempGeometry ) { for (int i = 0; i < (int)m_pGeometry->m_Meshes.size(); i++) { - msMesh *pMesh = &m_pGeometry->m_Meshes[i]; - RageModelVertexArray* pOrigVertices = pMesh->Vertices; - RageModelVertexArray* pTempVertices = m_vpTempVerticesByMesh[i]; - for (unsigned j = 0; j < pOrigVertices->sizeVerts(); j++) + msMesh &origMesh = m_pGeometry->m_Meshes[i]; + msMesh &tempMesh = m_vTempMeshes[i]; + vector &origVertices = origMesh.Vertices; + vector &tempVertices = tempMesh.Vertices; + for (unsigned j = 0; j < origVertices.size(); j++) { - - RageVector3& tempPos = pTempVertices->Position(j); - RageVector3& originalPos = pOrigVertices->Position(j); - RageVector3& tempNormal = pTempVertices->Normal(j); - RageVector3& originalNormal = pOrigVertices->Normal(j); - RageVector2& tempTex = pTempVertices->TexCoord(j); - RageVector2& originalTex = pOrigVertices->TexCoord(j); - Sint8 bone = pOrigVertices->Bone(j); + RageVector3& tempPos = tempVertices[j].p; + RageVector3& originalPos = origVertices[j].p; + RageVector3& tempNormal = tempVertices[j].n; + RageVector3& originalNormal = origVertices[j].n; + RageVector2& tempTex = tempVertices[j].t; + RageVector2& originalTex = origVertices[j].t; + Sint8 bone = origVertices[j].bone; tempTex = originalTex; @@ -865,8 +849,10 @@ void Model::Update( float fDelta ) } } - pTempVertices->OnChanged(); // send the new vertices to the graphics card } + + // send the new vertices to the graphics card + m_pTempGeometry->Change( m_vTempMeshes ); } } diff --git a/stepmania/src/Model.h b/stepmania/src/Model.h index f0e4ced559..173b4cb391 100644 --- a/stepmania/src/Model.h +++ b/stepmania/src/Model.h @@ -54,7 +54,7 @@ public: virtual void HandleCommand( const ParsedCommand &command ); - int m_iRefCount; +// int m_iRefCount; private: RageModelGeometry *m_pGeometry; @@ -65,12 +65,10 @@ private: vector m_vpBones; - // true if any vertex has a bone weight. - // If true, then render from m_vTempVerticesByBone. - // Otherwise, render directly from the mesh's vertices - bool m_bUseTempVertices; - - vector m_vpTempVerticesByMesh; + // If any vertex has a bone weight, then then render from m_pTempGeometry. + // Otherwise, render directly from m_pGeometry. + vector m_vTempMeshes; + RageCompiledGeometry* m_pTempGeometry; float m_fCurrFrame; CString m_sDefaultAnimation; diff --git a/stepmania/src/ModelTypes.cpp b/stepmania/src/ModelTypes.cpp index c75f0610c0..8244762856 100644 --- a/stepmania/src/ModelTypes.cpp +++ b/stepmania/src/ModelTypes.cpp @@ -128,12 +128,10 @@ void AnimatedTexture::Unload() msMesh::msMesh() { ZERO( szName ); - Vertices = NULL; } msMesh::~msMesh() { - Vertices = NULL; } diff --git a/stepmania/src/ModelTypes.h b/stepmania/src/ModelTypes.h index ae102fb99e..c1961e4de6 100644 --- a/stepmania/src/ModelTypes.h +++ b/stepmania/src/ModelTypes.h @@ -67,8 +67,6 @@ typedef struct } msTriangle; -class RageModelVertexArray; - /* msMesh */ typedef struct msMesh { @@ -78,9 +76,8 @@ typedef struct msMesh // byte nFlags; // we don't care about saving this flag char szName[MS_MAX_NAME]; char nMaterialIndex; - - RageModelVertexArray* Vertices; -// vector Vertices; + + vector Vertices; // vector Normals; // each vertex holds its own normal @@ -89,7 +86,7 @@ typedef struct msMesh // of transforming each vertex on the CPU; char nBoneIndex; // -1 = no bone -// vector Triangles; + vector Triangles; } msMesh; /* msMaterial */ @@ -188,12 +185,12 @@ typedef struct msBone } msBone; /* msModel */ -typedef struct msModel -{ - vector Meshes; - - vector Materials; -} msModel; +//typedef struct msModel +//{ +// vector Meshes; +// +// vector Materials; +//} msModel; struct msAnimation { diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 9811af1ae2..d9b7adbbc8 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -733,11 +733,11 @@ void RageDisplay::DrawTriangles( const RageSpriteVertex v[], int iNumVerts ) StatsAddVerts(iNumVerts); } -void RageDisplay::DrawIndexedTriangles( const RageModelVertexArray *p ) +void RageDisplay::DrawCompiledGeometry( const RageCompiledGeometry *p, int iMeshIndex, const vector &vMeshes ) { - this->DrawIndexedTrianglesInternal(p); + this->DrawCompiledGeometryInternal( p, iMeshIndex ); - StatsAddVerts(p->sizeTriangles()*3); + StatsAddVerts( vMeshes[iMeshIndex].Triangles.size() ); } void RageDisplay::DrawLineStrip( const RageSpriteVertex v[], int iNumVerts, float LineWidth ) diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 4e412a7b0b..86f7547b1e 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -19,31 +19,59 @@ const int REFRESH_DEFAULT = 0; struct SDL_Surface; const int MAX_TEXTURE_UNITS = 2; -// VertexArray holds vertex data in a format that is most efficient for -// the graphics API. -class RageModelVertexArray +// RageCompiledGeometry holds vertex data in a format that is most efficient +// for the graphics API. +class RageCompiledGeometry { public: - virtual ~RageModelVertexArray() { } + virtual ~RageCompiledGeometry() { } + + void Set( const vector &vMeshes ) + { + size_t totalVerts = 0; + size_t totalTriangles = 0; + + m_vMeshInfo.resize( vMeshes.size() ); + for( unsigned i=0; i &Vertices = mesh.Vertices; + const vector &Triangles = mesh.Triangles; + + MeshInfo& meshInfo = m_vMeshInfo[i]; + + meshInfo.iVertexStart = totalVerts; + meshInfo.iVertexCount = Vertices.size(); + meshInfo.iTriangleStart = totalTriangles; + meshInfo.iTriangleCount = Triangles.size(); + + totalVerts += Vertices.size(); + totalTriangles += Triangles.size(); + } + + this->Allocate( vMeshes ); + + Change( vMeshes ); + } + + virtual void Allocate( const vector &vMeshes ) = 0; // allocate space + virtual void Change( const vector &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() { return m_vMeshInfo.back().iVertexStart + m_vMeshInfo.back().iVertexCount; } + size_t GetTotalTriangles() { return m_vMeshInfo.back().iTriangleStart + m_vMeshInfo.back().iTriangleCount; } - virtual size_t sizeVerts() const = 0; - virtual void resizeVerts( size_t size ) = 0; - - virtual size_t sizeTriangles() const = 0; - virtual void resizeTriangles( size_t size ) = 0; - - virtual RageVector3& Position( int index ) = 0; - virtual RageVector3& Normal ( int index ) = 0; - virtual RageVector2& TexCoord( int index ) = 0; - virtual Sint8& Bone ( int index ) = 0; - - virtual msTriangle& Triangle( int index ) = 0; - - virtual void OnChanged() const = 0; // call this to re-send data to the video card - virtual void Draw() const = 0; // call this to make the video card draw the vertices + struct MeshInfo + { + int iVertexStart; + int iVertexCount; + int iTriangleStart; + int iTriangleCount; + }; + vector m_vMeshInfo; }; - class RageDisplay { friend class RageTexture; @@ -206,15 +234,15 @@ public: virtual void SetSphereEnironmentMapping( bool b ) = 0; - virtual RageModelVertexArray* CreateRageModelVertexArray() = 0; - virtual void DeleteRageModelVertexArray( RageModelVertexArray* p ) = 0; + virtual RageCompiledGeometry* CreateCompiledGeometry() = 0; + virtual void DeleteCompiledGeometry( RageCompiledGeometry* p ) = 0; void DrawQuads( const RageSpriteVertex v[], int iNumVerts ); void DrawQuadStrip( const RageSpriteVertex v[], int iNumVerts ); void DrawFan( const RageSpriteVertex v[], int iNumVerts ); void DrawStrip( const RageSpriteVertex v[], int iNumVerts ); void DrawTriangles( const RageSpriteVertex v[], int iNumVerts ); - void DrawIndexedTriangles( const RageModelVertexArray *p ); + void DrawCompiledGeometry( const RageCompiledGeometry *p, int iMeshIndex, const vector &vMeshes ); void DrawLineStrip( const RageSpriteVertex v[], int iNumVerts, float LineWidth ); void DrawCircle( const RageSpriteVertex &v, float radius ); @@ -236,7 +264,7 @@ protected: virtual void DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ) = 0; virtual void DrawStripInternal( const RageSpriteVertex v[], int iNumVerts ) = 0; virtual void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ) = 0; - virtual void DrawIndexedTrianglesInternal( const RageModelVertexArray *p ) = 0; + virtual void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ) = 0; virtual void DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth ); virtual void DrawCircleInternal( const RageSpriteVertex &v, float radius ); diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 2f96cc12da..3f6b52af38 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -734,94 +734,63 @@ RageDisplay::VideoModeParams RageDisplay_D3D::GetVideoModeParams() const { retur g_pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)&m ); -class RageModelVertexArraySWD3D : public RageModelVertexArray +class RageCompiledGeometrySWD3D : public RageCompiledGeometry { public: - RageModelVertexArraySWD3D() + void Allocate( const vector &vMeshes ) { - m_sizeVerts = 0; - m_sizeTriangles = 0; - m_pVertex = NULL; - m_pTriangles = NULL; + m_vVertex.resize( GetTotalVertices() ); + m_vTriangles.resize( GetTotalTriangles() ); } + void Change( const vector &vMeshes ) + { + for( unsigned i=0; i &Vertices = mesh.Vertices; + const vector &Triangles = mesh.Triangles; - ~RageModelVertexArraySWD3D() - { - m_sizeVerts = 0; - m_sizeTriangles = 0; - SAFE_DELETE( m_pVertex ); - SAFE_DELETE( m_pTriangles ); - } - - size_t sizeVerts() const - { - return m_sizeVerts; - } - void resizeVerts( size_t size ) - { - SAFE_DELETE( m_pVertex ); + { + for( unsigned j=0; jSetVertexShader( D3DFVF_RageModelVertex ); g_pd3dDevice->DrawIndexedPrimitiveUP( - D3DPT_TRIANGLELIST, // PrimitiveType - 0, // MinIndex - m_sizeVerts, // NumVertices - m_sizeTriangles, // PrimitiveCount, - m_pTriangles, // pIndexData, - D3DFMT_INDEX16, // IndexDataFormat, - m_pVertex, // pVertexStreamZeroData, - sizeof(Vertex) // VertexStreamZeroStride + D3DPT_TRIANGLELIST, // PrimitiveType + meshInfo.iVertexStart, // MinIndex + meshInfo.iVertexCount, // NumVertices + meshInfo.iTriangleCount, // PrimitiveCount, + &m_vTriangles[0]+meshInfo.iTriangleStart,// pIndexData, + D3DFMT_INDEX16, // IndexDataFormat, + &m_vVertex[0], // pVertexStreamZeroData, + sizeof(m_vVertex[0]) // VertexStreamZeroStride ); } + protected: - size_t m_sizeVerts; - size_t m_sizeTriangles; - - struct Vertex - { - RageVector3 p; // position - RageVector3 n; // normal - RageVector2 t; // texture coordinates - Sint8 bone; - } *m_pVertex; - - msTriangle *m_pTriangles; + vector m_vVertex; + vector m_vTriangles; }; -RageModelVertexArray* RageDisplay_D3D::CreateRageModelVertexArray() +RageCompiledGeometry* RageDisplay_D3D::CreateCompiledGeometry() { - return new RageModelVertexArraySWD3D; + return new RageCompiledGeometrySWD3D; } -void RageDisplay_D3D::DeleteRageModelVertexArray( RageModelVertexArray* p ) +void RageDisplay_D3D::DeleteCompiledGeometry( RageCompiledGeometry* p ) { delete p; } @@ -934,11 +903,11 @@ void RageDisplay_D3D::DrawTrianglesInternal( const RageSpriteVertex v[], int iNu ); } -void RageDisplay_D3D::DrawIndexedTrianglesInternal( const RageModelVertexArray *p ) +void RageDisplay_D3D::DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ) { SEND_CURRENT_MATRICES; - p->Draw(); + p->Draw( iMeshIndex ); } /* Use the default poly-based implementation. D3D lines apparently don't support diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index 7b503b7df4..afbbb1206b 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -75,8 +75,8 @@ public: void SetSphereEnironmentMapping( bool b ); - RageModelVertexArray* CreateRageModelVertexArray(); - void DeleteRageModelVertexArray( RageModelVertexArray* p ); + RageCompiledGeometry* CreateCompiledGeometry(); + void DeleteCompiledGeometry( RageCompiledGeometry* p ); protected: void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ); @@ -84,7 +84,7 @@ protected: void DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawStripInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ); - void DrawIndexedTrianglesInternal( const RageModelVertexArray *p ); + void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ); CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ); SDL_Surface* CreateScreenshot(); diff --git a/stepmania/src/RageDisplay_Null.cpp b/stepmania/src/RageDisplay_Null.cpp index 47a998aa77..203c21949f 100644 --- a/stepmania/src/RageDisplay_Null.cpp +++ b/stepmania/src/RageDisplay_Null.cpp @@ -126,85 +126,20 @@ void RageDisplay_Null::EndFrame() } -class RageModelVertexArrayNull : public RageModelVertexArray +class RageCompiledGeometryNull : public RageCompiledGeometry { public: - RageModelVertexArrayNull() - { - m_sizeVerts = 0; - m_sizeTriangles = 0; - m_pPosition = NULL; - m_pTexture = NULL; - m_pNormal = NULL; - m_pBone = NULL; - m_pTriangles = NULL; - } - - ~RageModelVertexArrayNull() - { - m_sizeVerts = 0; - m_sizeTriangles = 0; - SAFE_DELETE( m_pPosition ); - SAFE_DELETE( m_pTexture ); - SAFE_DELETE( m_pNormal ); - SAFE_DELETE( m_pBone ); - SAFE_DELETE( m_pTriangles ); - } - size_t sizeVerts() const - { - return m_sizeVerts; - } - void resizeVerts( size_t size ) - { - SAFE_DELETE( m_pPosition ); - SAFE_DELETE( m_pTexture ); - SAFE_DELETE( m_pNormal ); - SAFE_DELETE( m_pBone ); - - m_sizeVerts = size; - m_pPosition = new RageVector3[size]; - m_pTexture = new RageVector2[size]; - m_pNormal = new RageVector3[size]; - m_pBone = new Sint8[size]; - } - - size_t sizeTriangles() const - { - return m_sizeTriangles; - } - void resizeTriangles( size_t size ) - { - SAFE_DELETE( m_pTriangles ); - - m_sizeTriangles = size; - m_pTriangles = new msTriangle[size]; - } - - RageVector3& Position ( int index ) { return m_pPosition[index]; } - RageVector2& TexCoord ( int index ) { return m_pTexture[index]; } - RageVector3& Normal ( int index ) { return m_pNormal[index]; } - Sint8& Bone ( int index ) { return m_pBone[index]; } - msTriangle& Triangle ( int index ) { return m_pTriangles[index]; } - - void OnChanged() const { } - void Draw() const { } - -protected: - size_t m_sizeVerts; - size_t m_sizeTriangles; - RageVector3 *m_pPosition; - RageVector2 *m_pTexture; - RageVector3 *m_pNormal; - Sint8 *m_pBone; - msTriangle *m_pTriangles; + void Allocate( const vector &vMeshes ) {} + void Change( const vector &vMeshes ) {} + void Draw( int iMeshIndex ) const {} }; -RageModelVertexArray* RageDisplay_Null::CreateRageModelVertexArray() +RageCompiledGeometry* RageDisplay_Null::CreateCompiledGeometry() { - return new RageModelVertexArrayNull; + return new RageCompiledGeometryNull; } -void RageDisplay_Null::DeleteRageModelVertexArray( RageModelVertexArray* p ) +void RageDisplay_Null::DeleteCompiledGeometry( RageCompiledGeometry* p ) { } diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index 58d4a6b4f2..fc27c5a740 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -60,8 +60,8 @@ public: void SetSphereEnironmentMapping( bool b ) { } - RageModelVertexArray* CreateRageModelVertexArray(); - void DeleteRageModelVertexArray( RageModelVertexArray* p ); + RageCompiledGeometry* CreateCompiledGeometry(); + void DeleteCompiledGeometry( RageCompiledGeometry* p ); protected: void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ) { } @@ -69,7 +69,7 @@ protected: void DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ) { } void DrawStripInternal( const RageSpriteVertex v[], int iNumVerts ) { } void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ) { } - void DrawIndexedTrianglesInternal( const RageModelVertexArray *p ) { } + void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ) { } void DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth ) { } VideoModeParams m_Params; diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 41d152b53d..f15345d4c7 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -50,6 +50,7 @@ namespace GLExt { extern PFNGLGENBUFFERSARBPROC glGenBuffersARB; extern PFNGLBINDBUFFERARBPROC glBindBufferARB; extern PFNGLBUFFERDATAARBPROC glBufferDataARB; + extern PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB; extern PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB; extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements; }; @@ -92,6 +93,7 @@ PFNGLACTIVETEXTUREARBPROC GLExt::glActiveTextureARB = NULL; PFNGLGENBUFFERSARBPROC GLExt::glGenBuffersARB = NULL; PFNGLBINDBUFFERARBPROC GLExt::glBindBufferARB = NULL; PFNGLBUFFERDATAARBPROC GLExt::glBufferDataARB = NULL; +PFNGLBUFFERSUBDATAARBPROC GLExt::glBufferSubDataARB = NULL; PFNGLDELETEBUFFERSARBPROC GLExt::glDeleteBuffersARB = NULL; PFNGLDRAWRANGEELEMENTSPROC GLExt::glDrawRangeElements = NULL; static bool g_bEXT_texture_env_combine = true; @@ -660,6 +662,7 @@ void SetupExtensions() GLExt::glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wind->GetProcAddress("glGenBuffersARB"); GLExt::glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wind->GetProcAddress("glBindBufferARB"); GLExt::glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wind->GetProcAddress("glBufferDataARB"); + GLExt::glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC) wind->GetProcAddress("glBufferSubDataARB"); GLExt::glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) wind->GetProcAddress("glDeleteBuffersARB"); GLExt::glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) wind->GetProcAddress("glDrawRangeElements"); g_bEXT_texture_env_combine = HasExtension("GL_EXT_texture_env_combine"); @@ -920,97 +923,75 @@ void RageDisplay_OGL::SendCurrentMatrices() glLoadMatrixf( (const float*)&modelView ); } -class RageModelVertexArraySWOGL : public RageModelVertexArray +class RageCompiledGeometrySWOGL : public RageCompiledGeometry { public: - RageModelVertexArraySWOGL() - { - m_sizeVerts = 0; - m_sizeTriangles = 0; - m_pPosition = NULL; - m_pTexture = NULL; - m_pNormal = NULL; - m_pBone = NULL; - m_pTriangles = NULL; - } - - ~RageModelVertexArraySWOGL() - { - m_sizeVerts = 0; - m_sizeTriangles = 0; - SAFE_DELETE( m_pPosition ); - SAFE_DELETE( m_pTexture ); - SAFE_DELETE( m_pNormal ); - SAFE_DELETE( m_pBone ); - SAFE_DELETE( m_pTriangles ); - } - size_t sizeVerts() const + void Allocate( const vector &vMeshes ) { - return m_sizeVerts; + m_vPosition.resize( GetTotalVertices() ); + m_vTexture.resize( GetTotalVertices() ); + m_vNormal.resize( GetTotalVertices() ); + m_vTriangles.resize( GetTotalTriangles() ); } - void resizeVerts( size_t size ) + void Change( const vector &vMeshes ) { - SAFE_DELETE( m_pPosition ); - SAFE_DELETE( m_pTexture ); - SAFE_DELETE( m_pNormal ); - SAFE_DELETE( m_pBone ); + for( unsigned i=0; i &Vertices = mesh.Vertices; + const vector &Triangles = mesh.Triangles; - m_sizeVerts = size; - m_pPosition = new RageVector3[size]; - m_pTexture = new RageVector2[size]; - m_pNormal = new RageVector3[size]; - m_pBone = new Sint8[size]; + { + for( unsigned j=0; j m_vPosition; + vector m_vTexture; + vector m_vNormal; + vector m_vTriangles; }; -class RageModelVertexArrayHWOGL : public RageModelVertexArraySWOGL +class RageCompiledGeometryHWOGL : public RageCompiledGeometrySWOGL { protected: // vertex buffer object names @@ -1019,7 +1000,7 @@ protected: GLuint m_nNormals; GLuint m_nTriangles; public: - RageModelVertexArrayHWOGL() + RageCompiledGeometryHWOGL() { m_nPositions = 0; m_nTextureCoords = 0; @@ -1029,26 +1010,19 @@ public: FlushGLErrors(); GLExt::glGenBuffersARB( 1, &m_nPositions ); - GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); AssertNoGLError(); GLExt::glGenBuffersARB( 1, &m_nTextureCoords ); - GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); AssertNoGLError(); GLExt::glGenBuffersARB( 1, &m_nNormals ); - GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); AssertNoGLError(); GLExt::glGenBuffersARB( 1, &m_nTriangles ); - GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTriangles ); AssertNoGLError(); - - GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); - GLExt::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); } - ~RageModelVertexArrayHWOGL() + ~RageCompiledGeometryHWOGL() { FlushGLErrors(); @@ -1062,86 +1036,147 @@ public: AssertNoGLError(); } - void OnChanged() const + void Allocate( const vector &vMeshes ) { - // some implementations don't handle buffers of size 0. - if( m_sizeVerts == 0 || m_nTriangles == 0 ) - return; - + RageCompiledGeometrySWOGL::Allocate( vMeshes ); + GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); - GLExt::glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_sizeVerts*sizeof(RageVector3), m_pPosition, GL_STATIC_DRAW_ARB ); -// AssertNoGLError(); + GLExt::glBufferDataARB( + GL_ARRAY_BUFFER_ARB, + GetTotalVertices()*sizeof(RageVector3), + NULL, + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); - GLExt::glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_sizeVerts*sizeof(RageVector2), m_pTexture, GL_STATIC_DRAW_ARB ); -// AssertNoGLError(); + GLExt::glBufferDataARB( + GL_ARRAY_BUFFER_ARB, + GetTotalVertices()*sizeof(RageVector2), + NULL, + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); - GLExt::glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_sizeVerts*sizeof(RageVector3), m_pNormal, GL_STATIC_DRAW_ARB ); -// AssertNoGLError(); + GLExt::glBufferDataARB( + GL_ARRAY_BUFFER_ARB, + GetTotalVertices()*sizeof(RageVector3), + NULL, + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); GLExt::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); - GLExt::glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_sizeTriangles*sizeof(msTriangle), m_pTriangles, GL_STATIC_DRAW_ARB ); -// AssertNoGLError(); + GLExt::glBufferDataARB( + GL_ELEMENT_ARRAY_BUFFER_ARB, + GetTotalTriangles()*sizeof(msTriangle), + NULL, + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); GLExt::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); } - void Draw() const - { - if( m_sizeVerts == 0 || m_nTriangles == 0 ) - return; + void Change( const vector &vMeshes ) + { + RageCompiledGeometrySWOGL::Change( vMeshes ); + + GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); + GLExt::glBufferDataARB( + GL_ARRAY_BUFFER_ARB, + GetTotalVertices()*sizeof(RageVector3), + &m_vPosition[0], + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); + + GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); + GLExt::glBufferDataARB( + GL_ARRAY_BUFFER_ARB, + GetTotalVertices()*sizeof(RageVector2), + &m_vTexture[0], + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); + + GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); + GLExt::glBufferDataARB( + GL_ARRAY_BUFFER_ARB, + GetTotalVertices()*sizeof(RageVector3), + &m_vNormal[0], + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); + + GLExt::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); + GLExt::glBufferDataARB( + GL_ELEMENT_ARRAY_BUFFER_ARB, + GetTotalTriangles()*sizeof(msTriangle), + &m_vTriangles[0], + GL_STATIC_DRAW_ARB ); + AssertNoGLError(); + + GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); + GLExt::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); + } + + void Draw( int iMeshIndex ) const + { FlushGLErrors(); + const MeshInfo& meshInfo = m_vMeshInfo[iMeshIndex]; + glEnableClientState(GL_VERTEX_ARRAY); GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); -// AssertNoGLError(); + AssertNoGLError(); glVertexPointer(3, GL_FLOAT, 0, NULL ); -// AssertNoGLError(); + AssertNoGLError(); glDisableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); -// AssertNoGLError(); + AssertNoGLError(); glTexCoordPointer(2, GL_FLOAT, 0, NULL); -// AssertNoGLError(); + AssertNoGLError(); glEnableClientState(GL_NORMAL_ARRAY); GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); -// AssertNoGLError(); + AssertNoGLError(); glNormalPointer(GL_FLOAT, 0, NULL); -// AssertNoGLError(); + AssertNoGLError(); GLExt::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); -// AssertNoGLError(); + AssertNoGLError(); -#define BUFFER_OFFSET(o) o +#define BUFFER_OFFSET(o) ((char*)(o)) - GLExt::glDrawRangeElements( + glDrawElements( GL_TRIANGLES, - 0, // minimum array index contained in indices - m_sizeVerts-1, // maximum array index contained in indices - m_sizeTriangles*3, // number of elements to be rendered - GL_UNSIGNED_SHORT, // - 0 ); -// AssertNoGLError(); + meshInfo.iTriangleCount*3, + GL_UNSIGNED_SHORT, + BUFFER_OFFSET(meshInfo.iTriangleStart*sizeof(msTriangle)) ); + +// GLExt::glDrawRangeElements( +// GL_TRIANGLES, +// meshInfo.iVertexStart, // minimum array index contained in indices +// meshInfo.iVertexStart+meshInfo.iVertexCount-1, +// // maximum array index contained in indices +// meshInfo.iTriangleCount*3, // number of elements to be rendered +// GL_UNSIGNED_SHORT, +// BUFFER_OFFSET(0) ); + AssertNoGLError(); GLExt::glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); GLExt::glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); } }; -RageModelVertexArray* RageDisplay_OGL::CreateRageModelVertexArray() +RageCompiledGeometry* RageDisplay_OGL::CreateCompiledGeometry() { if( GLExt::glGenBuffersARB ) - return new RageModelVertexArrayHWOGL; + return new RageCompiledGeometryHWOGL; else - return new RageModelVertexArraySWOGL; + return new RageCompiledGeometrySWOGL; } -void RageDisplay_OGL::DeleteRageModelVertexArray( RageModelVertexArray* p ) +void RageDisplay_OGL::DeleteCompiledGeometry( RageCompiledGeometry* p ) { delete p; } @@ -1188,11 +1223,11 @@ void RageDisplay_OGL::DrawTrianglesInternal( const RageSpriteVertex v[], int iNu glDrawArrays( GL_TRIANGLES, 0, iNumVerts ); } -void RageDisplay_OGL::DrawIndexedTrianglesInternal( const RageModelVertexArray *p ) +void RageDisplay_OGL::DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ) { SendCurrentMatrices(); - p->Draw(); + p->Draw( iMeshIndex ); } void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth ) diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index 16e32ab80e..da9bccc6b8 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -61,8 +61,8 @@ public: void SetSphereEnironmentMapping( bool b ); - RageModelVertexArray* CreateRageModelVertexArray(); - void DeleteRageModelVertexArray( RageModelVertexArray* p ); + RageCompiledGeometry* CreateCompiledGeometry(); + void DeleteCompiledGeometry( RageCompiledGeometry* p ); CString GetTextureDiagnostics( unsigned id ) const; @@ -72,7 +72,7 @@ protected: void DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawStripInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ); - void DrawIndexedTrianglesInternal( const RageModelVertexArray *p ); + void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ); void DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth ); CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ); diff --git a/stepmania/src/RageModelGeometry.cpp b/stepmania/src/RageModelGeometry.cpp index fdb1296585..990f81914c 100644 --- a/stepmania/src/RageModelGeometry.cpp +++ b/stepmania/src/RageModelGeometry.cpp @@ -19,17 +19,12 @@ RageModelGeometry::RageModelGeometry () { m_iRefCount = 1; + m_pGeometry = DISPLAY->CreateCompiledGeometry(); } RageModelGeometry::~RageModelGeometry () { - for (unsigned i = 0; i < m_Meshes.size(); i++) - { - msMesh& mesh = m_Meshes[i]; - RageModelVertexArray *&pVertices = mesh.Vertices; - DISPLAY->DeleteRageModelVertexArray( pVertices ); - pVertices = NULL; - } + DISPLAY->DeleteCompiledGeometry( m_pGeometry ); } void RageModelGeometry::OptimizeBones() @@ -40,12 +35,18 @@ void RageModelGeometry::OptimizeBones() // check to see if all vertices have the same bone index bool bAllVertsUseSameBone = true; - char nBoneIndex = !mesh.Vertices->sizeVerts()==0 ? mesh.Vertices->Bone(0) : (char) -1; + + char nBoneIndex; + if( !mesh.Vertices.empty() ) + nBoneIndex = mesh.Vertices[0].bone; + else + nBoneIndex = (char)-1; + if( nBoneIndex != -1 ) { - for (unsigned j = 1; j < mesh.Vertices->sizeVerts(); j++) + for (unsigned j = 1; j < mesh.Vertices.size(); j++) { - if( mesh.Vertices->Bone(j) != nBoneIndex ) + if( mesh.Vertices[j].bone != nBoneIndex ) { bAllVertsUseSameBone = false; break; @@ -57,9 +58,9 @@ void RageModelGeometry::OptimizeBones() mesh.nBoneIndex = nBoneIndex; // clear all vertex/bone associations; - for (unsigned j = 0; j < mesh.Vertices->sizeVerts(); j++) + for (unsigned j = 0; j < mesh.Vertices.size(); j++) { - mesh.Vertices->Bone(j) = -1; + mesh.Vertices[j].bone = -1; } } } @@ -110,9 +111,9 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) for (i = 0; i < nNumMeshes; i++) { - msMesh& mesh = m_Meshes[i]; - RageModelVertexArray *&pVertices = mesh.Vertices; - pVertices = DISPLAY->CreateRageModelVertexArray(); + msMesh &mesh = m_Meshes[i]; + vector &Vertices = mesh.Vertices; + vector &Triangles = mesh.Triangles; if( f.GetLine( sLine ) <= 0 ) THROW @@ -137,19 +138,19 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) if (sscanf (sLine, "%d", &nNumVertices) != 1) THROW - pVertices->resizeVerts( nNumVertices ); + Vertices.resize( nNumVertices ); for (j = 0; j < nNumVertices; j++) { + RageModelVertex &v = Vertices[j]; + if( f.GetLine( sLine ) <= 0 ) THROW - RageVector3 pos; - RageVector2 uv; if (sscanf (sLine, "%d %f %f %f %f %f %d", &nFlags, - &pos[0], &pos[1], &pos[2], - &uv[0], &uv[1], + &v.p[0], &v.p[1], &v.p[2], + &v.t[0], &v.t[1], &nIndex ) != 7) { @@ -157,10 +158,8 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) } // vertex.nFlags = nFlags; - pVertices->Position(j) = pos; - pVertices->TexCoord(j) = uv; - pVertices->Bone(j) = (byte)nIndex; - RageVec3AddToBounds( RageVector3(pos), m_vMins, m_vMaxs ); + v.bone = (byte)nIndex; + RageVec3AddToBounds( v.p, m_vMins, m_vMaxs ); } @@ -201,7 +200,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) if (sscanf (sLine, "%d", &nNumTriangles) != 1) THROW - pVertices->resizeTriangles( nNumTriangles ); + Triangles.resize( nNumTriangles ); for (j = 0; j < nNumTriangles; j++) { @@ -223,13 +222,13 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) // deflate the normals into vertices for( int k=0; k<3; k++ ) { - //RageModelVertex& vertex = mesh.Vertices[ nIndices[k] ]; - //RageVector3& normal = Normals[ nNormalIndices[k] ]; - //vertex.n = normal; - mesh.Vertices->Normal( nIndices[k] ) = Normals[ nNormalIndices[k] ]; + RageModelVertex& vertex = Vertices[ nIndices[k] ]; + RageVector3& normal = Normals[ nNormalIndices[k] ]; + vertex.n = normal; + //mesh.Vertices[nIndices[k]].n = Normals[ nNormalIndices[k] ]; } - msTriangle& Triangle = pVertices->Triangle(j); + msTriangle& Triangle = Triangles[j]; // Triangle.nFlags = nFlags; memcpy( &Triangle.nVertexIndices, nIndices, sizeof(Triangle.nVertexIndices) ); // Triangle.nSmoothingGroup = nIndex; @@ -241,14 +240,7 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) OptimizeBones(); // send the finalized vertices to the graphics card - { - for( unsigned i = 0; i < m_Meshes.size(); i++ ) - { - msMesh& mesh = m_Meshes[i]; - RageModelVertexArray *&pVertices = mesh.Vertices; - pVertices->OnChanged(); - } - } + m_pGeometry->Set( m_Meshes ); f.Close(); } diff --git a/stepmania/src/RageModelGeometry.h b/stepmania/src/RageModelGeometry.h index e12a98ad01..90e8408740 100644 --- a/stepmania/src/RageModelGeometry.h +++ b/stepmania/src/RageModelGeometry.h @@ -17,8 +17,7 @@ #include #include -struct msRageModelGeometry; - +class RageCompiledGeometry; class RageModelGeometry { @@ -32,7 +31,8 @@ public: int m_iRefCount; - vector m_Meshes; + vector m_Meshes; + RageCompiledGeometry* m_pGeometry; // video memory copy of geometry shared by all meshes RageVector3 m_vMins, m_vMaxs; }; diff --git a/stepmania/src/RageTypes.h b/stepmania/src/RageTypes.h index 13802cbfa9..a98900f4b2 100644 --- a/stepmania/src/RageTypes.h +++ b/stepmania/src/RageTypes.h @@ -219,19 +219,19 @@ struct RageSpriteVertex // has color }; -//struct RageModelVertex // doesn't have color. Relies on material color -//{ -// /* Zero out by default. */ -// RageModelVertex(): -// p(0,0,0), -// n(0,0,0), -// t(0,0) -// { } -// RageVector3 p; // position -// RageVector3 n; // normal -// RageVector2 t; // texture coordinates -// Sint8 bone; -//}; +struct RageModelVertex // doesn't have color. Relies on material color +{ + /* Zero out by default. */ + RageModelVertex(): + p(0,0,0), + n(0,0,0), + t(0,0) + { } + RageVector3 p; // position + RageVector3 n; // normal + RageVector2 t; // texture coordinates + Sint8 bone; +}; // RageMatrix elements are specified in row-major order. This