2023-08-17 16:56:54 +02:00
|
|
|
function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
|
|
|
name = "3D";
|
2024-06-15 08:02:10 +02:00
|
|
|
is_3D = NODE_3D.polygon;
|
2024-07-12 03:18:34 +02:00
|
|
|
dimension_index = -1;
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
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-28 12:56:00 +02:00
|
|
|
if(ds_list_empty(outputs)) return noone;
|
2023-10-08 09:22:01 +02:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
switch(outputs[| preview_channel].type) {
|
|
|
|
case VALUE_TYPE.d3Mesh :
|
|
|
|
case VALUE_TYPE.d3Light :
|
|
|
|
case VALUE_TYPE.d3Camera :
|
|
|
|
case VALUE_TYPE.d3Scene : break;
|
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
default : return noone;
|
2023-08-17 16:56:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var _obj = outputs[| 0].getValue();
|
2024-03-31 05:36:11 +02:00
|
|
|
if(is_array(_obj)) _obj = array_safe_get_fast(_obj, preview_index, noone);
|
2023-08-17 16:56:54 +02:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
return _obj;
|
2023-08-19 12:42:50 +02:00
|
|
|
} #endregion
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
static getPreviewObjects = function() { return [ getPreviewObject() ]; }
|
|
|
|
|
|
|
|
static getPreviewObjectOutline = function() { return getPreviewObjects() }
|
2023-08-22 11:51:45 +02:00
|
|
|
|
|
|
|
static refreshPreview = function() { #region
|
2023-08-28 12:56:00 +02:00
|
|
|
var _prev_obj = getPreviewObjects();
|
2023-08-22 11:51:45 +02:00
|
|
|
|
2024-07-02 09:15:42 +02:00
|
|
|
surface_depth_disable(false);
|
2024-05-01 14:28:15 +02:00
|
|
|
mesh_prev_surface = surface_verify(mesh_prev_surface, PREFERENCES.node_3d_preview_size, PREFERENCES.node_3d_preview_size);
|
2023-08-22 11:51:45 +02:00
|
|
|
surface_set_target(mesh_prev_surface);
|
|
|
|
DRAW_CLEAR
|
|
|
|
|
|
|
|
gpu_set_zwriteenable(true);
|
|
|
|
gpu_set_ztestenable(true);
|
|
|
|
gpu_set_cullmode(cull_noculling);
|
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
D3D_GLOBAL_PREVIEW.camera.applyCamera();
|
2023-08-22 11:51:45 +02:00
|
|
|
D3D_GLOBAL_PREVIEW.apply();
|
|
|
|
|
|
|
|
for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) {
|
|
|
|
var _prev = _prev_obj[i];
|
2023-10-18 14:58:55 +02:00
|
|
|
if(!is_struct(_prev) || !struct_has(_prev, "getBBOX")) continue;
|
2023-08-28 12:56:00 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
var _b = _prev.getBBOX();
|
|
|
|
var _c = _prev.getCenter();
|
|
|
|
if(_b == noone || _c == noone) continue;
|
|
|
|
|
2023-08-30 16:40:45 +02:00
|
|
|
D3D_GLOBAL_PREVIEW.custom_transform.position.set(_c._multiply(-1));
|
2023-08-22 11:51:45 +02:00
|
|
|
|
2024-05-01 14:28:15 +02:00
|
|
|
var _sca = 2 / _b.getScale();
|
|
|
|
//print($"Submitting object {_prev}\n{_b}, {_c}, {_sca}");
|
2023-08-22 11:51:45 +02:00
|
|
|
|
2024-05-01 14:28:15 +02:00
|
|
|
D3D_GLOBAL_PREVIEW.custom_transform.scale.set(_sca);
|
2023-08-30 16:40:45 +02:00
|
|
|
D3D_GLOBAL_PREVIEW.submitUI(_prev);
|
2023-08-22 11:51:45 +02:00
|
|
|
}
|
|
|
|
surface_reset_target();
|
2024-07-02 09:15:42 +02:00
|
|
|
surface_depth_disable(true);
|
2023-08-22 11:51:45 +02:00
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
D3D_GLOBAL_PREVIEW.camera.resetCamera();
|
2023-08-22 11:51:45 +02:00
|
|
|
} #endregion
|
|
|
|
|
2023-11-19 14:28:50 +01:00
|
|
|
static postProcess = function() { refreshPreview(); }
|
2023-08-22 11:51:45 +02:00
|
|
|
|
2024-07-11 05:28:15 +02:00
|
|
|
static getGraphPreviewSurface = function() { return mesh_prev_surface; }
|
|
|
|
|
2024-05-01 14:28:15 +02:00
|
|
|
static onDrawNodeOver = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { }
|
2023-08-14 19:22:04 +02:00
|
|
|
}
|