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.
|