Changeset 535

Show
Ignore:
Timestamp:
03/05/08 15:32:26 (10 months ago)
Author:
phill
Message:

o Can now import patches.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bin/win32/release (8.5)/bin

    • Property svn:ignore changed from
      x42maya.exp
      x42maya.lib
      to
      x42maya.exp
      x42maya.lib
      maya2q3.exp
      maya2q3.lib
  • trunk/common/math-vector.h

    r211 r535  
    8484inline vec2 abs( const vec2 &v ) { return vec2c( abs( v.x ), abs( v.y ) ); } 
    8585 
     86inline bool equal( const vec2 &v0, const vec2 &v1, float tol ) { return fabsf( v0.x - v1.x ) <= tol && fabsf( v0.y - v1.y ) <= tol; } 
     87 
    8688struct vec3 
    8789{ 
     
    138140inline vec3 abs( const vec3 &v ) { return vec3c( abs( v.x ), abs( v.y ), abs( v.z ) ); } 
    139141 
     142inline bool equal( const vec3 &v0, const vec3 &v1, float tol ) { return fabsf( v0.x - v1.x ) <= tol && fabsf( v0.y - v1.y ) <= tol && fabsf( v0.z - v1.z ) <= tol; } 
     143 
    140144__declspec( align( 16 ) ) struct vec4 
    141145{ 
  • trunk/maya2q3/bsp.cpp

    r495 r535  
    3434        MIntArray m_faceVertIndices; 
    3535 
     36        std::vector< q3::Patch > m_patchStaging; 
     37 
    3638        BspMeshData( void ); 
    3739 
     
    4143 
    4244private: 
     45        void AppendTriangles( const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices, 
     46                int firstVert = 0, int vertexCount = -1, int firstIndex = 0, int indexCount = -1 ); 
    4347        void AppendFace( const q3::dsurface_t &surf, const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices ); 
    4448        void AppendMesh( const q3::dsurface_t &surf, const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices ); 
     49        void AppendPatch( const q3::dsurface_t &surf, const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices ); 
     50 
     51        void BakePatches(); 
    4552}; 
    4653 
     
    5259} 
    5360 
     61void BspMeshData::AppendTriangles( const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices, 
     62                int firstVert, int vertexCount, int firstIndex, int indexCount ) 
     63{ 
     64        if( vertexCount == -1 ) 
     65                vertexCount = (int)verts.size(); 
     66        if( indexCount == -1 ) 
     67                indexCount = (int)indices.size(); 
     68 
     69        int baseVert = (int)m_verts.length(); 
     70        for( int i = 0; i < vertexCount; i++ ) 
     71                m_verts.append( MPoint( verts[firstVert + i].xyz ) ); 
     72 
     73        //ToDo: collapse out coplanar edges     (?) 
     74 
     75        int numTris = indexCount / 3; 
     76        for( int i = 0; i < numTris; i++ ) 
     77        { 
     78                m_faceVertIndices.append( baseVert + indices[firstIndex + i * 3 + 0] ); 
     79                m_faceVertIndices.append( baseVert + indices[firstIndex + i * 3 + 2] ); 
     80                m_faceVertIndices.append( baseVert + indices[firstIndex + i * 3 + 1] ); 
     81 
     82                m_faceCounts.append( 3 ); 
     83        } 
     84} 
     85 
    5486void BspMeshData::AppendFace( const q3::dsurface_t &surf, const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices ) 
    5587{ 
    56         int baseVert = (int)m_verts.length(); 
    57         for( int i = 0; i < surf.numVerts; i++ ) 
    58                 m_verts.append( MPoint( verts[surf.firstVert + i].xyz ) ); 
    59  
    60         //ToDo: collapse out coplanar edges     (?) 
    61  
    62         for( int i = 0; i < surf.numIndexes / 3; i++ ) 
    63         { 
    64                 m_faceVertIndices.append( baseVert + indices[surf.firstIndex + i * 3 + 0] ); 
    65                 m_faceVertIndices.append( baseVert + indices[surf.firstIndex + i * 3 + 2] ); 
    66                 m_faceVertIndices.append( baseVert + indices[surf.firstIndex + i * 3 + 1] ); 
    67  
    68                 m_faceCounts.append( 3 ); 
    69         } 
     88        AppendTriangles( verts, indices, surf.firstVert, surf.numVerts, surf.firstIndex, surf.numIndexes ); 
    7089} 
    7190 
    7291void BspMeshData::AppendMesh( const q3::dsurface_t &surf, const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices ) 
    7392{ 
    74         int baseVert = (int)m_verts.length(); 
    75         for( int i = 0; i < surf.numVerts; i++ ) 
    76                 m_verts.append( MPoint( verts[surf.firstVert + i].xyz ) ); 
    77  
    78         //ToDo: collapse out coplanar edges     (?) 
    79  
    80         for( int i = 0; i < surf.numIndexes / 3; i++ ) 
    81         { 
    82                 m_faceVertIndices.append( baseVert + indices[surf.firstIndex + i * 3 + 0] ); 
    83                 m_faceVertIndices.append( baseVert + indices[surf.firstIndex + i * 3 + 2] ); 
    84                 m_faceVertIndices.append( baseVert + indices[surf.firstIndex + i * 3 + 1] ); 
    85  
    86                 m_faceCounts.append( 3 ); 
    87         } 
     93        AppendTriangles( verts, indices, surf.firstVert, surf.numVerts, surf.firstIndex, surf.numIndexes ); 
     94
     95 
     96void BspMeshData::AppendPatch( const q3::dsurface_t &surf, const std::vector< q3::drawVert_t > &verts, const std::vector< int > &indices ) 
     97
     98        q3::Patch p = q3::SubdividePatchToGrid( surf.patchWidth, surf.patchHeight, &verts[surf.firstVert] ); 
     99        m_patchStaging.push_back( p ); 
     100
     101 
     102void BspMeshData::BakePatches() 
     103
     104        q3::StitchAllPatches( m_patchStaging ); 
     105        q3::FixSharedVertexLodError( m_patchStaging ); 
     106 
     107        std::vector< int > indices; 
     108        std::vector< q3::drawVert_t > verts; 
     109 
     110        for( uint i = 0; i < m_patchStaging.size(); i++ ) 
     111        { 
     112                q3::PatchToMesh( m_patchStaging[i], verts, indices ); 
     113                AppendTriangles( verts, indices ); 
     114        } 
     115 
     116        m_patchStaging.clear(); 
    88117} 
    89118 
     
    135164                        break; 
    136165 
     166                case q3::MST_PATCH: 
     167                        AppendPatch( surfs[i], verts, indices ); 
     168                        break; 
     169 
    137170                default: 
    138171                        warn( "Ignoring surface." ); 
     
    143176MObject BspMeshData::CreateMesh( void ) 
    144177{ 
     178        BakePatches(); 
     179 
    145180        MStatus stat; 
    146181 
  • trunk/maya2q3/maya2q3.vcproj

    r534 r535  
    1818                <Configuration 
    1919                        Name="Debug (6.0)|Win32" 
    20                         OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)
     20                        OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)\bin
    2121                        IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)" 
    2222                        ConfigurationType="2" 
     
    109109                <Configuration 
    110110                        Name="Release (6.0)|Win32" 
    111                         OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)
     111                        OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)\bin
    112112                        IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)" 
    113113                        ConfigurationType="2" 
     
    198198                <Configuration 
    199199                        Name="Debug (7.0)|Win32" 
    200                         OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)
     200                        OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)\bin
    201201                        IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)" 
    202202                        ConfigurationType="2" 
     
    289289                <Configuration 
    290290                        Name="Release (7.0)|Win32" 
    291                         OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)
     291                        OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)\bin
    292292                        IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)" 
    293293                        ConfigurationType="2" 
     
    378378                <Configuration 
    379379                        Name="Debug (8.5)|Win32" 
    380                         OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)
     380                        OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)\bin
    381381                        IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)" 
    382382                        ConfigurationType="2" 
     
    470470                <Configuration 
    471471                        Name="Release (8.5)|Win32" 
    472                         OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)
     472                        OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)\bin
    473473                        IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)" 
    474474                        ConfigurationType="2" 
     
    554554                                Name="VCPostBuildEventTool" 
    555555                                Description="Copying to Maya plugins directory." 
    556                                 CommandLine="copy &quot;$(OutDir)\$(ProjectName).mll&quot; &quot;$(ProgramFiles)\Alias\Maya7.0\bin\plug-ins&quot;&#x0D;&#x0A;copy &quot;$(ProjectDir)\AEQ3ShaderTemplate.mel&quot; &quot;$(ProgramFiles)\Alias\Maya7.0\scripts\AETemplates&quot;&#x0D;&#x0A;copy &quot;$(ProjectDir)\maya2q3.mel&quot; &quot;$(ProgramFiles)\Alias\Maya7.0\scripts\others&quot;&#x0D;&#x0A;" 
    557                                 ExcludedFromBuild="true" 
     556                                CommandLine="copy &quot;$(OutDir)\$(ProjectName).mll&quot; &quot;C:\Program Files (x86)\Autodesk\Maya8.5\bin\plug-ins&quot;&#x0D;&#x0A;copy &quot;$(ProjectDir)\AEQ3ShaderTemplate.mel&quot; &quot;C:\Program Files (x86)\Autodesk\Maya8.5\scripts\AETemplates&quot;&#x0D;&#x0A;copy &quot;$(ProjectDir)\maya2q3.mel&quot; &quot;C:\Program Files (x86)\Autodesk\Maya8.5\scripts\others&quot;&#x0D;&#x0A;" 
    558557                        /> 
    559558                </Configuration> 
     
    568567                        > 
    569568                        <File 
     569                                RelativePath=".\bsp-patches.cpp" 
     570                                > 
     571                        </File> 
     572                        <File 
    570573                                RelativePath=".\bsp.cpp" 
    571574                                > 
  • trunk/maya2q3/q3util.h

    r182 r535  
    9191MString GetTagName( const MDagPath &path ); 
    9292 
     93struct Patch 
     94{ 
     95        vec3                                    lodOrigin; 
     96        float                                   lodRadius; 
     97        int                                             lodFixed; 
     98        bool                                    lodStitched; 
     99 
     100        int                                             width; 
     101        int                                             height; 
     102        std::vector< float >    widthLodError; 
     103        std::vector< float >    heightLodError; 
     104        std::vector< q3::drawVert_t >   verts; 
     105 
     106        uint                                    meshIdx; 
     107}; 
     108 
     109void StitchAllPatches( std::vector< Patch > &patches ); 
     110void FixSharedVertexLodError( std::vector< Patch > &patches ); 
     111Patch SubdividePatchToGrid( int width, int height, const drawVert_t points[] ); 
     112 
     113void PatchToMesh( const Patch &patch, std::vector< q3::drawVert_t > &out_verts, std::vector< int > &out_indices ); 
     114 
    93115}; 
    94116