≡
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: "In?ernational"
(you are not logged in)
Text:
[quote][b]Guest[/b] wrote: Noticed a minor error. Here's the updated 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" ); if (rgb) { 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) ); } } else { // Do nothing } } } } editorRegisterMenuEntry( "vertexColorByMaterial()", "Apply vertex color per material\tCtrl+Shift+L" ); [/code][/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