Originally Posted by
Petr Schreiber
I checked the code now, loading M15 from memory is okay, but I wonder - how would you expect it to seek for textures?
Because by default, it looks for the on HDD. Maybe passing array with texture IDs? Let me know!
Petr
I think the best way is to make a big function called LoadM15FromZip(Zipfile,M15file,Pass) witch :
1) extracts M15 to memory
2) Extracts Texture names from M15
3) Looks for names as files in the same zipfile
4) Extracts Textures to memory from zip file
5) Catches the textures from memory and Mesh from memory
Procedure.i LoadMeshFromZip(nomfichier.s,zipfile.s=#CurrentZipArchive,pass.s=#ZipPassword)
Static myFileinfo.PureZIP_FileInfo
If PureZIP_Archive_Read(zipfile)
PureZIP_SetArchivePassword(pass)
NB=PureZIP_FindFile(zipfile, nomfichier)
PureZIP_GetFileInfo(zipfile, NB, @myFileinfo)
Debug "Found " + myFileinfo\FileName
Debug "unCompressed Size: " + Str(myFileinfo\unCompressedSize)
*MemoireTampon1 = AllocateMemory(myFileinfo\unCompressedSize)
Debug PureZIP_ExtractMemory(zipfile,NB,*MemoireTampon1, MemorySize(*MemoireTampon1))
Texte$ = PeekS(*MemoireTampon1,myFileinfo\unCompressedSize)
position=1
posf = 1
Repeat
Position = FindString(Texte$, "TextureFilename",posf)
If Position >0
posi=FindString(Texte$, Chr(34) , position+1 )
posf=FindString(Texte$, Chr(34) , posi+1 )
;Debug posi
;Debug posf
If posf>posi
TextureName$ = Mid(Texte$, posi+1, posf-posi-1)
Debug "Found Texture : "+ TextureName$
NB.i=PureZIP_FindFile(zipfile, TextureName$)
PureZIP_GetFileInfo(zipfile, NB, @myFileinfo)
*MemoireTampon = AllocateMemory(myFileinfo\unCompressedSize)
PureZIP_ExtractMemory(zipfile,NB,*MemoireTampon,myFileinfo\unCompressedSize)
Debug "Extracting texture.."
textur = MP_catchtexture(*MemoireTampon,myFileinfo\unCompressedSize,1,1)
MP_TextureSetName (Textur ,TextureName$)
EndIf
EndIf
Until position=0
mesh = MP_catchMesh(*MemoireTampon1,MemorySize(*MemoireTampon1))
Debug "Model loaded"
FreeMemory(*MemoireTampon1)
PureZIP_Archive_Close()
ProcedureReturn mesh
EndIf
EndProcedure
This is how i do in purebasic
the procedure loads a .X text mesh where the texture file names are indicated by "TextureFilename" string
the MP_catchMesh function looks for a variable called textur by defaut, and applies it on the mesh, if the textur variable is empty so the mesh will appear bold
so in the program we must preload the texture by textur=catchtextur function before calling it
Hope it may help
Bookmarks