Pixel-Composer/scripts/node_3d_repeat/node_3d_repeat.gml

102 lines
3.5 KiB
Plaintext
Raw Normal View History

2023-08-30 16:40:45 +02:00
function Node_3D_Repeat(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor {
2023-01-01 02:06:02 +01:00
name = "3D Repeat";
2023-08-30 16:40:45 +02:00
inputs[| 0] = nodeValue("Objects", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Mesh, noone )
.setArrayDepth(1)
.setVisible(true, true);
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
inputs[| 1] = nodeValue("Object Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_button, [ "Duplicate", "Array" ] )
.rejectArray();
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
inputs[| 2] = nodeValue("Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 );
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
inputs[| 3] = nodeValue("Starting Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ] )
2023-01-01 02:06:02 +01:00
.setDisplay(VALUE_DISPLAY.vector);
2023-08-30 16:40:45 +02:00
inputs[| 4] = nodeValue("Starting Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0, 1 ] )
.setDisplay(VALUE_DISPLAY.d3quarternion);
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
inputs[| 5] = nodeValue("Starting Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1, 1 ] )
2023-01-01 02:06:02 +01:00
.setDisplay(VALUE_DISPLAY.vector);
2023-08-30 16:40:45 +02:00
inputs[| 6] = nodeValue("Shift Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ] )
2023-01-01 02:06:02 +01:00
.setDisplay(VALUE_DISPLAY.vector);
2023-08-30 16:40:45 +02:00
inputs[| 7] = nodeValue("Shift Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0, 1 ] )
.setDisplay(VALUE_DISPLAY.d3quarternion);
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
inputs[| 8] = nodeValue("Shift Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ] )
2023-01-01 02:06:02 +01:00
.setDisplay(VALUE_DISPLAY.vector);
2023-08-30 16:40:45 +02:00
outputs[| 0] = nodeValue("Scene", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3Scene, noone);
2023-02-23 07:02:19 +01:00
2023-08-30 16:40:45 +02:00
input_display_list = [
["Objects", false], 0, 3, 4, 5,
["Repeat", false], 1, 2, 6, 7, 8,
2023-01-09 03:14:20 +01:00
]
2023-08-30 16:40:45 +02:00
static step = function() { #region
var _mode = array_safe_get(current_data, 1, 0);
//var _tran = array_safe_get(current_data, 9, 0);
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
inputs[| 0].setArrayDepth(_mode == 1);
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
inputs[| 2].setVisible(_mode == 0);
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
//inputs[| 6].setVisible(_tran == 0);
//inputs[| 7].setVisible(_tran == 0);
//inputs[| 8].setVisible(_tran == 0);
} #endregion
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _object = _data[0];
var _mode = _data[1];
var _Spos = _data[3];
var _Srot = _data[4];
var _Ssca = _data[5];
var _Rpos = _data[6];
var _Rrot = _data[7];
var _Rsca = _data[8];
2023-02-14 05:32:32 +01:00
2023-08-30 16:40:45 +02:00
if(_mode == 1 && !is_array(_object)) return noone;
var _amo = _mode == 1? array_length(_object) : _data[2];
2023-02-14 05:32:32 +01:00
2023-08-30 16:40:45 +02:00
var _scene = new __3dGroup();
2023-01-01 02:06:02 +01:00
2023-08-30 16:40:45 +02:00
for( var i = 0; i < _amo; i++ ) {
var _obj = _mode == 1? _object[i] : _object;
if(_obj == noone) continue;
2023-01-09 03:14:20 +01:00
2023-08-30 16:40:45 +02:00
var _subScene = new __3dGroup();
2023-02-23 07:02:19 +01:00
2023-08-30 16:40:45 +02:00
var _sPos = [ _Spos[0] + _Rpos[0] * i,
_Spos[1] + _Rpos[1] * i,
_Spos[2] + _Rpos[2] * i ];
var _sSca = [ _Ssca[0] + _Rsca[0] * i,
_Ssca[1] + _Rsca[1] * i,
_Ssca[2] + _Rsca[2] * i ];
2023-05-03 21:42:17 +02:00
2023-08-30 16:40:45 +02:00
var _sRot = new BBMOD_Quaternion(_Srot[0], _Srot[1], _Srot[2], _Srot[3]);
var _rRot = new BBMOD_Quaternion(_Rrot[0], _Rrot[1], _Rrot[2], _Rrot[3]);
var _sRotE = _sRot.ToEuler();
var _rRotE = _rRot.ToEuler();
var _fRotE = [ _sRotE.x + _rRotE.x * i,
_sRotE.y + _rRotE.y * i,
_sRotE.z + _rRotE.z * i ];
var _fRot = new BBMOD_Quaternion().FromEuler(_fRotE[0], _fRotE[1], _fRotE[2]);
_subScene.transform.position.set(_sPos);
_subScene.transform.rotation.set(_fRot.X, _fRot.Y, _fRot.Z, _fRot.W);
_subScene.transform.scale.set(_sSca);
array_push(_subScene.objects, _obj);
array_push(_scene.objects, _subScene);
2023-01-09 03:14:20 +01:00
}
2023-08-30 16:40:45 +02:00
return _scene;
} #endregion
2023-01-01 02:06:02 +01:00
}