Ambiera ForumDiscussions, Help and Support. |
|
| [ 1 2 ] Page 2 of 2 |
|
|||||
|
Ah, ok. I've read the original post. You were asking how the number is obtained, I see. |
||||
|
@okeoke now run: var node = ccbGetSceneNodeFromName("box1"); var meshBufferCount = ccbGetSceneNodeMeshBufferCount(node); for (var i=0; i<meshBufferCount; i++) { var vertCountPerBuffer = ccbGetMeshBufferVertexCount(node, i); for (var j=0; j<vertCountPerBuffer; j++) { var color = ccbGetMeshBufferVertexColor(node, i, j); print(color + " = " + color.toString(16)); } } |
||||
|
It is red to the eyes, but will we actually get ff0000 when we use CopperCube's 'Scripting Window' (or our app's JavaScript)? |
||||
|
You're missing alpha channel. Your result should be either FF0000FF for RGBA or FFFF0000 ARGB. There is either an issue with data types, so it's translated incorrectly, or it's calculated differently. But does it matter? If you want to apply different colors, you can get random ints. If you want to set colors in blender - you can also do that and they are propagated correctly. I mean, if you want to understand how it works, you probably, need to understand which data type is used to store color in C++ and see if it translates to js engine properly. Or you can try exporting different vertex colors like black with 0 and 255 transparency, red with 0 and 255 transparency, and etc and see if you can see any system. |
||||
|
I kind of understand... I had a problem in the past with using fanciful int (like int32_t, uint_8 etc) while dealing with colors and color channels. Maybe I was not being consistent. I had to use plain int to solve those bugs. Further: Blender doesn't support changing alpha value for vertex coloring. Also, CopperCube doesn't support that. I think I tried one other software. color.toString(16) did not include alpha on my computer. @Dieter and @Guest (a guest) gave codes that included alpha. |
||||
|
@oleprint, it will give you the red color as well, if you have the functions mentioned on my website then you will get to know that, by default the API ccbGetMeshBufferVertexColor(node, meshbufferindex, vertexindex)gives you a decimal color, which you need to convert into RGB values, you can use the functions from the website. or for ease of acess I am writing them again here.
you can use the above code to get the RBG values from the decimal color, it will give you the same color. However this only works if you apply the vertex color inside the CopperCube editor, if you are importing the model for example from blender 3D, then you also need to multiply the RGB value with 4.0476, to get the actual value of the vertex color. Hope this will solve the original question asked here, I thought that you just wanted to have vertex colored objects in your game. |
||||
|
Yeah, well first of all, there seems to be an inconsistency between webGL and other targets, in how to access vertex color by script in CC. If I remember correctly, these aren't supported at all, but one can use the respective copperlicht.js syntax instead, or a fork in the code, depending on platform. I have just recently posted an EntityAlpha() function somewhere here (somebody asked for something to appear slowly). It works, but only with an older version of copperlicht.js. There are blending modes for textures in the irrEditor window. One of the last ones in the menu is something like "use vertex alpha to blend in 2nd texture". You can use this one without a second texture, effectively making the mesh alpha-transparent, based on vertex alpha. One could do a fog this way that gets dense towards the ground, for example. In terms of vertex color, CC uses 63 interally, not 255, so values higher than 63 are reseved for other purposes, it seems. However, B3D files normally contain RGB as 8 bit ints. I do remember I had quite a hard time to modd the export code, as for this particular blending mode there was some kind of strange behavior by CC, like reading them as signed 8 bit int values. As very often, when standards blur, experimentation can give answers, and it is rather a matter of setting up the experiment in no time, than to find the answer online. Because frankly I even don't remember exactly. Actually, just for fun:
There you see a lot of messy code to handle just 2 possible blending modes. If the mesh is lit dynamically, alpha is multiplied x 4. Alpha may be no more than 0x3E000000, or if dyn-lit no more than 0xFE000000. Then I mix this with a neutral 0x3F3F3F, which is basically 63,63,63, or CC-white. Could be anything, of course. |
||||
|
well i guess, We answered the thread at the same moment Dieter. hehehhe |
||||
|
Hey just_in_case, 4.0476 ? Why? :-) |
||||
|
Blender also supports vertex alpha. You need to set up the material so it's transparent. It's also easy to verify, if you export models with alpha set to 1 and 0 and compare number you receive by ccbGetMeshBufferVertexColor. |
||||
|
I guess 4.0476 * 63 ~= 255:) |
||||
|
Thanks @just_in_case. Thanks @Dieter. Since I'm new to CopperCube, I barely know things about copperlicht. Remember everyone: I'm no longer seeking for a solution. |
||||
|
@Dieter, remember when you have your Viking boat in your game disappearing I suggested you to use (63,63,63) as vertex color, to fix it. At that time I took myself why it happens and since then I knew that CC uses 4x of vertex color for some imported models, while it internally uses values upto 255. So if you apply the color using CC's internal vertex coloring mechanism, you will get 255 while for some imported models with vertex color you will get 63. As @okeoke already provided answer 63 * 4.0476 ~= 255 , I suggested multiplying the result with this value, it will give the required color value for the imported model with vertex color. @Olprint, Copperlicht is the webGL engine for CopperCube. Welcome to the community, hope you will create something good with the engine. There is a lot to explore in this engine. |
||||
|
Thanks for the explanation. There is a lot to explore in this engine True. I like it because it serves both low and high end computers.
|
||||
|
@just_in_case Yeah I already had a suspicion. Yet, I'd rather say: (64*4)-1= 255. All those cryptic floats must scare people lol. Like I use 57.29577951 a lot, and people go like "yeah right, totally intuitive" ^^ - the secret math spells of the CC vets. I still don't understand exactly why it uses 63 instead of 255. Sure when you set it to say 127,127,127, the mesh becomes way too bright. Could use this for baked shading, like Phong shading, or for a part of the triangles of a lightmap (triangles without shadow edges on them). |
||||
| [ 1 2 ] Page 2 of 2 |
|
|