Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Slow appearance of an object

tarasdreamer
Registered User
Quote
2023-08-21 20:30:39

Hi all. I want something to slowly appear in the game through transparency when triggered. For example, I am walking along a path and when I reach the intersection in front of me, a sign with a hint inscription slowly appears in the air. I was able to do it through visible/invisible, but this way the appearance is instantaneous and I need to gradually appear through transparency. How can I do it?


hadoken
Guest
Quote
2023-08-21 20:58:18

@tarasdreamer,

you would need a shader action with alpha transparency fade

I think there was such extension for DirectX on neophyte.cf, but he site is down for the moment, maybe its owner @just_in_case could help you out here directly ...

I remember having also created a GLSL script for this for OpenGL users already some time ago - let me take a look into my HD ...


tarasdreamer
Registered User
Quote
2023-08-21 21:05:41

@hadoken

Thanks for answer!


Dieter
Guest
Quote
2023-08-22 13:08:41

An other option might be: Set Vertex Alpha dynamically, eg. by:
ccbSetMeshBufferVertexColor(node, meshbufferindex, vertexindex, color) - Sets color of a vertex
whereas a 32 bit color has the alpha byte in the topmost 8 bits, from $01000000 to $FF000000. Then you can choose a blending mode that uses vertex alpha. That said, didn't try it and cannot guarantee that Niko has no AND $FFFFFF filter that would remove the alpha before applying it as vertex color.

Tho the docs say this works only in windows and mac OS X, but I remember I had it working in webGL, but using copperlicht.js commands directly. Well you could switch based on ccbGetPlatform().


Dieter
Guest
Quote
2023-08-22 15:11:01

Just for the records, I undug my EntityAlpha Function. When I just run it for webgl with CC (I guess still Version 6.0) then the JS error console says the getMesh method is not defined.
Then I replace copperlicht.js in the copperlichtdata folder (about 224 kb) by an older one I got from IDK where, that's about 443 kb, then it works nicely:
🔎︎


So this mesh was set to alpha 0.5 after clicking. using this function:


function EntityAlpha(node2,al,is_dyn_lit=0){
var node=node2.getMesh();
if(!node)alert("sum ting wong");
//var mes=node.GetMesh();
buf=node.GetMeshBuffers();
if(is_dyn_lit==1) {al*=4;}
al*=63;
if(al<0)al=0;
if(al>255)al=255;
al=al<<24; // bit-shifting alpha to the top byte.
var al_max=0x3e000000;
if(is_dyn_lit==1) {al_max=0xfe000000;}
for(i=0; i<buf.length;i++){
if(al>al_max){
if(is_dyn_lit==0) {buf[i].Mat.Type = CL3D.Material.EMT_SOLID;}
else {buf[i].Mat.Type = CL3D.Material.EMT_TRANSPARENT_ALPHA_CHANNEL_REF;} // this is used for dyn. lit plants and such
}
else{
buf[i].Mat.Type = CL3D.Material.EMT_TRANSPARENT_ALPHA_CHANNEL;
}
for(j=0; j<buf[i].Vertices.length;j++){
buf[i].Vertices[j].Color=(al | 0x3f3f3f);//0x3f3f3f);
}
buf[i].update(false,false);
}
}

As mentioned before, this is for webgl only. So put it into a if (ccbGetPlatform()=="webgl") condition, and else try the CC internal Vertex Color commands.
Something like:


var meshnode = ccbGetCurrentNode();
var bufferCount = ccbGetSceneNodeMeshBufferCount(meshnode);
if (bufferCount == 0)
alert('The selected node has no 3D geometry.');
else
{
for (var i=0; i<bufferCount; ++i)
{
var vertexcount = ccbGetMeshBufferVertexCount(meshnode, i);
for (var v=0; v<vertexcount; ++v)
{
var rgb = ccbGetMeshBufferVertexColor(meshnode, i, v);
//actually, IDK what rgb is, a 32 bit color, or a 3d vector, so maybe write it to some console, and then proceed accordingly
// just, if it were 32 bit:
var argb=(rgb & 0xFFFFFF) | 0x7F000000; // is 50% transparent
ccbSetMeshBufferVertexColor(meshnode, i, v, argb);
}
}
// ccbUpdateSceneNodeBoundingBox(meshnode); // maybe unnecessary
}




Dieter
Guest
Quote
2023-08-22 19:22:58

BTW, could somebody who has the latest CC update test the EntityAlpha function for the webgl target? I wonder whether it does again support those copperlicht calls, and if not, why it was removed.
I also wonder whether I can again obtain an engine handle in the html page, for a progressbar or similar:

var engine = new CL3D.CopperLicht('3darea', 1, 30, 1, "<image src='copperlichtdata/progressbar.png' id='my_progressbar' style='width:20px; height:20px;'><image src='copperlichtdata/progressbardark.png' id='my_progressbardark' style='width:80px; height:20px;'>", "no WebGL found", 0, 1);

This is another thing that doesn't work with the 6.0 version.


tarasdreamer
Registered User
Quote
2023-08-22 20:41:29

Thank you very much @Dieter!


Guest
Guest
Quote
2023-08-23 14:19:06

Since the update of neophyte site to github by JIC, you can download his fade shader from here, it works on webGL as well.
https://vazahat.github.io/ccb_sh...


Dieter
Guest
Quote
2023-08-23 21:32:13

Thanks, but the download button is not working. However, found it in this huge repository:
https://github.com/BeingNeophyte/BeingNeophyte.github.io/tree/af5c9733fb3aa4a2030fe608a47e88555d184f27/downloadables

Or go to github.com and search the zipfile


just_in_case
Moderator
Quote
2023-08-25 06:27:08

Yup, that repo also belongs to me, but is now restricted, anyways you guys can acess the same on the Vazahat/Neophyte Repo as well. The file tree to download all the downloadables will be acessible to there as well.

https://github.com/vazahat/vazah...


Dieter
Guest
Quote
2023-08-25 13:32:39

Thanks for sharing, just_in_case, that's some years of excellent work there..


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

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