Jump to content

Random UVW Script in existence anywhere?


Dave Buckley
 Share

Recommended Posts

Guys

 

I have 1500 pieces of wood that need texturing, easy enough to do, simple wood material, simple UVW map, they are all identical in terms of size. my obvious problem is how repetitive the same wood texture will look on all of them with the same uvw settings.

 

i know i can give them all unique mapping by hand, i just wondered of a more efficient way to do it and my first thoughts were a script that randomly adjusts the position of the uvw map of selected objects.

 

does anyone know of anything like this or have any methods that i could use. Until i get a response i'm doing this one by one because i clearly have no life/need to learn scripting

 

it's quite important each piece is unique as they are the main focus and there is nothing worse for me than obvious repetition.

 

cheers

Link to comment
Share on other sites

apply a UVWmap to all your objects, select the "make unique" option to break all the instancing then execute the following.... (with all your objects still selected)

 

 

for o in $ do

(

randX = random 0 1000

randY = random 0 1000

randZ = random 0 1000

o.modifiers[#UVW_Mapping].gizmo.position = [randX,randY,randZ]

)

 

 

your other option would be to make a handful of wood maps and use the mutlitexture script found here ....

http://www.cg-source.com/multitexture.php

Link to comment
Share on other sites

brian your a hero, acjwalker just reminded me about the 'screen mapping technique' over on twitter, it was a good effort but the angle of the planks on screen and the grain in the wood weren't working using that method. i'll give this scripting a shot, my scripting knowledge is no-existent, how do i get what you've just written as a neat little button on my custom toolbar, i've a feeling i'll use it quite a lot.

 

i think the multi-texture script is what pixela used on his recent viz pro of the week images, and that's kind of what i'm trying to do, will give both a shot

Link to comment
Share on other sites

quickest way to make a button would be to highlight the text in your internet browser, then drag it straight to the max tool bar at the top of your screen, the cursor will change to a "+" sign acknowledging that it's going to add it as a button.

 

Then you can right click on the button and change it's appearance.

Link to comment
Share on other sites

Brian. tried and tested, works amazing, what i thought was going to take for ages, now takes a whopping 5 clicks maximum, select all, apply material, apply uvw map, make unique, new uvw script button, BANG just what i wanted (test result attached for those who are interested)[ATTACH=CONFIG]37489[/ATTACH]

Link to comment
Share on other sites

Yup, maxscript can blow your mind once you realize how powerful it is when you build your own tool kit to do things exactly how you want them done. I've really been diving into it lately..... I graduated with a minor in programing so it's nice to be putting all that education to work in production. I don't remember much of my C++ syntax, but the concepts and theories all apply.

 

Hardest part of it is getting off the hamster wheel to re-adjust your methods. Sure you could keep plugging away manually adjusting every map, because you know how to do it and it works. But breaking away for that hour of your day to learn/write a new maxscript will equal the same amount of time you intially put into it, and then the next time you need to do the same task already have a 5 click fix in your toolkit.

 

BTW, your test looks like its on the right path..... but you might want to consider making the UVW map larger than the geometry itself, that way parts of the map don't always get used on each board. I see a dark knot that appears on every board. Although it's never in the same spot it shows that they're all mapped with the same texture.

Edited by BrianKitts
Link to comment
Share on other sites

Yup, maxscript can blow your mind once you realize how powerful it is when you build your own tool kit to do things exactly how you want them done. I've really been diving into it lately..... I graduated with a minor in programing so it's nice to be putting all that education to work in production. I don't remember much of my C++ syntax, but the concepts and theories all apply.

 

Hardest part of it is getting off the hamster wheel to re-adjust your methods. Sure you could keep plugging away manually adjusting every map, because you know how to do it and it works. But breaking away for that hour of your day to learn/write a new maxscript will equal the same amount of time you intially put into it, and then the next time you need to do the same task already have a 5 click fix in your toolkit.

 

BTW, your test looks like its on the right path..... but you might want to consider making the UVW map larger than the geometry itself, that way parts of the map don't always get used on each board. I see a dark knot that appears on every board. Although it's never in the same spot it shows that they're all mapped with the same texture.

 

oh for sure i will make it bigger, the knot just helped me see how the script was working. thanks again brian, i must say i use a lot of scripts for mundane tasks, i just don't understand how they work or why they work and i'm intrigued to know and be able to do it myself, but for now, you've helped me put it off for another couple of weeks ;)

Link to comment
Share on other sites

learning wise, this dvd set will probably help more than the book in terms of getting the main ideas up and running in your head, first disk is concepts, second is a "what can you do with 1 line" type book., after that its all about just finding/knowing whats possible to do ;)

 

I've got a million of these little 'snippets' laying around with various states of ui's

Link to comment
Share on other sites

cheers for the link dave will check it out.

 

going back to the original question, can that small bit of script be adapted for things like the mapscaler modifier?

 

i would imagine so . . . damn i really do need to learn it, i've had a day today where i've just thought about how much i could automate what i do . . .

Link to comment
Share on other sites

You can script the width and height of the map gizmo if that's what you mean. UVmap gizmos become a lot more difficult to script when you want to align them to face normals and precisely position them. Unfortunately, they don't move/rotate/scale like any other max object.

 

Like Brian, I've been learning a lot of maxscript in the last 6 months. It really IS amazing what you can do. That said it does require a lot of time, as you'll spend a lot of time reading the maxscript help file. Books and videos can help explain a lot of concepts, but nothing is going to show you how to make the exact script you want to do your special task that suits your workflow. Asking questions on the forums about how to script something is a great way to get answers, but if you're like me, you want answers asap and forums don't often provide instant answers. So I tend to keep reading the help file. You can wait and hour for the forum or read for 30 minutes in the help file! hahaa... or both. I find scripting to be incredibly addictive. It's a good thing I don't do much of it at home or I'd lose a lot of sleep!

Link to comment
Share on other sites

Sure can..... just got to careful that you don't use a larger random selection set since you're now talking about scale factors.

 

The position I set it to pick a random between 1 and 1000 to get a large amount of movement, but for the scale I'm only selecting random values between .5 and 1.5 as to not let the map scale get out of control.... obviously you'd adjust the variance based on your need.....

 

for o in $ do

(

randX = random 0 1000

randY = random 0 1000

randZ = random 0 1000

o.modifiers[#UVW_Mapping].gizmo.position = [randX,randY,randZ]

 

scaleX = random .5 1.5

scaleY = random .5 1.5

scaleZ = random .5 1.5

o.modifiers[#UVW_Mapping].gizmo.scale = [scaleX,scaleY,scaleZ]

)

Link to comment
Share on other sites

  • 1 year later...

Hey thanks a lot for the info.. but ihave a problem. the script works nice for me in 2009 version of max, but since i'm using 2012 i can´t make i work. I´m sure it´s an easy thing, but my knowledge of scripts is also non-existance, and as muck as i try i cant make it work!

 

Thanks again & anyway for everything

 

gas

Link to comment
Share on other sites

  • 8 months later...

hi brian,

i'm on max 2013 64 when i run the script i got this error:

---------------------------

MAXScript MacroScript Error Exception

---------------------------

-- Unknown property: "gizmo" in undefined

---------------------------

OK

---------------------------

any idea on how to fix it?

Link to comment
Share on other sites

hi Ismael, it works fantastic :)

it works on geometries with just assigned uvw map modifier, you can chose the type the fit the axis orientation of the map.... then you can apply the script to the selected geometries pieces.

Link to comment
Share on other sites

  • 2 months later...

Hi I tried the script in max 2012 and it doesn't seem to work there. Though in max 2012 it doens't work anymore and gives the error message --Unknown property: "gizmo" in undefined.

Is there a way to do this in max 2012 too? (I'm sure there is :D )

 

Now I fixed it in my max 2009 and merged the file in my 2012 project, also works but it's a little work more work (still a lot less then changing 1500 uvw's by hand hehe).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...