Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Can you change text on a plain instead of an overlay?

chicoporter
Registered User
Quote
2022-06-10 14:32:43

Is it possible to change text like you might do on a 2d overlay.

What I'd like to do it use one model to do a street sign of sorts.

To avoid creating a new graphics for each sign, I'd like to be able to have street names as a variable and then change the signs accordingly.

I know how to do it on a 2d overlay, but I'd like to display on a plain instead of an overlay.

Thanks in advance


okeoke
Registered User
Quote
2022-06-10 16:55:33

I don't think you can.

I guess, if you really need to do a lot of signs you can sort of use ccbLoadTexture function https://www.ambiera.com/coppercu....

So, I would do the following, but I also like to overcomplicate things:
1. Create a texture template without text
2. In the file system create a folder named "signs" or something similar in the same folder your ccb file is
3. Use graphic editor to write a text over the template, save it as png into that folder with some file name that makes sense
4. In coppercube editor create folder node named signs
5. Import your sign model as a static 3d node
6. Put it into sings node folder
7. Duplicate the sign node inside the folder using ctrl + c
8. Put it into the correct position and change its name to the same name as texture from p3.
9. On the scene root node add 'before the first drawning' behavior and put the script which applies the texture:

var signsNode = ccbGetSceneNodeFromName('signs');
var signsCount = = ccbGetSceneNodeChildCount(signsNode);

for (var i = 0; i < signsCount; I++) {
var sign = ccbGetChildSceneNode(signsNode, i);
var signName = ccbGetSceneNodeProperty(sign, 'Name');
var tex = ccbLoadTexture('signs/' + signName + '.png');
ccbSetSceneNodeMaterialProperty(sign, 0, "Texture1", tex);
}

repeat p3-8 for every sign.


just_in_case
Moderator
Quote
2022-06-10 18:24:32

Actually if you know scripting then you can achieve something that may be used as to write on a planemesh.

You can get the 3D position of the planemesh and with scripting can convert it into a 2D position and then set this 2D position as the position of a 2D overlay.
Something like this code below.


var s = ccbGetSceneNodeFromName("cubeMesh1");
var pos = ccbGetSceneNodeProperty(s,"Position");
var pos2d = ccbGet2DPosFrom3DPos(pos.x,pos.y,pos.z);
var o = ccbGetSceneNodeFromName("overlay");
ccbSetSceneNodeProperty(o,"Pos X (pixels)",pos2d.x);
ccbSetSceneNodeProperty(o,"Pos Y (pixels)",pos2d.y);
print(pos2d);


what this code will do is it will make the overlay appear on the position of a 3D cubemesh.

but you also need to scale the overlay accordingly when you move closer or further to the 3D object.

Also, you need to set your overlay to absolute pixel mode in order to test out the above code and you might need to make necessary changes to the name according to the above code.

Otherwise use the method proposed by @OkeOke, to use multiple textures for the planemeshes.


chicoporter
Registered User
Quote
2022-06-11 16:15:01

I'll give it a go


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (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