MoI discussion forum
MoI discussion forum

Full Version: Random color script

Show messages: All  1-4  5-18

From: Frenchy Pilou (PILOU)
25 Nov 2010   [#5] In reply to [#4]
< That's not really a very good structure

Yes but not important, it's just for "artistic purpose" result ;)
so only face or surface will be sufficient :)

Image Attachments:
exoo.jpg 


From: Michael Gibson
26 Nov 2010   [#6] In reply to [#5]
Hi Pilou, right now MoI is not really set up to generate images directly...

Is it possible for you to export your MoI model into SketchUp and then assign random colors for a screenshot inside of there? It kind of looks like you might have some method in SketchUp for that already.

- Michael
From: Frenchy Pilou (PILOU)
26 Nov 2010   [#7] In reply to [#6]
Of course yes I can ;)
It was for win a step :)
From: Michael Gibson
26 Nov 2010   [#8] In reply to [#7]
Hi Pilou, so exporting to SketchUp is probably your best bet for this - the script that would be created in MoI for full color randomization of every single sub-object would be awkward since it would involve creating a huge number of styles.

Maybe in the future there will be some way to assign a color to an object directly overriding its style assignment but currently it is not set up that way.

- Michael
From: Frenchy Pilou (PILOU)
26 Nov 2010   [#9] In reply to [#8]
No problem :)
And just one random color for a solid or by object or by object?
From: Michael Gibson
26 Nov 2010   [#10] In reply to [#9]
Hi Pilou, so I was thinking - do you really need a completely different random color for every single thing? What if it was more like 20 different base colors which were then randomly assigned? That would be a lot easier to set up because that would only involve creating 20 styles.

So the way that would work would be to first set up 20 different styles, and you can assign them the colors that you want, or use the script from here to randomize their colors:
http://moi3d.com/forum/index.php?webtag=MOI&msg=2987.2


Then you can use the following script on a shortcut key to randomly assign each face or edge to one of those styles:

script: /* Assign random styles to faces and edges */ var styles = moi.geometryDatabase.getObjectStyles(); var breps = moi.geometryDatabase.getObjects().getBReps(); for ( var i = 0; i < breps.length; ++i ) { var brep = breps.item(i); var edges = brep.getEdges(); for ( var j = 0; j < edges.length; ++j ) { edges.item(j).styleIndex = Math.floor(Math.random() * styles.length); } var faces = brep.getFaces(); for ( var j = 0; j < faces.length; ++j ) { faces.item(j).styleIndex = Math.floor(Math.random() * styles.length); } }


You can also just use this with the default set of styles as well, it will randomly assign each face or edge to one of the current style colors. Then if you want more variety add more styles.

- Michael
From: Frenchy Pilou (PILOU)
26 Nov 2010   [#11] In reply to [#10]
Thx I will see that as soon as possible :)
From: Frenchy Pilou (PILOU)
28 Nov 2010   [#12]
Works like a charme! You rocks!
http://moiscript.weebly.com/randomcolor.html
Speedy test!
Ps No problem but there is a white color who is not inside the default Style


Image Attachments:
speedytest.jpg 


From: Michael Gibson
28 Nov 2010   [#13] In reply to [#12]
Hi Pilou, I'm glad that will work for you!

> Ps No problem but there is a white color who is
> not inside the default Style

What options do you have enabled under Options > View > Lighting options, did you turn on the option for "Specular highlights" in there?

That option makes white shiny spots on objects, so turn that off.

- Michael
From: Frenchy Pilou (PILOU)
28 Nov 2010   [#14] In reply to [#13]
Yes it was some enable Metallic Lights :)
From: Frenchy Pilou (PILOU)
28 Nov 2010   [#15]
Seems Styles are losted when you export as SKP file
Is that normal?
From: Michael Gibson
28 Nov 2010   [#16] In reply to [#15]
Hi Pilou, yes currently styles are not exported to SKP format.

One reason for that was that I wasn't sure how they should be exported - SketchUp has a couple of different ways for assigning colors, there are both Layers and Materials.

I think with the previous discussion here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=3790.16 it was resolved that Layers are not generally used in SketchUp so that styles should be exported as Materials. That's something that I will be trying to add in for MoI v3.

- Michael
From: Frenchy Pilou (PILOU)
28 Nov 2010   [#17] In reply to [#16]
Cool :)
From: NightCabbage
29 Nov 2010   [#18]
Hehe, yes, I'm also very interesting in coaxing Michael into adding basic rendering into MoI :)

(even for 2d stuff)

Would cut out 2 or 3 programs in my workflow LOL

Show messages: All  1-4  5-18