Random image texture rotation script

Hello,  I am looking for a script to randomly rotate the image texture of an object. Inside the interface that kind of rotation could be done with the Layered Image Editor, but the rotation options are limited to 90, 180 et 270 degrees. 

I used the code from @Esemwy  (https://www.daz3d.com/forums/discussion/62783/surface-selection-script/p1) to access to the surfaces Tab and a function to generate integer numbers from 0 to 360 degrees. There is no error message in the console but the image texture doesn't move.

function RandomPos(min, max) {  min = Math.ceil(0);  max = Math.floor(360);  return Math.floor(Math.random() * (max - min +1)) + min;  var nNodes = Scene.findNodeByLabel("Duvet");for (var i=0; i < nNodes; i++) {	var oNode = Scene.getNode(i)	var oObj = oNode.getObject();	if (! oObj) continue;	var nShapes = oObj.getNumShapes();	for (var j=0; j < nShapes; j++) {		var oShape = oObj.getShape(j);		var nMat = oShape.getNumMaterials();		for (var k=0; k < nMat; k++) {			var oMat = oShape.getMaterial(k);				oMat.select(true);				oMat.getXRotControl().setValue(RandomPos());			}		}	}}

The last line works for moving an object but not here ; it's probably due to the absence of transforms controllers in the surfaces editor...

Does anyone have a image texture rotation script that works ? 

Comments

  • EsemwyEsemwy Posts: 578

    Images can only be rotated in 90° increments using DAZ Script. You have to write a plugin for full access to the image transform API. ????

  • Event with 90 degrees increments, my code doesn't work :/ 

    I thought it would be easier to randomize the rotation of the image texture to generate different images- as manipulating images is very easy  in Javascript (I am building a bed simulation, and I would have liked to add a wrinkled texture to the sheets with a random orientation to customize each frame).

    Maybe I should find another way to add more variations to the texture...

  • Ok I will use material presets instead, and load them randomly inside the script.

Sign In or Register to comment.