Changeset 547
- Timestamp:
- 03/25/08 04:24:06 (10 months ago)
- Files:
-
- trunk/maya2q3/bsp.cpp (modified) (11 diffs)
- trunk/maya2q3/maya_entry.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/maya2q3/bsp.cpp
r546 r547 43 43 public: 44 44 BspImporter( void ); 45 void Import( std::istream &stm, const MObject &parentTransform );45 void Import( std::istream &stm, const MObject &parentTransform, const char *basePath ); 46 46 47 47 private: … … 79 79 std::vector< MSelectionList > m_shaderSels; 80 80 81 const char *m_basePath; 81 82 q3::dheader_t m_fileHeader; 82 83 BinaryReader *m_fileData; … … 103 104 void ClearStagingArea(); 104 105 106 MObject ImportTexture( const char *shaderName ); 105 107 int GetShaderIndex( const std::vector< q3::dshader_t > &shaders, int shaderNum, int lightmapNum ); 106 108 … … 147 149 } 148 150 151 MObject BspImporter::ImportTexture( const char *shaderName ) 152 { 153 ospath basePath( m_basePath ); 154 basePath.Append( shaderName ); 155 156 const char *path = 0; 157 158 static const char *const exts[] = { ".tga", ".jpg" }; 159 for( size_t i = 0; i < lengthof( exts ); i++ ) 160 { 161 ospath p2( basePath ); 162 p2.Append( exts[i] ); 163 164 if( GetFileAttributesA( p2 ) != INVALID_FILE_ATTRIBUTES ) 165 { 166 basePath = p2; 167 path = basePath; 168 break; 169 } 170 } 171 172 if( !path ) 173 return MObject::kNullObj; 174 175 MStatus stat; 176 177 MFnDependencyNode fnTex; 178 fnTex.create( MString( "file" ), &stat ); 179 check_status( stat ); 180 181 sstr< 1024 > nameBuf; 182 MangleShaderName( nameBuf, shaderName ); 183 nameBuf.Append( "_tex" ); 184 185 fnTex.setName( MString( nameBuf ), &stat ); 186 check_status( stat ); 187 188 MPlug filePlug = fnTex.findPlug( MString( "fileTextureName" ), &stat ); 189 check_status( stat ); 190 191 stat = filePlug.setString( MString( path ) ); 192 check_status( stat ); 193 194 MObject ret = fnTex.object( &stat ); 195 check_status( stat ); 196 197 return ret; 198 } 199 149 200 int BspImporter::GetShaderIndex( const std::vector< q3::dshader_t > &shaders, int shaderNum, int lightmapNum ) 150 201 { … … 172 223 173 224 MStatus stat; 225 226 MDGModifier dgMod; 227 174 228 MFnLambertShader fnShader; 175 229 … … 185 239 MObject shaderObj = fnShader.object( &stat ); 186 240 check_status( stat ); 241 242 MObject texObj = ImportTexture( shader.shader ); 243 if( texObj != MObject::kNullObj ) 244 { 245 MFnDependencyNode fnTex( texObj, &stat ); 246 check_status( stat ); 247 248 MPlug texColorPlug = fnTex.findPlug( MString( "outColor" ), &stat ); 249 check_status( stat ); 250 //MPlug texTransPlug = fnTex.findPlug( MString( "outTransparency" ), &stat ); 251 //check_status( stat ); 252 253 MPlug shaderColorPlug = fnShader.findPlug( MString( "color" ), &stat ); 254 check_status( stat ); 255 //MPlug shaderTransPlug = fnShader.findPlug( MString( "transparency" ), &stat ); 256 //check_status( stat ); 257 258 259 stat = dgMod.connect( texColorPlug, shaderColorPlug ); 260 check_status( stat ); 261 //stat = dgMod.connect( texTransPlug, shaderTransPlug ); 262 //check_status( stat ); 263 } 187 264 188 265 MFnSet fnGroup; … … 200 277 MObject groupObj = fnGroup.object( &stat ); 201 278 check_status( stat ); 202 203 MDGModifier dgMod;204 279 205 280 MPlugArray connections; … … 717 792 } 718 793 719 void BspImporter::Import( std::istream &stm, const MObject &parentXform )794 void BspImporter::Import( std::istream &stm, const MObject &parentXform, const char *basePath ) 720 795 { 721 796 size_t base_pos = stm.tellg(); … … 728 803 729 804 m_fileData = ∈ 805 m_basePath = basePath; 730 806 731 807 ParseEntities(); … … 773 849 file.open( filename.resolvedFullName().asChar(), std::ios::in | std::ios::binary ); 774 850 851 MString basePath = filename.resolvedPath(); 852 853 basePath = basePath.substring( 0, basePath.length() - 2 ); 854 855 int idx = basePath.rindex( '/' ); 856 if( idx > 0 ) 857 basePath = basePath.substring( 0, idx ); 858 775 859 try 776 860 { … … 789 873 790 874 BspImporter imp; 791 imp.Import( file, xformObj );875 imp.Import( file, xformObj, basePath.asChar() ); 792 876 } 793 877 catch( std::exception &ex ) trunk/maya2q3/maya_entry.cpp
r543 r547 26 26 27 27 static const char *g_vendor = "HermitWorks"; 28 static const char *g_version = "3.3. 2";28 static const char *g_version = "3.3.3"; 29 29 static const char *g_reqVer = "Any"; 30 30
