Does anyone know if the scatter file transformation matrix recognizes scaling values? Every time I try to randomly scale objects they get distorted.
I thought it was a simple matter of multiply the scale factor to the appropriate matrix cell. In this case, it appears to be:
sx 0 0 0
0 sy 0 0
0 0 sz 0
0 0 0 1
Where sx, sy, and sz are the factors to be applied. Or am I doing this in the wrong direction?
-------------------------
If anyone is interested here's a simple javascript I wrote to create output you can cut and paste as a scatter file.
Code: Select all
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Scatter File Randomizer</title>
</head>
<body>
<label>translate uniform</label><input id="translate" type="text"><br>
<label>trans x</label><input id="transx" type="text"><br>
<label>trans y</label><input id="transy" type="text"><br>
<label>trans z</label><input id="transz" type="text"><br>
<label>rot x</label><input id="rotx" type="text"><br>
<label>rot y</label><input id="roty" type="text"><br>
<label>rot z</label><input id="rotz" type="text"><br>
<label>scale uniform</label><input id="scale" type="text"><br>
<label>scale x</label><input id="scalex" type="text"><br>
<label>scale y</label><input id="scaley" type="text"><br>
<label>scale z</label><input id="scalez" type="text"><br><br>
<label>Quantity</label><input id="qty" type="text" value=10><br>
<input type='button' onclick="createTransform()" value = "start">
<div id="test">test
</div>
</body>
<script language = "javascript">
var matrix = new Array(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); // standard transformation matrix
function createTransform(){
var qty = document.getElementById('qty').value;
var str = '';
for (var i = 0; i < qty; i++)
str = rotationRange() + str;
document.getElementById('test').innerHTML = str;
}
function randomNum(){
var rnd = Math.random()
return rnd;
}
function rotationRange(){
var defaultVal = 1;
var x = document.getElementById("rotx").value;
var y = document.getElementById("roty").value;
var z = document.getElementById("rotz").value;
var a = 180 * randomNum();
var d = document.getElementById('translate').value;
var dx = document.getElementById('transx').value;
var dy = document.getElementById('transy').value;
var dz = document.getElementById('transz').value;
var s = document.getElementById('scale').value;
var sx = document.getElementById('scalex').value;
var sy = document.getElementById('scaley').value;
var sz = document.getElementById('scalez').value;
// ------------ rotate -----------------//
if(x == '') x = defaultVal * randomNum();
else x = x * randomNum();
if(y == '') y = defaultVal * randomNum();
else y = y * randomNum();
if(z == '') z = defaultVal * randomNum();
else z = z * randomNum();
// -------------- translate ----------- //
if(d == '')
defaultVal = 200;
else
defaultVal = d;
if(dx == '') dx = defaultVal * randomNum();
else dx = dx * randomNum();
if(dy == '') dy = defaultVal * randomNum();
else dy = dy * randomNum();
if(dz == '') dz = defaultVal * randomNum();
else dz = dz * randomNum();
// ------------ scale -------------------//
if(s == '') defaultVal = 1;
else defaultVal = s;
var uniformScale = randomNum();
if(sx == '') sx = defaultVal * uniformScale;
else sx = sx * randomNum();
if(sy == '') sy = defaultVal * uniformScale;
else sy = sy * randomNum();
if(sz == '') sz = defaultVal * uniformScale;
else sz = sz * randomNum();
// borrowed this code snippet from http://evanw.github.io/lightgl.js/docs/matrix.html - me likey.
var m = matrix;
var d = Math.sqrt(x*x + y*y + z*z) ;
a *= Math.PI / 180; x /= d; y /= d; z /= d;
var c = Math.cos(a), s = Math.sin(a), t = 1 - c;
m[0] = (x * x * t + c) * sx ; //scale x
m[1] = x * y * t - z * s;
m[2] = x * z * t + y * s;
m[3] = dx;
m[4] = y * x * t + z * s;
m[5] = (y * y * t + c) * sy; // scale y
m[6] = y * z * t - x * s;
m[7] = dy;
m[8] = z * x * t - y * s;
m[9] = z * y * t + x * s;
m[10] = (z * z * t + c) * sz ; // scale z
m[11] = dz;
m[12] = 0; // we are ignoring these - not recognized by Octane
m[13] = 0;
m[14] = 0;
m[15] = 1;
var out ='';
for (var i =0; i<12; i++) {
out = out+ m[i] + " ";
}
return out + "<br>";
}
//document.getElementById('test').innerHTML=out;
</script>
</html>
For some reason when using the scatter file, you can not focus the camera on the objects.
Then if you just use the default camera and click on the geometry goup you can see them perfectly.
This may not be a octane issue, as I built these asteroids with sculptris...they could have polygon problem...notheless, only one
of the three objects accepts the materials.

