mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
- [3D Obj] Fix loaded solid missing alpha value.
This commit is contained in:
parent
1db8b7a488
commit
ec1bbdcd53
6 changed files with 58 additions and 37 deletions
|
@ -35,7 +35,8 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
|
|||
inputs[| in_mesh + 2] = nodeValue("Import Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
||||
.rejectArray();
|
||||
|
||||
inputs[| in_mesh + 3] = nodeValue("Invert Y", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true)
|
||||
inputs[| in_mesh + 3] = nodeValue("Swap YZ", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "YZ", "Z-Y", "-ZY" ])
|
||||
.rejectArray();
|
||||
|
||||
input_display_list = [
|
||||
|
@ -99,7 +100,7 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
|
|||
} else {
|
||||
var sol = nodeBuild("Node_Solid", x - (w + 128), matY + m_index * (128 + 32));
|
||||
sol.name = mat.name + " texture";
|
||||
sol.inputs[| 1].setValue(mat.diff);
|
||||
sol.inputs[| 1].setValue(cola(mat.diff));
|
||||
|
||||
inputs[| index].setFrom(sol.outputs[| 0]);
|
||||
}
|
||||
|
@ -131,13 +132,13 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
|
|||
use_display_list = true;
|
||||
if(obj_raw == noone) return;
|
||||
|
||||
// var txt = $"========== OBJ import ==========\n";
|
||||
// txt += $"Vertex counts: {obj_raw.vertex_count}\n";
|
||||
// txt += $"Object counts: {obj_raw.object_counts}\n";
|
||||
// txt += $"Material counts: {array_length(obj_raw.materials)}\n";
|
||||
// txt += $"Model BBOX: {obj_raw.model_size}\n";
|
||||
// txt += $"Load completed in {(get_timer() - obj_read_time) / 1000} ms\n";
|
||||
// print(txt);
|
||||
var txt = $"========== OBJ import ==========\n";
|
||||
txt += $"Vertex counts: {obj_raw.vertex_count}\n";
|
||||
txt += $"Object counts: {obj_raw.object_counts}\n";
|
||||
txt += $"Material counts: {array_length(obj_raw.materials)}\n";
|
||||
txt += $"Model BBOX: {obj_raw.model_size}\n";
|
||||
txt += $"Load completed in {(get_timer() - obj_read_time) / 1000} ms\n";
|
||||
logNode(txt);
|
||||
|
||||
var span = max(abs(obj_raw.model_size.x), abs(obj_raw.model_size.y), abs(obj_raw.model_size.z));
|
||||
if(span > 10) {
|
||||
|
|
|
@ -83,6 +83,8 @@ function Node_3D_Mesh_Stack_Slice(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
var _surfBuff = buffer_from_surface(_matSurf, false);
|
||||
var _surfW = surface_get_width(_matSurf);
|
||||
var _surfH = surface_get_height(_matSurf);
|
||||
|
||||
// print($"{_matSurf} : {_surfBuff} [{buffer_get_size(_surfBuff)}]");
|
||||
}
|
||||
|
||||
switch(_mesh.VF) {
|
||||
|
@ -128,7 +130,12 @@ function Node_3D_Mesh_Stack_Slice(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
faces_maxz = max(faces_maxz, _pz);
|
||||
|
||||
if(_pid == 9) {
|
||||
_pnt[9] = _useSurf? buffer_read_at(_surfBuff, (round(_vv * _surfH) * _surfW + round(_uu * _surfW)) * 4, buffer_u32) : c_white;
|
||||
_uu = frac(_uu) < 0? 1 + frac(_uu) : frac(_uu);
|
||||
_vv = frac(_vv) < 0? 1 + frac(_vv) : frac(_vv);
|
||||
var _uvPx = round(_vv * (_surfH - 1)) * _surfW + round(_uu * (_surfW - 1));
|
||||
// print($"{_uvPx} : {_uu}, {_vv}");
|
||||
|
||||
_pnt[9] = _useSurf? buffer_read_at(_surfBuff, _uvPx * 4, buffer_u32) : c_white;
|
||||
_pnt[10] = max(_pnt[0], _pnt[3], _pnt[6]);
|
||||
|
||||
_pnt[11] = (_pnt[0] + _pnt[3] + _pnt[6]) / 3;
|
||||
|
@ -149,6 +156,12 @@ function Node_3D_Mesh_Stack_Slice(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
if(_useSurf) buffer_delete(_surfBuff);
|
||||
}
|
||||
|
||||
var _ranx = faces_maxx - faces_minx;
|
||||
var _rany = faces_maxy - faces_miny;
|
||||
var _ranz = faces_maxz - faces_minz;
|
||||
|
||||
mesh_data.text = $"Faces: {_ind}\nSize: [{_ranx}, {_rany}, {_ranz}]";
|
||||
|
||||
array_sort(_fac, function(a1, a2) { return sign(a2[10] - a1[10]); });
|
||||
|
||||
faces_amo = _ind;
|
||||
|
@ -197,8 +210,6 @@ function Node_3D_Mesh_Stack_Slice(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
var _rany = faces_maxy - faces_miny;
|
||||
var _ranz = faces_maxz - faces_minz;
|
||||
|
||||
mesh_data.text = $"Faces: {_faces}\nSize: [{_ranx}, {_rany}, {_ranz}]";
|
||||
|
||||
var _stpx = _ranx / dimensions[0];
|
||||
var _stpy = _rany / dimensions[1];
|
||||
var _stpz = _ranz / slicesAmo;
|
||||
|
@ -311,7 +322,7 @@ function Node_3D_Mesh_Stack_Slice(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
}
|
||||
|
||||
static update = function() {
|
||||
|
||||
meshInit();
|
||||
}
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
|
|
|
@ -62,9 +62,9 @@ function Node_Sprite_Stack(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
var px = _x + pos[0] * _s;
|
||||
var py = _y + pos[1] * _s;
|
||||
|
||||
var a = inputs[| 3].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny, THEME.anchor); active &= a;
|
||||
var a = inputs[| 4].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); active &= a;
|
||||
var a = inputs[| 5].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny); active &= a;
|
||||
var a = inputs[| 3].drawOverlay(hover, active, px, py, _s * 4, _mx, _my, _snx, _sny, THEME.anchor); active &= a;
|
||||
var a = inputs[| 4].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); active &= a;
|
||||
var a = inputs[| 5].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny); active &= a;
|
||||
} #endregion
|
||||
|
||||
static drawPreviewToolOverlay = function(hover, active, _mx, _my, _panel) { #region
|
||||
|
@ -94,7 +94,6 @@ function Node_Sprite_Stack(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
draw_surface_ext_safe(_s, _sx, _sy, _ss, _ss);
|
||||
|
||||
if(hover && point_in_rectangle(_mx, _my, _sx - ui(4), _sy, _sx + _sw * _ss + ui(4), _sy + _sh * _ss)) {
|
||||
hov = true;
|
||||
preview_custom_index = i;
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
|
@ -103,12 +102,14 @@ function Node_Sprite_Stack(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
|
||||
draw_rectangle(_sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss, true);
|
||||
|
||||
sx += prev_size + ui(8);
|
||||
preview_custom_x_max += prev_size + ui(8);
|
||||
sx += _sw * _ss + ui(8);
|
||||
preview_custom_x_max += _sw * _ss + ui(8);
|
||||
}
|
||||
|
||||
preview_custom_x_max = max(preview_custom_x_max - _panel.w + ui(64), 0);
|
||||
|
||||
var hov = hover && point_in_rectangle(_mx, _my, 0, sy, _panel.x1, _panel.x1);
|
||||
|
||||
if(hov) {
|
||||
if(mouse_wheel_down()) preview_custom_x_to -= ui(128);
|
||||
if(mouse_wheel_up()) preview_custom_x_to += ui(128);
|
||||
|
|
|
@ -40,18 +40,30 @@ function readObj_file() {
|
|||
|
||||
switch(sep[0]) {
|
||||
case "v" :
|
||||
if(obj_reading_yneg) {
|
||||
array_push(v, [
|
||||
real(sep[1]) * obj_reading_scale,
|
||||
real(sep[3]) * obj_reading_scale,
|
||||
-real(sep[2]) * obj_reading_scale,
|
||||
]);
|
||||
} else {
|
||||
array_push(v, [
|
||||
real(sep[1]) * obj_reading_scale,
|
||||
real(sep[2]) * obj_reading_scale,
|
||||
real(sep[3]) * obj_reading_scale,
|
||||
]);
|
||||
switch(obj_reading_yneg) {
|
||||
case 0 :
|
||||
array_push(v, [
|
||||
real(sep[1]) * obj_reading_scale,
|
||||
real(sep[2]) * obj_reading_scale,
|
||||
real(sep[3]) * obj_reading_scale,
|
||||
]);
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
array_push(v, [
|
||||
real(sep[1]) * obj_reading_scale,
|
||||
real(sep[3]) * obj_reading_scale,
|
||||
-real(sep[2]) * obj_reading_scale,
|
||||
]);
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
array_push(v, [
|
||||
real(sep[1]) * obj_reading_scale,
|
||||
-real(sep[3]) * obj_reading_scale,
|
||||
real(sep[2]) * obj_reading_scale,
|
||||
]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -568,10 +568,10 @@ function Panel_Inspector() : PanelContent() constructor {
|
|||
var con_w = contentPane.surface_w;
|
||||
var con_h = contentPane.surface_h - yy;
|
||||
|
||||
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, 0, yy, con_w, con_h, COLORS._main_icon);
|
||||
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, 0, yy, con_w, con_h, merge_color(CDEF.main_ltgrey, CDEF.main_white, 0.5));
|
||||
yy += ui(8);
|
||||
|
||||
for (var i = 0, n = array_length(_logs); i < n; i++) {
|
||||
for (var i = array_length(_logs) - 1; i >= 0; i--) {
|
||||
var _log = _logs[i];
|
||||
|
||||
var _time = _log[0];
|
||||
|
|
|
@ -214,10 +214,6 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
d3_tool_snap_rotation = 15;
|
||||
#endregion
|
||||
|
||||
#region shadow map
|
||||
|
||||
#endregion
|
||||
|
||||
#region view channel
|
||||
d3ChannelNames = [ "Rendered", "Normal", "Depth" ];
|
||||
d3Channel = new scrollBox(d3ChannelNames, function(index) { d3_preview_channel = index; });
|
||||
|
|
Loading…
Reference in a new issue