2023-01-01 02:06:02 +01:00
|
|
|
function Node_3D_Repeat(_x, _y, _group = -1) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "3D Repeat";
|
|
|
|
|
|
|
|
inputs[| 0] = nodeValue(0, "Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2)
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 1] = nodeValue(1, "Object position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 2] = nodeValue(2, "Object rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 3] = nodeValue(3, "Object scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1, 1 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 4] = nodeValue(4, "Render position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ def_surf_size / 2, def_surf_size / 2 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
|
|
|
.setUnitRef( function() { return inputs[| 2].getValue(); });
|
|
|
|
|
|
|
|
inputs[| 5] = nodeValue(5, "Render scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 6] = nodeValue(6, "Light direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
|
|
|
.setDisplay(VALUE_DISPLAY.rotation);
|
|
|
|
|
|
|
|
inputs[| 7] = nodeValue(7, "Light height", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
|
|
|
|
.setDisplay(VALUE_DISPLAY.slider, [-1, 1, 0.01]);
|
|
|
|
|
|
|
|
inputs[| 8] = nodeValue(8, "Light intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
|
|
|
.setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01]);
|
|
|
|
|
|
|
|
inputs[| 9] = nodeValue(9, "Light color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
|
|
|
|
|
|
|
inputs[| 10] = nodeValue(10, "Ambient color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_grey);
|
|
|
|
|
|
|
|
inputs[| 11] = nodeValue(11, "3D object", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3object, noone)
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
|
|
|
inputs[| 12] = nodeValue(12, "Repeat", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1);
|
|
|
|
|
|
|
|
inputs[| 13] = nodeValue(13, "Repeat position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 0, 0 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 14] = nodeValue(14, "Repeat rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 15] = nodeValue(15, "Repeat scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1, 1 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 16] = nodeValue(16, "Repeat pattern", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
|
|
|
.setDisplay(VALUE_DISPLAY.enum_button, [ "Linear", "Radial" ]);
|
|
|
|
|
|
|
|
inputs[| 17] = nodeValue(17, "Axis", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
|
|
|
.setDisplay(VALUE_DISPLAY.enum_button, [ "x", "y", "z" ]);
|
|
|
|
|
|
|
|
inputs[| 18] = nodeValue(18, "Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
|
|
|
|
|
|
|
|
inputs[| 19] = nodeValue(19, "Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 360 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.rotation_range);
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
inputs[| 20] = nodeValue(20, "Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
|
|
|
.setDisplay(VALUE_DISPLAY.enum_button, [ "Orthographic", "Perspective" ]);
|
|
|
|
|
|
|
|
inputs[| 21] = nodeValue(21, "Field of view", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 60)
|
|
|
|
.setDisplay(VALUE_DISPLAY.slider, [ 0, 90, 1 ]);
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
input_display_list = [ 0, 11,
|
|
|
|
["Object transform", true], 1, 2, 3,
|
2023-01-09 03:14:20 +01:00
|
|
|
["Camera", true], 20, 21, 4, 5,
|
2023-01-01 02:06:02 +01:00
|
|
|
["Light", true], 6, 7, 8, 9, 10,
|
|
|
|
["Repeat", false], 12, 16, 13, 14, 15, 17, 18, 19
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
outputs[| 0] = nodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, PIXEL_SURFACE);
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
outputs[| 1] = nodeValue(1, "3D objects", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3object, function() { return submit_vertex(); });
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
outputs[| 2] = nodeValue(2, "Normal pass", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, PIXEL_SURFACE);
|
|
|
|
|
|
|
|
output_display_list = [
|
|
|
|
0, 2, 1
|
|
|
|
]
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
_3d_node_init(1, /*Transform*/ 4, 2, 5);
|
|
|
|
|
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
|
|
_3d_gizmo(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
|
|
|
}
|
|
|
|
|
|
|
|
static submit_vertex = function() {
|
|
|
|
var _lpos = inputs[| 1].getValue();
|
|
|
|
var _lrot = inputs[| 2].getValue();
|
|
|
|
var _lsca = inputs[| 3].getValue();
|
|
|
|
|
|
|
|
var sv = inputs[| 11].getValue();
|
|
|
|
if(sv == noone) return;
|
|
|
|
|
|
|
|
var _samo = inputs[| 12].getValue();
|
|
|
|
var _patt = inputs[| 16].getValue();
|
|
|
|
|
|
|
|
var _srot = inputs[| 14].getValue();
|
|
|
|
var _ssca = inputs[| 15].getValue();
|
|
|
|
|
|
|
|
var _spos = inputs[| 13].getValue();
|
|
|
|
|
|
|
|
var _raxs = inputs[| 17].getValue();
|
|
|
|
var _rrad = inputs[| 18].getValue();
|
|
|
|
var _rrot = inputs[| 19].getValue();
|
|
|
|
|
|
|
|
_3d_local_transform(_lpos, _lrot, _lsca);
|
|
|
|
for( var i = 0; i < _samo; i++ ) {
|
|
|
|
if(_patt == 0) {
|
|
|
|
matrix_stack_push(matrix_build( _spos[0] * i, _spos[1] * i, _spos[2] * i,
|
|
|
|
_srot[0] * i, _srot[1] * i, _srot[2] * i,
|
|
|
|
power(_ssca[0], i), power(_ssca[1], i), power(_ssca[2], i)));
|
|
|
|
} else if(_patt == 1) {
|
|
|
|
var angle = _rrot[0] + i * (_rrot[1] - _rrot[0]) / _samo;
|
|
|
|
var ldx = lengthdir_x(_rrad, angle);
|
|
|
|
var ldy = lengthdir_y(_rrad, angle);
|
|
|
|
|
|
|
|
switch(_raxs) {
|
|
|
|
case 0 :
|
|
|
|
matrix_stack_push(matrix_build( 0, ldx, ldy,
|
|
|
|
_srot[0] * i, _srot[1] * i, _srot[2] * i,
|
|
|
|
power(_ssca[0], i), power(_ssca[1], i), power(_ssca[2], i)));
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
matrix_stack_push(matrix_build( ldy, 0, ldx,
|
|
|
|
_srot[0] * i, _srot[1] * i, _srot[2] * i,
|
|
|
|
power(_ssca[0], i), power(_ssca[1], i), power(_ssca[2], i)));
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
matrix_stack_push(matrix_build( ldx, ldy, 0,
|
|
|
|
_srot[0] * i, _srot[1] * i, _srot[2] * i,
|
|
|
|
power(_ssca[0], i), power(_ssca[1], i), power(_ssca[2], i)));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
matrix_set(matrix_world, matrix_stack_top());
|
|
|
|
|
|
|
|
if(is_array(sv)) {
|
|
|
|
var index = i % array_length(sv);
|
|
|
|
var _sv = sv[index];
|
|
|
|
_sv(index);
|
|
|
|
} else
|
|
|
|
sv();
|
|
|
|
|
|
|
|
matrix_stack_pop();
|
|
|
|
}
|
|
|
|
_3d_clear_local_transform();
|
|
|
|
}
|
|
|
|
|
|
|
|
static update = function() {
|
|
|
|
var _dim = inputs[| 0].getValue();
|
|
|
|
var _lpos = inputs[| 1].getValue();
|
|
|
|
var _lrot = inputs[| 2].getValue();
|
|
|
|
var _lsca = inputs[| 3].getValue();
|
|
|
|
|
|
|
|
var _pos = inputs[| 4].getValue();
|
|
|
|
var _sca = inputs[| 5].getValue();
|
|
|
|
|
|
|
|
var _ldir = inputs[| 6].getValue();
|
|
|
|
var _lhgt = inputs[| 7].getValue();
|
|
|
|
var _lint = inputs[| 8].getValue();
|
|
|
|
var _lclr = inputs[| 9].getValue();
|
|
|
|
var _aclr = inputs[| 10].getValue();
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
var _proj = inputs[| 20].getValue();
|
|
|
|
var _fov = inputs[| 21].getValue();
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
var _patt = inputs[| 16].getValue();
|
|
|
|
inputs[| 13].setVisible(_patt == 0);
|
|
|
|
|
|
|
|
inputs[| 17].setVisible(_patt == 1);
|
|
|
|
inputs[| 18].setVisible(_patt == 1);
|
|
|
|
inputs[| 19].setVisible(_patt == 1);
|
2023-01-09 03:14:20 +01:00
|
|
|
inputs[| 21].setVisible(_proj);
|
|
|
|
|
|
|
|
for( var i = 0; i < array_length(output_display_list) - 1; i++ ) {
|
|
|
|
var ind = output_display_list[i];
|
|
|
|
var _outSurf = outputs[| ind].getValue();
|
|
|
|
outputs[| ind].setValue(surface_verify(_outSurf, _dim[0], _dim[1]));
|
|
|
|
|
|
|
|
var pass = "diff";
|
|
|
|
switch(ind) {
|
|
|
|
case 0 : pass = "diff" break;
|
|
|
|
case 2 : pass = "norm" break;
|
|
|
|
}
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
_3d_pre_setup(_outSurf, _dim, _pos, _sca, _ldir, _lhgt, _lint, _lclr, _aclr, _lpos, _lrot, _lsca, _proj, _fov, pass, false);
|
|
|
|
submit_vertex();
|
|
|
|
_3d_post_setup();
|
|
|
|
}
|
2023-01-01 02:06:02 +01:00
|
|
|
}
|
|
|
|
}
|