int AseFile::Init(char *file_name, int MipLevels, int rotateX90, float scale, int loadNormalMap, int loadHeightMap) { char strMessage[255]={0}; DeleteAll(); file = fopen( file_name, "rb"); if(!file) { sprintf(strMessage, "Unable to find the file: %s!", file_name); MessageBox(NULL, strMessage, "Error", MB_OK); return 0; } char *pdest = strrchr( file_name, '/' ); if( pdest==NULL)directory[0]=NULL; else { strncpy( directory, file_name, pdest-file_name+1); directory[pdest-file_name+1]=NULL; } int ret = ReadAseFile(); fclose( file ); if(!ret)return 0; if(!LoadTexturesDiffuse(MipLevels))return 0; if(loadNormalMap) if(!LoadTexturesNormal(MipLevels))return 0; if(loadHeightMap) if(!LoadTexturesHeight(MipLevels))return 0; if(rotateX90)RotateX90(); if(scale!=1.0f)Rescale( scale); MakeBoundingBoxs(); for(int i=0; i<objects.size(); i++) // if(objects[i].pFaceNormals==NULL || objects[i].pNormals==NULL) ComputeNormals(objects[i]); if(loadNormalMap) ComputeTangentBinormal(); return 1; }
bool CLoadASE::ImportASE(t3DModel *pModel, char *strFileName) { char strMessage[255] = {0}; if(!pModel || !strFileName) return false; m_FilePointer = fopen(strFileName, "r"); if(!m_FilePointer) { sprintf(strMessage, "Unable to find or open the file: %s", strFileName); MessageBox(NULL, strMessage, "Error", MB_OK); return false; } ReadAseFile(pModel); ComputeNormals(pModel); ComputeTangents(pModel); fclose(m_FilePointer); return true; }