PDA

View Full Version : Obtaining a list of textures from multisub materials.


NestorPL
08-14-2007, 10:43 PM
Hello everyone!

I'm writing a little geometry exporter for the OpenGL project I'm doing.
So far I've managed to get the geometry out right, but I have major problems with texture names.

What I already have: all geometry data, mapping data, material ID data per face

Whan I need: list of texture names without the full path that were used with the object in question, so I can corelate that with the texture database in my project.

My attempt so far :

out_name = "c:/testdump2.dat"
out_file = fopen out_name "wb"



mats=sceneMaterials
for mtl in mats do
(
if (classof mtl == standardMaterial) then
(
if mtl.diffuseMap != undefined then
(
WriteString out_file mtl.diffuseMap.filename
)
)
else if (classof mtl == multimaterial) then
(
for sMat in mtl do
(
if sMat.diffuseMap != undefined then
(
WriteString out_file mtl.diffuseMap.filename
)
)
)
)
)

The error message I get is : >> MAXScript Rollout Handler Exception: -- Unknown property: "diffuseMap" in #Multi/Sub-Object:Material #79(Standard:Material #25, Standard:Material #26, Standard:Material #27) <<
#56(Standard:Material #26, Standard:Material #25, Standard:Material #27) <<

Oddly enough, it appears at random parts of the above code really. Refreshing the source of maxscript to make it run makes me furious sometimes.

Anyways, can someone point what I am doing wrong here?

The output of the file is expected to be :
tex1.bmp
tex2.bmp
etc etc.

Thanks in advance for any tips you might have.

PiXeL_MoNKeY
08-14-2007, 10:52 PM
Multimaterial has no diffuse or other map slots. The submaterials of the multimaterial will, though. So you need to use something like mtl.materialList[sMat].diffusemap, where mtl = the Multimaterial and sMat = the array index of the submaterials. Look up Multimaterial in the Maxscript help for more info.

-Eric

kikialex
08-15-2007, 08:06 AM
--where to create the file(nume_unde)
fn c_dump nume_unde =
(
if nume_unde != "" do
(
try(
fis_1 = createfile nume_unde
mng = #()
cat_total = 0
mng = getClassInstances bitmaptexture
for m in mng do
(
print (getFilenameFile m.filename) to:fis_1
)
close fis_1
edit nume_unde
)
catch(MessageBox "Error")
)
)


c_dump "c:\dump.txt"

NestorPL
08-18-2007, 03:34 AM
Thanks kikialex,

I have modified your example a bit to fit my needs. Had a bit of a problem with variable scope, but eventually I figured it out.

out_file = createfile ((getfilenamefile nume_unde)+".ntex")
mng = #()
cat_total = 0
mng = getClassInstances bitmaptexture
for m in mng do
(
print (filenamefrompath m.filename) to:out_file
)
close out_file

It creates a texture reference file with the same name as the model file, which can then be reused by the engine.

Thanks for bringing those few functions to my attention.

kikialex
08-18-2007, 08:03 PM
Hi, I'm happy you found my answer helpful, I just wanted to say that "cat_total" is not used in that piece of code

CGTalk Moderation
08-18-2007, 08:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.