Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
How to change texture with coding ?

Alireza
Guest
Quote
2021-11-24 09:51:56

How to change the texture with coding (without loading texture from disk )?
I use this command:
ccbSetSceneNodeMaterialProperty (node, 0, "Texture1", "example.jpg");
But it gives an error: could not open file


DouweDabbe
Guest
Quote
2021-11-25 07:05:27

you need a tex library in your scene,
some simple mesh that holds extra needed textures
then you can easily swap textures between nodes etc.


Alireza
Guest
Quote
2021-11-25 09:37:55

Thankful .
I did that. I mean, my textures are exist in scene . But I still get the same error and could not open file!!


DouweDabbe
Guest
Quote
2021-11-26 01:46:02

first you get the terxture from your libray:

in a for loop or so to get them all in a array variable

for (i=0; i<texCount; i++) {
var s = ccbGetSceneNodeFromName("cubeMesh1");
var myTex[i] = ccbGetSceneNodeProperty(s, "Texture");
}

then you set the materialproperty with that variabe:

ccbSetSceneNodeProperty(s, "Texture", myTex[i]);

it depends on you mesh type that you must use:
ccb Get / Set SceneNodeProperty or
ccb Get / Set SceneNodeMaterialProperty


Alireza
Guest
Quote
2021-11-26 09:09:26

Thank you very much
It works.

I did not know before that we have to get the material first.
Thank you again


Create reply:


Posted by: (you are not logged in)


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