≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Wow I got plain Vertex Alpha working
Posted by:
(you are not logged in)
Enter the missing letter in: "Inte?national"
(you are not logged in)
Text:
[quote][b]csp-games[/b] wrote: Thanks! It seems now: the vertex color, that contains alpha, is a 32 bit int, argb. But alpha is not 0 to 255, but 0 to 63 only (and opaque above, yet still unsorted). Furthermore, to make this work, the RGB component must be 0x7f7f7f, which is 50% grey. Here's an example on how to alter the vertex alpha dynamically at runtime. Note the mesh of this node is then z-unsorted. It emulates the Blitz3D command EntityAlpha() that sets the transparency of a mesh, regardless of textures etc. The example smoothly fades in and out the house mesh node "glob_mesh". [code] // note: Alpha goes from 0 to 1.0, but internally it uses 0 to 63 (not 0 to 255), and RGB must be set to 0x3f3f3f // also, the materials must use a texture without alpha channel (24 bit), using yourmeshbuf.Mat.Type = CL3D.Material.EMT_TRANSPARENT_ALPHA_CHANNEL; // note: these meshes have then no Z-sorting, so usage may be limited to certain things like distant LOD objects. function EntityAlpha(name,al){ // somehow Nikos prototype function to create the mesh made me troubles in assigning a name to it, so I just stored the // node handle as a global named glob_mesh. I guess you can fix this. // var node= ccbGetSceneNodeFromName(name); node=glob_mesh; if(!node)alert("sum ting wong"); buf=node.GetMeshBuffers(); al*=63; if(al<0)al=0; if(al>255)al=255; al=al<<24; // bit-shifting alpha to the top byte. for(i=0; i<buf.length;i++){ for(j=0; j<buf[i].Vertices.length;j++){ buf[i].Vertices[j].Color=(al | 0x3f3f3f); } buf[i].update(false,false); } } function onFrameDrawing() { EntityAlpha("House",Math.abs(Math.sin(al_glow))); al_glow+=.01; if(al_glow>6.282){al_glow=0;} } ccbRegisterOnFrameEvent(onFrameDrawing); [/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