2022-12-16 09:18:09 +01:00
|
|
|
function Node_Camera(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
|
|
|
|
name = "Camera";
|
|
|
|
preview_alpha = 0.5;
|
|
|
|
|
|
|
|
inputs[| 0] = nodeValue(0, "Scene", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
|
|
|
inputs[| 1] = nodeValue(1, "Focus area", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 16, 16, 4, 4, AREA_SHAPE.rectangle ])
|
2022-12-27 04:00:50 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.area)
|
2022-12-27 13:30:02 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(index); });
|
2022-12-16 09:18:09 +01:00
|
|
|
|
|
|
|
outputs[| 0] = nodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, PIXEL_SURFACE);
|
|
|
|
|
|
|
|
static getPreviewValue = function() { return inputs[| 0]; }
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2022-12-27 04:00:50 +01:00
|
|
|
if(array_length(current_data) == 0) return;
|
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
var _out = outputs[| 0].getValue();
|
|
|
|
var _area = current_data[1];
|
|
|
|
var _px = _x + (_area[0] - _area[2]) * _s;
|
|
|
|
var _py = _y + (_area[1] - _area[3]) * _s;
|
|
|
|
|
|
|
|
draw_surface_ext_safe(_out, _px, _py, _s, _s);
|
2022-12-19 13:35:30 +01:00
|
|
|
inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static process_data = function(_outSurf, _data, _output_index) {
|
|
|
|
var _area = _data[1];
|
|
|
|
|
|
|
|
var _dw = surface_valid_size(_area[2]) * 2;
|
|
|
|
var _dh = surface_valid_size(_area[3]) * 2;
|
2022-12-27 04:00:50 +01:00
|
|
|
_outSurf = surface_verify(_outSurf, _dw, _dh);
|
2022-12-16 09:18:09 +01:00
|
|
|
|
|
|
|
var _px = _area[0] - _dw / 2;
|
|
|
|
var _py = _area[1] - _dh / 2;
|
|
|
|
|
|
|
|
surface_set_target(_outSurf);
|
|
|
|
draw_clear_alpha(0, 0);
|
2022-12-27 04:00:50 +01:00
|
|
|
BLEND_OVER
|
2022-12-16 09:18:09 +01:00
|
|
|
draw_surface_safe(_data[0], -_px, -_py);
|
|
|
|
BLEND_NORMAL
|
|
|
|
surface_reset_target();
|
|
|
|
|
|
|
|
return _outSurf;
|
|
|
|
}
|
|
|
|
}
|