View Full Version : assigning a texturemap via maxscript

01 January 2009, 07:23 PM
I'm currently writing a little tool to go through all textures assigned to geo in my scene and change their texture-maps from .psd to .tga. I have got all my loops working fine to take their existing filename and create a string which is the corresponding .tga version (all textures will share the same name but with the different extension).

However I seem to have hit a roadblock actually using this string to change the currently used texture. So going back to basics I have just written the following;

myBmp = "c:\512.tga"
isValid = doesFileExist myBmp
$.mat.materialList[1].diffuseMap = myBmp

What I am not understanding is that I get an error saying;

-- Unable to convert: "c:\512.tga" to type: TextureMap

Now I know that that texture exists because isValid returns true. I'm sure I am doing something blatently obvious but I can't figure what!

Any suggestions would be great.

01 January 2009, 07:37 PM
I think the issue is because you need to stick the map inside a bitmap texture map. You are trying to map an image off disk, but the image must be placed inside the bitmap. So create a bitmaptexture and assign your map to it, then assign it to the diffuse slot or, assign a bitmaptexture to the diffusemap, then set .filename parameter to the image file.meditamterials[1].diffusemap = bitmaptexture
meditmaterials[1].diffusemap.filename = myBmpormyBmp = bitmaptexture filename:"c:\512.tga"
meditmaterials[1].diffusemap = myBmp-Eric

01 January 2009, 07:39 PM
awesome thanks very much :)

CGTalk Moderation
01 January 2009, 07:39 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.