Pixel-Composer/scripts/__node_3d/__node_3d.gml

77 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-08-17 16:56:54 +02:00
function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "3D";
2023-08-14 19:22:04 +02:00
is_3D = true;
w = 64;
h = 64;
min_h = h;
mesh_prev_surface = surface_create(64, 64);
2023-08-14 19:22:04 +02:00
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {}
2023-08-17 16:56:54 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) {}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {}
2023-08-19 12:42:50 +02:00
static getPreviewObject = function() { #region
2023-08-17 16:56:54 +02:00
if(ds_list_empty(outputs)) return [];
switch(outputs[| preview_channel].type) {
case VALUE_TYPE.d3Mesh :
case VALUE_TYPE.d3Light :
case VALUE_TYPE.d3Camera :
case VALUE_TYPE.d3Scene : break;
default : return [];
}
var _obj = outputs[| 0].getValue();
if(is_array(_obj))
_obj = array_safe_get(_obj, preview_index, noone);
return [ _obj ];
2023-08-19 12:42:50 +02:00
} #endregion
2023-08-14 19:22:04 +02:00
2023-08-17 16:56:54 +02:00
static getPreviewObjectOutline = function() { return getPreviewObject() }
static refreshPreview = function() { #region
var _prev_obj = getPreviewObject();
mesh_prev_surface = surface_verify(mesh_prev_surface, 64, 64);
surface_set_target(mesh_prev_surface);
DRAW_CLEAR
gpu_set_zwriteenable(true);
gpu_set_ztestenable(true);
gpu_set_cullmode(cull_noculling);
D3D_GLOBAL_PREVIEW.applyCamera();
D3D_GLOBAL_PREVIEW.apply();
for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) {
var _prev = _prev_obj[i];
if(_prev == noone) continue;
var _b = _prev.getBBOX();
var _c = _prev.getCenter();
if(_b == noone || _c == noone) continue;
D3D_GLOBAL_PREVIEW.custom_transform.set(_c);
var _sca = 1 / _b.getMaximumScale();
D3D_GLOBAL_PREVIEW.custom_scale.set(_sca);
_prev.submitUI(D3D_GLOBAL_PREVIEW);
}
surface_reset_target();
D3D_GLOBAL_PREVIEW.resetCamera();
} #endregion
static postUpdate = function() { refreshPreview(); }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { #region
if(!is_surface(mesh_prev_surface)) return;
var bbox = drawGetBbox(xx, yy, _s);
draw_surface_bbox(mesh_prev_surface, bbox);
} #endregion
2023-08-14 19:22:04 +02:00
}