Hello everyone,
I am trying to convert a vray material into a standard material, and I have a problem to write this algorithm in MAXScript :
if (the bump map slot is not empty) do
(if (the slot contains a normal map) do (normal map goes to bump slot of the standard material)
else (bump map goes to bump slot of the standard material))
Probably I'm wrong, but the problem is that i don't know how to differentiate the 3 possible choices.
This is my actual code which is wrong :
for o in geometry do
(
if classof o.material == VRayMtl do
(
newmtl = Standardmaterial ()
if (o.material.texmap_bump != undefined) do
(
if o.material.texmap_bump.normal_map.filename != undefined then
(
newmtl.bumpMap.FileName = o.material.texmap_bump.normal_map.filename
newmtl.bumpMapAmount = o.material.texmap_bump_multiplier
)
else
(
newmtl.bumpMap.FileName = o.material.texmap_bump.filename
newmtl.bumpMapAmount = o.material.texmap_bump_multiplier
)
)
o.material = newmtl
)
)
Thank you.
By
Comments (10)
Comment policy
I found the real problem.Do
I found the real problem.
Do you know how to test if inside the Normal Map there is a map ?
Your script doesn't contain this case.
In your script, even if you remove or not the line "obj.material.texmap_bump.normal_map.filename != undefined", the VrayNormalMap won't be converted to Normal Map with a material with a Normal Map with no map inside.
In my script if I add the line "o.material.texmap_bump.normal_map.filename != undefined" as a condition, and if I have just a bump map in my material, I will have this error "Unknown property: "filename" in undefined".
I will be grateful if you can solve this problem.
if you want to test if "NormalBump" have "mormal_map" use this
For your code not need to twice check NormalMap, try this
nMap = o.material.texmap_bump
if nMap != undefined and (isKindOf nMap Bitmaptex or isKindOf nMapNormal_Bump) do
(
newmtl.bumpMap = nMap.normal_map
newmtl.bumpMapAmount = o.material.texmap_bump_multiplier
)
Thank you ! I've used both of your codes to integrate it with mine. I understand how it works now.
fine.now you can continue with the rest of script.
cheers!
I have a new problem.
I want to add the case where the bump map slot contains a checker (for example)
First I transform the checker into a Bitmap inside a path name ThePath
But after this I cant insert this Bitmap inside the new bump slot of my Standardmaterial
I have this :
And this error : Unknown property: "filename" in undefined
I don't know how to say that o.material.texmap_bump is not checker but Bitmap.
I need your help.
This is your code
Don't use any more ".FileName" property to assigne bitmap.
You have more then this problem in your code.
Compare my code and your and you;ll see what i mean.
for o in geometry where not isKindOf o targetObject and classof o.material == VRayMtl do
(
newmtl = Standardmaterial diffuseMap:(o.material.texmap_diffuse)
if o.material.texmap_bump != undefined do
(
if not (isKindOf o.material.texmap_bump Bitmaptexture) then
(
-- add your path (this is only for testing)
fileNameImg = @"C:\temp\testMap.jpg"
rm = renderMap o.material.texmap_bump \
size:[1024,1024] \
fileName:fileNameImg \
filter:true \
save rm
close rm
o.material.texmap_bump = Bitmaptexture bitmap:rm
newmtl.bumpMap = o.material.texmap_bump
newmtl.bumpMapAmount = o.material.texmap_bump_multiplier
)
else
(
newmtl.bumpMap = o.material.texmap_bump
newmtl.bumpMapAmount = o.material.texmap_bump_multiplier
)
)
o.material = newmtl
)
Thank you very much.
What does it mean this : "where not isKindOf o targetObject" ?
Means that target objects (camera, light target etc.) are
also geometry objects and should be isolated from for-loop
try this to see from yourself
a=targetobject()
superclassof a
--GeometryClass
You can red this thread
http://www.scriptspot.com/forums/3ds-max/scripts-wanted/switch-maps-text…
I saw it. But I didn't find any clue in it.