Pixel-Composer/scripts/d3d_transformation/d3d_transformation.gml

54 lines
1.3 KiB
Text
Raw Normal View History

2023-08-30 16:40:45 +02:00
function __transform() constructor {
parent = noone;
position = new __vec3(0);
2023-10-08 09:22:01 +02:00
anchor = new __vec3(0);
2023-08-30 16:40:45 +02:00
rotation = new BBMOD_Quaternion();
scale = new __vec3(1);
matrix = new BBMOD_Matrix();
2023-08-30 16:40:45 +02:00
static submitMatrix = function() {
if(parent) parent.submitMatrix();
var pos = matrix_build(position.x, position.y, position.z,
0, 0, 0,
1, 1, 1);
var rot = rotation.ToMatrix();
var sca = matrix_build(0, 0, 0,
0, 0, 0,
scale.x, scale.y, scale.z);
2023-10-08 09:22:01 +02:00
var anc = matrix_build(-anchor.x, -anchor.y, -anchor.z,
0, 0, 0,
1, 1, 1);
2023-08-30 16:40:45 +02:00
matrix_stack_push(pos);
matrix_stack_push(rot);
matrix_stack_push(sca);
2023-10-08 09:22:01 +02:00
matrix_stack_push(anc);
matrix = new BBMOD_Matrix().Mul(new BBMOD_Matrix().FromArray(pos))
.Mul(new BBMOD_Matrix().FromArray(rot))
.Mul(new BBMOD_Matrix().FromArray(sca))
.Mul(new BBMOD_Matrix().FromArray(anc))
2023-08-30 16:40:45 +02:00
}
static clearMatrix = function() {
matrix_stack_pop();
matrix_stack_pop();
matrix_stack_pop();
2023-10-08 09:22:01 +02:00
matrix_stack_pop();
2023-08-30 16:40:45 +02:00
}
2023-10-24 02:09:04 +02:00
static clone = function() {
var _res = new __transform();
_res.parent = parent;
_res.position = position.clone();
_res.anchor = anchor.clone();
_res.rotation = rotation.Clone();
_res.scale = scale.clone();
return _res;
}
2023-08-30 16:40:45 +02:00
}