≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Vertex color by material slot
Posted by:
(you are not logged in)
Enter the missing letter in: "Interna?ional"
(you are not logged in)
Text:
[quote][b]Guest[/b] wrote: So I'm interested in vertex color and procedural textures for my future CC project. Graphics like the original Playstation. That said, I've been making some tools to work with various free CC0 low poly models I've found. I'm really a big fan of these modelers who give out these great sets for free, and I want to make using them in CC more enjoyable. I have quite a few ideas to chase at the moment, but recently Just_In_Case put my "Random Vertex Color" editor plugin on his great website. This new editor plugin takes in the number of materials assigned to a model and allows the user to set a vertex color per material slot. Here is the code: [code] // CopperCube editor plugin that sets a vertex color per material function vertexColorByMaterial() { var meshnode = editorGetSelectedSceneNode(); var bufferCount = ccbGetSceneNodeMeshBufferCount(meshnode); alert("Selected node has " + bufferCount + " material(s)."); if (bufferCount == 0) alert("The selected node has no 3D geometry."); else { for (var i = 0; i < bufferCount; ++i) { var vertexcount = ccbGetMeshBufferVertexCount(meshnode, i); var rgb = prompt( "RGB" + "[" + (i + 1) + "/" + bufferCount + "]: ", "64,64,64" ); var rgbStr = rgb.replace(" ", ""); var rgbArr = rgbStr.split(","); var r = parseInt(rgbArr[0]); if (r < 0) { r = 0; } if (r > 255) { r = 255; } var g = parseInt(rgbArr[1]); if (g < 0) { g = 0; } if (g > 255) { g = 255; } var b = parseInt(rgbArr[2]); if (b < 0) { b = 0; } if (b > 255) { b = 255; } for (var v = 0; v < vertexcount; ++v) { function rgbToHex(r, g, b) { return ( "0x" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1) ); } var color = rgbToHex(parseInt(r), parseInt(g), parseInt(b)); ccbSetMeshBufferVertexColor( meshnode, i, v, parseInt(Number(color), 10) ); } } } } editorRegisterMenuEntry( "vertexColorByMaterial()", "Apply vertex color per material\tCtrl+Shift+L" ); [/code] I give this code to the CC community to do with what they want, free of charge, for both non-commercial and commercial purposes. Consider it CC0. No credit needed. Simply copy and paste the code into a text file, save it as "vertexColorByMaterial.js", then place it in your CC plugins folder in your CC documents folder. The key combo for this plugin is "Ctrl+Shift+L" but can be changed to anything you want by simply changing this line of code: [code] editorRegisterMenuEntry( "vertexColorByMaterial()", "Apply vertex color per material\tCtrl+Shift+B" ); [/code] Note: In the example code above, I have changed "Ctrl+Shift+L" to "Ctrl+Shift+B". I hope someone finds this code useful. Cheers.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact