Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Change a Texture BUT set the amount of time the texture tile.

bracer
Registered User
Quote
2017-07-17 23:21:17

Is it possible to set the texture of a model AND set the number of times the texture repeats ?


niko
Moderator
Quote
2017-07-18 07:52:11

The built-in animate texture behavior doesn't have an option for this, but this could be easily achieveable by creating a custom behavior. You could base it maybe on the already existing "Animate Dynamic Loaded Textures", which does something similar already.


bracer
Registered User
Quote
2017-07-19 00:07:32

What about implementing it in Special->Execute Javascript ?
What would be the line of code for that Niko ? Thanks.


niko
Moderator
Quote
2017-07-21 05:30:57

For something like that, which does something every frame, it is probably easier to add a behavior. BUT you could use the "every x seconds do something" behavior and put a JavaScript into there. Then just do something like



var textures = ["tex1.jpg", "tex2.jpg", "tex3.jpg"];
var frameLength = 1000; // in milli seconds
var maxLoopCount = 3;
var nameOfSceneNode = 'cubeMesh1';

var now = new Date();
now = now.getTime();
if (typeof textureAnimStateTime == 'undefined')
{
textureAnimStateTime = now;
}

if ((now - textureAnimStateTime) / (frameLength * textures.length) < maxLoopCount)
{
var node = ccbGetSceneNodeFromName(nameOfSceneNode);
var texidx = Math.floor(((now - textureAnimStateTime) / frameLength) % textures.length);
var tex = ccbLoadTexture(textures[texidx]);

ccbSetSceneNodeMaterialProperty(node, 0, "Texture1", tex);
}


The four first lines contain parameters you need to adjust for your setting.


Create reply:


Posted by: (you are not logged in)


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