Notifications
Clear all

[Closed] UVW Map Co-ords

Hi everyone,

Ok i am a little stuck with this script I am trying to create – i have spent much time with it and tried different things to some sucess.

If I render anything in a specific scene where a texture is applied but no uvw mapping co-ords are applied, I get a uvw mapping error (which is fine), which when going to backburner throws an error.

I tried to find a way via the error but i foudn out what happens with Max but I cannot do things different upon that error (Do nothing since the texture is a solid colour).

So i decided to write a script that search’s through all the geometry and to put the objects that have a bitmap applied to it (i originally tried to search through all the maps but was proving difficult).

Main issue
[ol]
[li]My main issues are when it comes to a multimaterial being nested inside another multimaterial. I can get it working with a standard material fine.[/li][li]I search through the modifier stack and if their is not a unwrap or uvw_mapping modifier then apply one – problem here is if i do have 3 modifiers that arnt unwrap or uvw_mapping, then these modifiers will be applied 3 times instead of the once.[/li][/ol]My script is now not completely adapatable, I am using specific name objects that are known to not have the mapping co-ords, I tried to make it search through all the scene but I ended up running around in circles.

Code


uvwMapArray = $flap_movable_front* as array
uvw = uvwmap()
for i = 1 to uvwMapArray.count do
(
for n = 1 to uvwMapArray[i].modifiers.count do
(
case classof uvwMapArray[i].modifiers[n] of
(
uvwmap: print "Already has has a UVW Mapping modifer" 
UVWunwrap: print "Already has a Unwrap_UVW modifier"
Default: addModifier uvwMapArray[i] uvw
)
)
)

Many thanks for any help, also any optimization of the above please feel free to share I am at a point in my scripting where I am getting annoyed at not knowing how to optimise.

Thanks

Alan

An earlier attempt at a more versatile script

 
 
fn standMat g =
(
--g = $flap_movable_front03
for i = 1 to g.modifiers.count where classof g.mat.diffusemap == bitmapTexture and classof g.modifiers[i] != Uvwmap do
(
print g
)
)
 
fn multiMat g =
(
 for i = 1 to g.mat.numsubs do --where classof g.mat[i].diffusemap == bitmapTexture do --and g.mat[i].diffusemap != undefined and g.mat[i].diffusemap != UndefinedClass do
 (  
  case classof g.mat[i] of
  (
   standardMaterial: print "StandM"
   multiMaterial: print "MM"
   default: Print "Something Else"
  )
 ) 


 
for g in geometry do
(
case classof g.mat of 
(
standardMaterial: standMat g
multiMaterial: multiMat g
default: "No Idea"
)
)

15 Replies
 JHN

With that error isn’t it the problem an object doesn’t have UV coords instead of not having a bitmap assigned to it? If so the script should identify objects without uv channels and assign a uvmap accordingly…

Just thinking out loud.

-Johan

 JHN

(
	local noMaps = #()
	for o in geometry where not isKindOf o TargetObject do
	(
		if not meshop.getMapSupport o.mesh 1 do append noMaps o
	)
	format "%
" noMaps
)

This will return an array of objects that don’t have a mapping channel 1. It’s mostly save to presume that a mapping channel 2 is also not present, but maybe you should build in more checks.

-Johan

Ok i think i get what your doing, and it through testign it works, but the issue is their are materials that dont have a bitmap applied, and some that do have a bitmap applied. ONLY the objects that have materials applied (which have a bitmap) NEED to have a mapping co-ords. When the error comes up I get about 8 objects (in this instance) but with after executing the scipts I get 53 objects.

Now I am unsure if geometry that has a material (but this material doesnt have a bitmap applied) need mapping co-ords (uvw mapping as such).

i only get the error when the objects material has a bitmap applied.

For me this is what make sit so difficult as i have many things to check for and with multimaterials nested within multimaterials this becomes increasingly difficult. I successfully done this with standard materials but not with multimaterials.

Thanks for the help – it is definately more efficient than what mine is. If you have any further idea…or if i have misunderstood the above about mappign co-ords pls let me know.

Thank you

Alan

1 Reply
(@artofsoulburn)
Joined: 11 months ago

Posts: 0

You may find some useful functions in the sLib.ms file that’s part of this pack…

http://www.neilblevins.com/soulburnscripts/soulburnscripts.htm

For example, sLibGetAllSceneMaps() followed by sLibGetBitmapsFromMaps(0 might be useful, as they get all maps, even ones in multimaterials.

  • Neil

Ok thanks Neil, looking at this too. Will report back my progress. Cheers guys.

Alan

Hi

@JHN

I tried your script and I understand enough of your scripts and I tried it with geometry that have a uvw map mod applied and one without (that has a material with a bitmap texture) and I get true or false which is good. The main problem I have now is the multimaterials.

@Neil

I have had a look through the script and the functions you provided. I understand some of the stuff thats going on and some is useful, but there are some elements in the functions that I cant find information (from AutoDesk Help Docs) to help me understand whats happening, such as:

if superclassof mat[i].object == textureMap then

I dont understand the ‘.object’ bit. I search ‘object’ in the help docs and, just about every reference possible is returned.

I coupled various functions together which are needed by ‘sLibGetAllSceneMaps’ (which requires no input i believe?) and i exectued it (obviously removed the macroscripts) and it returned #(Map #15:Raytrace) in the Listener which…it should have returnd a lot more?

I will compile some code to filter through geometry with getMapSupport and check for a standard material. Now in this specific scene there is less geometry with a material (that constains a texture) applied, than geometry with a procedural material. So it makes sense to filter first via objects that have a material (with a texturemap) applied to them then the getMapSupport filter. What would you guys recommend since you guys haev worked on a lot mreo projects than me, search through geometry first for getMapSupport or materials (containing texturemaps)?

Thanks for the assistance guys.

Alan

1 Reply
(@artofsoulburn)
Joined: 11 months ago

Posts: 0

So the way I am traversing the material is by traversing all of the animatable properties of the material, and trying to figure out which of these properties are a texturemap. Take a look in the helpfile for ‘numsubs’, and you’ll see what .object does…

Indexed Access to Animatable Properties in 3ds Max Objects<subAnim>.object : MAXWrapper, read-only

Yields the subAnim object, or undefined if not assigned. This property is read-only. The .object property may return any kind of MAXWrapper object, depending on what the parent object decides to put there. For example, <node>[1].object is the visibility controller or undefined if not yet assigned, <node>[2].object contains the bindings of any space warps bound to the node, or undefined if none have been bound, <node>[3].object is the transform controller, <node>[4].object is the node’s object, either the modified object if there are modifiers present or the base object if not, <node>[5].object is the material assigned to the node or undefined if no material has been assigned, and <node>[6].object is the Image Motion Blur Multiplier controller or undefined if not yet assigned.

This allows me to traverse any mutisubobject material, blend material, etc without the need to write speciality code for each material type.

That function will get every map that’s in a material that’s assigned to a scene object. Maybe many of your maps exist in the material editor only and aen’t assigned to scene materials?

  • Neil

Ok here is one for the standard Material. The objects that have a material appleid (which contains ‘ANY’ bitmap texture in its map slots will be added to ‘objArray’. The actual Maps that are used are added into another array ‘objMatsArray’.


objArray = #()
objMatArray = #()
for g in geometry where classof g.mat == Standardmaterial do
(
	 --append objArray #(g, #())
	 for i = 1 to g.mat.maps.count where g.mat.maps[i] != undefined and classof g.mat.maps[i] == bitmapTexture do
	 (
		 append objArray g
		 appendIfUnique objMatArray g.mat.maps[i].filename
	)
)
objArray
objMatArray

Johan next i would use an example of your script to search through the array to find which of these elements dont have a map channel. But first a dynamic multimaterial (which can check nested standard mats and multimats). :banghead: this is where I will try to further understand what is happenning in your script Neil.

Any further intervention/ideas/suggestions is definately welcome!

Thanks guys

Alan

 JHN

Okay, maybe doing it the other way around is better.


nodeArrTemp = #()
nodeArr = #()

-- Get all nodes with a texture applied (no problems with what kind of material)
for n in getClassInstances bitmapTexture do join nodeArrTemp (refs.dependentNodes n)

-- Get unique nodes without mapping channel 1
for n in nodeArrTemp where not meshop.getMapSupport n.mesh 1 do appendIfUnique nodeArr n

format "%
" nodeArr

This finds first all bitmap textures, with the textures we lookup up the dependentNodes, these are the nodes with textures applied, note, the type of material doesn’t matter!
With these node we check which have a UVmap channel 1, with my other function.

So nodeArr returns and array with textured nodes, without the UV channel 1.

Hope this is what is needed,
-Johan

 JHN

So did it work out?

-Johan

Hi

Thanks for both your replies – I am currently tangled up with something else, I havnt forgot what you both have provided me just cant learn from it right at this moment.

But I wanted to say thanks.

Alan

Page 1 / 2