/*
Create two cubes, the first one uses Matrix4.Set function and
the second uses the transpose inverse matrix of the first
*/
NewScene(null, false);
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oCube = oRoot.AddGeometry("Cube", "MeshSurface", "CubeOriginal");
var oCube2 = oRoot.AddGeometry("Cube", "MeshSurface", "CubeTransposed");
var oTrans = oCube.Kinematics.Local.Transform;
var oTrans2 = oCube2.Kinematics.Local.Transform;
// Change the cube shape
var oMat4 = XSIMath.CreateMatrix4(
1.0, 1.0, 0.0, 10.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
);
// Original cube
oTrans.SetMatrix4(oMat4);
oCube.Kinematics.Local.Transform = oTrans;
// Transpose inverse cube
oMat4.TransposeInverseInPlace();
oTrans2.SetMatrix4(oMat4);
oCube2.Kinematics.Local.Transform = oTrans2; |