3ds Materials & Names
Blitz3D Forums/Blitz3D Programming/3ds Materials & Names
| ||
| Hey All, Here's a super-tricky one for you. (I think!) I need to figure out what the Name of the materials assigned to 3ds objects that are loaded into blitz are. I don't think at this point that this information is included in the load, but if it is, that would be great, I just don't know how to get it! As far as I can tell, 3ds material properties, such as color and texture are loaded with objects, but what about the name?? So anyway, when a 3ds is saved out, the material names are encoded into it. Looking at a format specification, I found that this is encoded in chunk Axxxh, and actually the name is a CSTR which resides at A000h. Is there a way to pull this string out of a 3ds file from within Blitz? Any helpful info or ideas would be greatly appreciated. I'm not sure if there are helper DLLs which I could use or what, but I'm open for suggestions! Thanks, Roland |
| ||
| There is a tool called 3D Exploration, if you can find an early version of the beta this may list the materials. Otherwise post the file here and ask us to look at it for you - if we can use some of the tools we have - milkshape, UUnwrap, Max itself we may be able to help. Btw as 3ds is an older format the names have to be 8.3 format. IPete2. |
| ||
| Would this help at all? http://www.blitzbasic.com/codearcs/codearcs.php?code=289 |
| ||
| Thanks for the replies, guys... IPete2 -- I've used this tool, and this would work if this was just for my own use, but i'm hoping to have this software work for others and be self-contained... so I'm afraid this won't do it. But thanks for the head's up! Joe -- This looks really interesting. Do you know if it shows only textures, or if it can return the actual material name? Thanks again! roland |
| ||
| Try this. It copies a model's (f$) textures to a destination folder. You can probably mod it to suit yourself. Yeah, I should probably add it to the code archives.
;-----------------------------------
Function CopyTextures(f$,destdir$)
;-----------------------------------
Local m$, z, md$, hfile
Local index, index1, index2, index3, lastindex
Local modelpath$
If f$<>""
modelpath$ = FullpathGetPath$(f$) ; <- substitute your own path
hfile = ReadFile(f$)
While Not Eof(hfile)
If Right$(Upper$(f$),2)=".X"
m$ = ReadLine$(hfile); implements 0D,0A
Else
m$ = ""
Repeat
If Eof(hfile) Then Exit
b = ReadByte(hfile)
If b = 0 Then Exit
m$ = m$ + Chr$(b)
Until b = 0 And m$<>""
If Eof(hfile) Then Return
EndIf
If m$<>""
lastindex = 0 : firstindex = 0
index = 0 : index1 = 0 : index2 = 0 : index3 = 0
index1 = Instr(Upper$(m$),".BMP") : index = index1
index2 = Instr(Upper$(m$),".JPG") : index = index2
index3 = Instr(Upper$(m$),".PNG") : index = index3
If index1 > 0 Then index = index1
If index2 > 0 Then index = index2
If index3 > 0 Then index = index3
If index1<>0 Or index2<>0 Or index3<>0 ;Print m$
For z = 1 To 4
md$ = Mid$(m$,index+z,1)
val = Asc(md$)
If val<=0 Or val=34 Or val=Asc("\") Or val>127
lastindex = index+z-1
z = 4
EndIf
Next
m$ = Left$(m$,lastindex) ;Print m$
firstindex = 1 ; in case no exit coz its a whole string.
For z = Len(m$) To 1 Step -1
md$ = Mid$(m$,z,1)
val = Asc(md$)
If val<=0 Or val=34 Or val=Asc("\") Or val>127
firstindex = z+1
z = 0
EndIf
Next
m$ = Mid$(m$,firstindex) ; Print m$
If m$<>""
sour$ = modelpath$+"\"+m$
CopyFile sour$,destdir$+"\"+m$
EndIf
EndIf
EndIf
Wend
CloseFile(hfile)
EndIf
End Function
|
| ||
| John, Nice one! Ipete2. |
| ||
| Thanks, Pete. Yeah, I've just re-read it and I know it looks laughably crude, but I remember that my brother wanted this by the end of the day, so that's why it was slapped together. |
| ||
| This looks really cool John. Thanks for the response. I'll see if I can mod it to find the info that I need. Thanks again! roland |
| ||
| Cheers, it's now also in the Code Archives / Misc. |