discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Using transformation matrices from other programs?

U
ufomorace
Mon, Aug 24, 2015 12:34 PM

So i have use a standard transformation matrix in openscad, which uses a
matrix processed by multimatrix.

the standard trs matrix can be rotated and placed with this:

i have to write a quaternion lookrotation function for openscad, unless
there is another option. i can export the positions and rotations to any
format from Unity3d so perhaps will use the fct's from it.

--
View this message in context: http://forum.openscad.org/Using-transformation-matrices-from-other-programs-tp13596p13598.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

So i have use a standard transformation matrix in openscad, which uses a matrix processed by multimatrix. the standard trs matrix can be rotated and placed with this: i have to write a quaternion lookrotation function for openscad, unless there is another option. i can export the positions and rotations to any format from Unity3d so perhaps will use the fct's from it. -- View this message in context: http://forum.openscad.org/Using-transformation-matrices-from-other-programs-tp13596p13598.html Sent from the OpenSCAD mailing list archive at Nabble.com.
U
ufomorace
Mon, Aug 24, 2015 4:40 PM

ok so here is a complete parser for position of unity transforms, it writes
up to 2000 or something objects to text in assets folder that can be copied
into a scad array and csg'd there. for the moment just tested the cube
centered and it works ok.

//clear matrix text prior to every rewrite, see end fct:

for (var i =0; i < depth; i++){

//obj2 = the object to get the transformation matrix from
	
	
// takes the matrix coordinates and formats them into .scad matrix array

string
var mtrs : String = "[";
var loopcount = 0;
var number : Matrix4x4 = obj2.transform.localToWorldMatrix;
mtrs = mtrs + "[" ;
for (var l =0; l < 4; l++)
{
mtrs = mtrs + "[" ;
for (var m =0; m < 4; m++)
{
loopcount += 1;
var numbertext = number[l,m];
numbertext.ToString();
mtrs = mtrs + "" + numbertext + "," ;
if (m==3){mtrs = mtrs.Substring(0, mtrs.Length - 1);};
}
if (loopcount == 16)    { mtrs = mtrs + "]],\n\n";}    else    {mtrs =
mtrs + "],\n";} ;
}
writeMatrixTxt(mtrs);

}
mtrs = mtrs.Substring(0, mtrs.Length - 3); mtrs = mtrs + "];";//delete one
char, the comma and close array

writeMatrixTxt(mtrs);

//squareoff ();
//offset();
}

function writeMatrixTxt(wrstring : String){

File.AppendAllText(Application.dataPath +"/MATRICES.txt",wrstring);

}

function clearMatrixTxt(){

File.WriteAllText(Application.dataPath +"/MATRICES.txt","");

}

--
View this message in context: http://forum.openscad.org/Using-transformation-matrices-from-other-programs-tp13596p13602.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

ok so here is a complete parser for position of unity transforms, it writes up to 2000 or something objects to text in assets folder that can be copied into a scad array and csg'd there. for the moment just tested the cube centered and it works ok. //clear matrix text prior to every rewrite, see end fct: for (var i =0; i < depth; i++){ //obj2 = the object to get the transformation matrix from // takes the matrix coordinates and formats them into .scad matrix array string var mtrs : String = "["; var loopcount = 0; var number : Matrix4x4 = obj2.transform.localToWorldMatrix; mtrs = mtrs + "[" ; for (var l =0; l < 4; l++) { mtrs = mtrs + "[" ; for (var m =0; m < 4; m++) { loopcount += 1; var numbertext = number[l,m]; numbertext.ToString(); mtrs = mtrs + "" + numbertext + "," ; if (m==3){mtrs = mtrs.Substring(0, mtrs.Length - 1);}; } if (loopcount == 16) { mtrs = mtrs + "]],\n\n";} else {mtrs = mtrs + "],\n";} ; } writeMatrixTxt(mtrs); } mtrs = mtrs.Substring(0, mtrs.Length - 3); mtrs = mtrs + "];";//delete one char, the comma and close array writeMatrixTxt(mtrs); //squareoff (); //offset(); } function writeMatrixTxt(wrstring : String){ File.AppendAllText(Application.dataPath +"/MATRICES.txt",wrstring); } function clearMatrixTxt(){ File.WriteAllText(Application.dataPath +"/MATRICES.txt",""); } -- View this message in context: http://forum.openscad.org/Using-transformation-matrices-from-other-programs-tp13596p13602.html Sent from the OpenSCAD mailing list archive at Nabble.com.