Changeset 561

Show
Ignore:
Timestamp:
04/17/08 12:00:20 (9 months ago)
Author:
phill
Message:

o Light grid import (I hope this is good enough).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/common/math-vector.h

    r535 r561  
    140140inline vec3 abs( const vec3 &v ) { return vec3c( abs( v.x ), abs( v.y ), abs( v.z ) ); } 
    141141 
     142inline vec3 ceil( const vec3 &v ) { return vec3c( ceil( v.x ), ceil( v.y ), ceil( v.z ) ); } 
     143inline vec3 floor( const vec3 &v ) { return vec3c( floor( v.x ), floor( v.y ), floor( v.z ) ); } 
     144 
    142145inline 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; } 
    143146 
  • trunk/maya2q3/bsp-local.h

    r549 r561  
    3131Literal EkMessage = "message"; 
    3232Literal EkDeluxeMapping = "deluxemapping"; 
     33Literal EkLightGridSize = "gridsize"; 
    3334Literal EkOrigin = "origin"; 
    3435Literal EkAngle = "angle"; 
  • trunk/maya2q3/bsp.cpp

    r550 r561  
    6161        MDagPathArray m_lightPaths; 
    6262 
     63        MDagPath m_lightGridPoints; 
     64 
    6365        std::vector< std::pair< int, int > > m_shaderMap; 
    6466        std::vector< std::vector< int > > m_shaderFaceNums; 
     
    105107        void CreateShaderQuickSelects(); 
    106108        void CreateQuickSelect( const MSelectionList &sel, const MString &name ); 
     109 
     110        void ImportLightGridPoints(); 
    107111 
    108112        void ParseEntities(); 
     
    742746                check_status( stat ); 
    743747        } 
     748 
     749        { 
     750                MDagPath path = m_lightGridPoints; 
     751 
     752                stat = path.pop(); 
     753                check_status( stat ); 
     754 
     755                MObject obj = path.node( &stat ); 
     756                check_status( stat ); 
     757 
     758                stat = fnParent.addChild( obj ); 
     759                check_status( stat ); 
     760        } 
    744761} 
    745762 
     
    824841} 
    825842 
     843void BspImporter::ImportLightGridPoints() 
     844{ 
     845        MStatus stat; 
     846 
     847        std::vector< q3::dmodel_t > models = ReadLump< q3::dmodel_t >( q3::LUMP_MODELS ); 
     848        if( models.size() < 1 ) 
     849                throw std::exception( "Missing world model record." ); 
     850        const q3::dmodel_t &wm = models[0]; 
     851         
     852        vec3 size = m_entities[0].AsVec3( EkLightGridSize, vec3c( 64, 64, 128 ) ); 
     853         
     854        vec3 mins = size * ceil( wm.mins / size ); 
     855        vec3 maxs = size * floor( wm.maxs / size ); 
     856         
     857        vec3 bounds = floor( (maxs - mins) / size ) + vec3c( 1 ); 
     858 
     859        MFloatPointArray points; 
     860        MIntArray counts, indices; 
     861 
     862        for( float z = 0; z < bounds.z; z++ ) 
     863        { 
     864                for( float y = 0; y < bounds.y; y++ ) 
     865                { 
     866                        for( float x = 0; x < bounds.x; x++ ) 
     867                        { 
     868                                points.append( MFloatPoint( q3::Q3VecToMaya( mins + vec3c( x, y, z ) ) ) ); 
     869                        } 
     870                } 
     871        } 
     872 
     873        MFnMesh mesh; 
     874        MObject meshObj = mesh.create( points.length(), counts.length(), points, counts, indices, MObject::kNullObj, &stat ); 
     875        check_status( stat ); 
     876 
     877        stat = mesh.updateSurface(); 
     878        check_status( stat ); 
     879 
     880        MDagPath path; 
     881        stat = mesh.getPath( path ); 
     882        check_status( stat ); 
     883 
     884        m_lightGridPoints = path; 
     885 
     886        stat = path.pop(); 
     887        check_status( stat ); 
     888 
     889        MFnDagNode fnParent( path, &stat ); 
     890        check_status( stat ); 
     891 
     892        fnParent.setName( MString( "lightgrid" ), &stat ); 
     893        check_status( stat ); 
     894} 
     895 
    826896void BspImporter::Import( std::istream &stm, const MObject &parentXform, const char *basePath ) 
    827897{ 
     
    844914 
    845915        ImportEntityLights(); 
     916        ImportLightGridPoints(); 
    846917 
    847918        GroupNodes( parentXform ); 
  • trunk/maya2q3/maya_entry.cpp

    r551 r561  
    2626 
    2727static const char *g_vendor = "HermitWorks"; 
    28 static const char *g_version = "3.3.6"; 
     28static const char *g_version = "3.3.7"; 
    2929static const char *g_reqVer = "Any"; 
    3030