Fix obj material, rotation snap bug.

This commit is contained in:
Tanasart 2023-08-29 19:26:18 +02:00
parent a58670de8b
commit 051553fa58
11 changed files with 168 additions and 140 deletions

View file

@ -66,6 +66,7 @@
{"name":"test","order":23,"path":"folders/functions/test.yy",},
{"name":"tween","order":33,"path":"folders/functions/tween.yy",},
{"name":"value","order":1,"path":"folders/functions/value.yy",},
{"name":"variables","order":41,"path":"folders/functions/variables.yy",},
{"name":"vector","order":3,"path":"folders/functions/vector.yy",},
{"name":"window","order":29,"path":"folders/functions/window.yy",},
{"name":"main","order":1,"path":"folders/main.yy",},
@ -143,6 +144,7 @@
{"name":"texts","order":49,"path":"folders/nodes/icons/value/texts.yy",},
{"name":"VFX","order":134,"path":"folders/nodes/icons/VFX.yy",},
{"name":"panels","order":2,"path":"folders/panels.yy",},
{"name":"animation","order":9,"path":"folders/panels/animation.yy",},
{"name":"colors","order":4,"path":"folders/panels/colors.yy",},
{"name":"context menu","order":5,"path":"folders/panels/context menu.yy",},
{"name":"graph","order":1,"path":"folders/panels/graph.yy",},
@ -190,8 +192,6 @@
{"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",},
{"name":"widget","order":3,"path":"folders/VCT/widget.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"variables","order":41,"path":"folders/functions/variables.yy",},
{"name":"animation","order":9,"path":"folders/panels/animation.yy",},
],
"ResourceOrderSettings": [
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},

View file

@ -89,6 +89,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"test","folderPath":"folders/functions/test.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"tween","folderPath":"folders/functions/tween.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"value","folderPath":"folders/functions/value.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"variables","folderPath":"folders/functions/variables.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"vector","folderPath":"folders/functions/vector.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"window","folderPath":"folders/functions/window.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"main","folderPath":"folders/main.yy",},
@ -178,6 +179,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"VFX","folderPath":"folders/nodes/icons/VFX.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"panels","folderPath":"folders/panels.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"_others","folderPath":"folders/panels/_others.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"animation","folderPath":"folders/panels/animation.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"colors","folderPath":"folders/panels/colors.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"context menu","folderPath":"folders/panels/context menu.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"graph","folderPath":"folders/panels/graph.yy",},
@ -228,8 +230,6 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"variables","folderPath":"folders/functions/variables.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"animation","folderPath":"folders/panels/animation.yy",},
],
"IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},

View file

@ -23,8 +23,9 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
drag_sv = 0;
drag_delta = 0;
drag_prev = 0;
drag_dist = 0;
drag_val = 0;
drag_val = 0;
drag_mx = 0;
drag_my = 0;
drag_px = 0;
@ -352,18 +353,13 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
draw_line_round(cx, cy, cx + _nv.X * 100, cy + _nv.Y * 100, 2);
if(drag_prev != undefined) {
var _rd = (mAng - drag_prev) * (_nv.Z > 0? 1 : -1);
var _currR = new BBMOD_Quaternion().FromAxisAngle(_n, _rd);
drag_val = _currR.Mul(drag_val);
var _rd = (mAng - drag_prev) * (_nv.Z > 0? 1 : -1);
drag_dist += _rd;
var _dist = value_snap(drag_dist, _sny);
var _axs = drag_val.GetAxis();
var _ang = drag_val.GetAngle();
var _ans = value_snap(_ang, _sny);
var _NrotE = new BBMOD_Quaternion().FromAxisAngle(_axs, -_ans);
var _Nrot = _NrotE.ToArray();
var _currR = new BBMOD_Quaternion().FromAxisAngle(_n, _dist);
var _val = _currR.Mul(drag_val);
var _Nrot = _val.ToArray();
if(inputs[| index].setValue(_Nrot))
UNDO_HOLDING = true;
@ -379,8 +375,8 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
drag_axis = _hover;
drag_prev = undefined;
drag_axs = undefined;
drag_val = _qrot.Clone();
drag_dist = 0;
} #endregion
} #endregion

View file

@ -3,7 +3,9 @@ function Panel_Linear_Setting() : PanelContent() constructor {
w = ui(380);
bg_y = -1;
bg_y = -1;
bg_y_to = -1;
bg_a = 0;
properties = []
static setHeight = function() { h = ui(12 + 36 * array_length(properties)); }
@ -14,9 +16,8 @@ function Panel_Linear_Setting() : PanelContent() constructor {
var ww = ui(200);
var wh = TEXTBOX_HEIGHT;
var bg_y_to = bg_y;
if(bg_y) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, ui(4), bg_y, w - ui(8), th, COLORS.panel_prop_bg, 0.5);
var _hov = false;
if(bg_y) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, ui(4), bg_y, w - ui(8), th, COLORS.panel_prop_bg, 0.5 * bg_a);
for( var i = 0, n = array_length(properties); i < n; i++ ) {
var _prop = properties[i];
@ -28,8 +29,10 @@ function Panel_Linear_Setting() : PanelContent() constructor {
_widg.setFocusHover(pFOCUS, pHOVER);
_widg.register();
if(pHOVER && point_in_rectangle(mx, my, 0, yy - th / 2, w, yy + th / 2))
if(pHOVER && point_in_rectangle(mx, my, 0, yy - th / 2, w, yy + th / 2)) {
bg_y_to = yy - th / 2;
_hov = true;
}
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text_add(ui(16), yy, _text);
@ -45,8 +48,10 @@ function Panel_Linear_Setting() : PanelContent() constructor {
yy += th;
}
bg_a = lerp_float(bg_a, _hov, 2);
if(bg_y == -1) bg_y = bg_y_to;
else bg_y = lerp_float(bg_y, bg_y_to, 3);
else bg_y = lerp_float(bg_y, bg_y_to, 2);
}
function drawContent(panel) { drawSettings(panel); }

View file

@ -6,58 +6,58 @@ function __3dCube() : __3dObject() constructor {
size /= 2;
vertex = [[
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 0),
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 1),
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(1, 0),
new __vertex( size, -size, size).setNormal(0, 0, 1).setUV(1, 1),
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 0),
new __vertex(-size, size, size).setNormal(0, 0, 1).setUV(1, 1),
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(0, 1),
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 1),
new __vertex(-size, size, size).setNormal(0, 0, 1).setUV(0, 0),
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(1, 0),
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 0),
new __vertex( size, -size, -size).setNormal(0, 0, -1).setUV(1, 0),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 1),
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 1),
new __vertex( size, -size, -size).setNormal(0, 0, -1).setUV(1, 1),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 0),
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 0),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 1),
new __vertex(-size, size, -size).setNormal(0, 0, -1).setUV(0, 1),
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 1),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 0),
new __vertex(-size, size, -size).setNormal(0, 0, -1).setUV(0, 0),
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(0, 0),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(1, 0),
new __vertex(-size, size, size).setNormal(-1, 0, 0).setUV(1, 1),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(1, 1),
new __vertex(-size, size, size).setNormal(-1, 0, 0).setUV(1, 0),
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(0, 0),
new __vertex(-size, -size, -size).setNormal(-1, 0, 0).setUV(1, 1),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(0, 1),
new __vertex(-size, -size, -size).setNormal(-1, 0, 0).setUV(0, 1),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(1, 1),
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
new __vertex( size, size, size).setNormal(1, 0, 0).setUV(1, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(1, 0),
new __vertex( size, size, size).setNormal(1, 0, 0).setUV(0, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(0, 1),
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
new __vertex( size, -size, -size).setNormal(1, 0, 0).setUV(0, 1),
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(1, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(0, 1),
new __vertex( size, -size, -size).setNormal(1, 0, 0).setUV(1, 1),
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(0, 0),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(1, 0),
new __vertex( size, size, size).setNormal(0, 1, 0).setUV(1, 1),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
new __vertex( size, size, size).setNormal(0, 1, 0).setUV(1, 0),
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(0, 0),
new __vertex(-size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
new __vertex(-size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
new __vertex( size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
new __vertex(-size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
new __vertex( size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
new __vertex(-size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
]];
VB = build();

View file

@ -8,58 +8,58 @@ function __3dCubeFaces() : __3dObject() constructor {
vertex = [
[
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 0),
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 1),
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(1, 0),
new __vertex( size, -size, size).setNormal(0, 0, 1).setUV(1, 1),
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 0),
new __vertex(-size, size, size).setNormal(0, 0, 1).setUV(1, 1),
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(0, 1),
],
[
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 0),
new __vertex( size, -size, -size).setNormal(0, 0, -1).setUV(1, 0),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 1),
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 0),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 1),
new __vertex(-size, size, -size).setNormal(0, 0, -1).setUV(0, 1),
],
[
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(0, 1),
new __vertex(-size, size, size).setNormal(0, 0, 1).setUV(0, 0),
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(1, 0),
],
[
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 1),
new __vertex( size, -size, -size).setNormal(0, 0, -1).setUV(1, 1),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 0),
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(0, 1),
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(1, 0),
new __vertex(-size, size, -size).setNormal(0, 0, -1).setUV(0, 0),
],
[
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(0, 0),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(1, 0),
new __vertex(-size, size, size).setNormal(-1, 0, 0).setUV(1, 1),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(1, 1),
new __vertex(-size, size, size).setNormal(-1, 0, 0).setUV(1, 0),
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(0, 0),
new __vertex(-size, -size, -size).setNormal(-1, 0, 0).setUV(1, 1),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(0, 1),
],
[
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
new __vertex( size, size, size).setNormal(1, 0, 0).setUV(1, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
new __vertex( size, -size, -size).setNormal(1, 0, 0).setUV(0, 1),
],
[
new __vertex(-size, -size, -size).setNormal(-1, 0, 0).setUV(0, 1),
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(1, 1),
],
[
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(1, 0),
new __vertex( size, size, size).setNormal(1, 0, 0).setUV(0, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(0, 1),
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(1, 0),
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(0, 1),
new __vertex( size, -size, -size).setNormal(1, 0, 0).setUV(1, 1),
],
[
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(0, 0),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(1, 0),
new __vertex( size, size, size).setNormal(0, 1, 0).setUV(1, 1),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
new __vertex( size, size, size).setNormal(0, 1, 0).setUV(1, 0),
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(0, 0),
new __vertex(-size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
],
[
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
new __vertex( size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
new __vertex(-size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
new __vertex(-size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
],
[
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
new __vertex( size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
new __vertex(-size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
]
];

View file

@ -31,7 +31,9 @@ function __3dObject() constructor {
scale = new __vec3(1);
size = new __vec3(1);
materials = [];
materials = [];
matrial_index = [];
texture_flip = false;
static checkParameter = function(params = {}, forceUpdate = false) { #region
var _keys = struct_get_names(params);
@ -169,9 +171,13 @@ function __3dObject() constructor {
} #endregion
#region ++++ Submit & Material ++++
gpu_set_tex_repeat(true);
for( var i = 0, n = array_length(VB); i < n; i++ ) {
if(_shader == sh_d3d_default) {
var _mat = array_safe_get(materials, i, noone);
var _ind = array_safe_get(matrial_index, i, i);
var _mat = array_safe_get(materials, _ind, noone);
if(_mat == noone) {
shader_set_f("mat_diffuse", 1);
shader_set_f("mat_specular", 0);
@ -181,12 +187,16 @@ function __3dObject() constructor {
shader_set_f("mat_reflective", 0);
} else
_mat.submitShader();
shader_set_i("mat_flip", texture_flip);
//print($"{instanceof(self)}: {i}, {_mat}");
var _tex = _mat == noone? -1 : _mat.getTexture();
vertex_submit(VB[i], render_type, _tex);
} else
vertex_submit(VB[i], render_type, -1);
}
gpu_set_tex_repeat(false);
#endregion
shader_reset();

View file

@ -39,8 +39,7 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
["Material", false], in_mesh + 1,
]
input_fix_len = ds_list_size(inputs);
input_display_len = array_length(input_display_list);
setIsDynamicInput(1);
current_path = "";
materials = [];
@ -61,16 +60,26 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
updateObj(path);
}
static createMaterial = function(m_index) { #region
var index = ds_list_size(inputs);
inputs[| index] = nodeValue(materialNames[m_index] + " Material", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, noone)
static createNewInput = function(index = -1) { #region
if(index == -1) index = ds_list_size(inputs);
inputs[| index] = nodeValue("Material", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, noone)
.setVisible(true, true);
} #endregion
static createMaterial = function(m_index) { #region
var index = input_fix_len + m_index;
input_display_list[input_display_len + m_index] = index;
if(index < ds_list_size(inputs)) return;
createNewInput(index);
if(m_index >= array_length(materials)) return;
var matY = y - (array_length(materials) - 1) / 2 * (128 + 32);
var mat = materials[m_index];
inputs[| index].name = materialNames[m_index] + " Material";
if(file_exists(mat.diff_path)) {
var sol = Node_create_Image_path(x - (w + 128), matY + m_index * (128 + 32), mat.diff_path);
@ -90,11 +99,10 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
if(!file_exists(_path)) return;
current_path = _path;
var _flip = inputs[| in_mesh + 1].getValue();
var _dir = filename_dir(_path);
var _pathMtl = string_copy(_path, 1, string_length(_path) - 4) + ".mtl";
var _v = readObj(_path, _flip);
var _v = readObj(_path);
if(_v == noone) return;
if(object != noone) object.destroy();
@ -120,8 +128,9 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
array_resize(input_display_list, input_display_len);
while(ds_list_size(inputs) > input_fix_len)
ds_list_delete(inputs, input_fix_len);
var _overflow = input_fix_len + array_length(materialNames);
while(ds_list_size(inputs) > _overflow)
ds_list_delete(inputs, _overflow);
for(var i = 0; i < array_length(materialNames); i++)
createMaterial(i);
@ -135,27 +144,29 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _path = _data[in_mesh + 0];
var _flip = _data[in_mesh + 1];
if(_path != current_path)
updateObj(_path);
if(object == noone) return noone;
var materials = [];
for( var i = input_fix_len, n = array_length(_data); i < n; i++ )
materials[i - input_fix_len] = _data[i];
var _object = getObject(_array_index);
if(object == noone)
return _object;
_object.VF = global.VF_POS_NORM_TEX_COL;
_object.VB = object.VB;
_object.NVB = object.NVB;
_object.vertex = object.vertex;
_object.object_counts = object.object_counts;
_object.materials = materials;
_object.object_counts = object.object_counts;
_object.materials = materials;
_object.matrial_index = materialIndex;
_object.texture_flip = _flip;
setTransform(_object, _data);
return _object;
} #endregion
//static getPreviewValues = function() { return array_safe_get(all_inputs, in_mesh + 1, noone); }
static getPreviewValues = function() { return array_safe_get(all_inputs, in_mesh + 2, noone); }
}

View file

@ -1295,8 +1295,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
isTool = true;
} #endregion
#region[#88ffe916] === Save Load ===
static serialize = function(scale = false, preset = false) {
static serialize = function(scale = false, preset = false) { #region
var _map = {};
//print(" > Serializing: " + name);
@ -1338,7 +1337,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
doSerialize(_map);
processSerialize(_map);
return _map;
}
} #endregion
static attributeSerialize = function() { return attributes; }
static doSerialize = function(_map) {}
@ -1346,7 +1345,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
load_scale = false;
load_map = -1;
static deserialize = function(_map, scale = false, preset = false) {
static deserialize = function(_map, scale = false, preset = false) { #region
load_map = _map;
load_scale = scale;
@ -1390,9 +1389,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
triggerRender();
}
}
} #endregion
static inputBalance = function() { //Cross version compatibility for dynamic input nodes
static inputBalance = function() { #region //Cross version compatibility for dynamic input nodes
if(!struct_has(load_map, "data_length"))
return;
@ -1430,9 +1429,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
//print($"IO size after: {array_length(load_map.inputs)}");
//for( var i = 0, n = array_length(load_map.inputs); i < n; i++ )
// print($"{i}: {load_map.inputs[i] == noone? "noone" : load_map.inputs[i].name}");
}
} #endregion
static inputGenerate = function() { //Generate input for dynamic input nodes
static inputGenerate = function() { #region //Generate input for dynamic input nodes
if(createNewInput == noone)
return;
@ -1440,16 +1439,16 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
//print($"Node {name} create {_dynamic_inputs} inputs for data length {data_length}");
repeat(_dynamic_inputs)
createNewInput();
}
} #endregion
static attributeDeserialize = function(attr) {
static attributeDeserialize = function(attr) { #region
struct_override(attributes, attr);
}
#endregion
static postDeserialize = function() {}
static processDeserialize = function() {}
static applyDeserialize = function(preset = false) {
static applyDeserialize = function(preset = false) { #region
var _inputs = load_map.inputs;
var amo = min(ds_list_size(inputs), array_length(_inputs));
@ -1475,11 +1474,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
}
doApplyDeserialize();
}
} #endregion
static doApplyDeserialize = function() {}
static loadGroup = function(context = PANEL_GRAPH.getCurrentContext()) {
static loadGroup = function(context = PANEL_GRAPH.getCurrentContext()) { #region
if(_group == noone) {
var c = context;
if(c != noone) c.add(self);
@ -1498,9 +1497,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
throw(txt);
}
}
}
} #endregion
static connect = function(log = false) {
static connect = function(log = false) { #region
var connected = true;
for(var i = 0; i < ds_list_size(inputs); i++)
connected &= inputs[| i].connect(log);
@ -1513,11 +1512,10 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
if(!connected) ds_queue_enqueue(CONNECTION_CONFLICT, self);
return connected;
}
} #endregion
static preConnect = function() {}
static postConnect = function() {}
#endregion
static resetAnimation = function() {}

View file

@ -1,4 +1,4 @@
function readObj(path, flipUV = false) {
function readObj(path) {
if(!file_exists(path)) return noone;
var _VB = [];
@ -30,7 +30,10 @@ function readObj(path, flipUV = false) {
ds_list_add(v, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]);
break;
case "vt" :
ds_list_add(vt, [ toNumber(sep[1]), flipUV + toNumber(sep[2]) * (1 - flipUV * 2) ]); // flipUV? 1 - sep[2] : sep[2]
var _u = toNumber(sep[1]);
var _v = toNumber(sep[2]);
ds_list_add(vt, [ _u, _v ]);
break;
case "vn" :
ds_list_add(vn, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]);

View file

@ -59,6 +59,8 @@ varying float v_cameraDistance;
uniform int mat_use_normal;
uniform float mat_normal_strength;
uniform sampler2D mat_normal_map;
uniform int mat_flip;
#endregion
#region ---- rendering ----
@ -144,7 +146,10 @@ varying float v_cameraDistance;
#endregion
void main() {
mat_baseColor = texture2D( gm_BaseTexture, v_vTexcoord );
vec2 uv_coord = v_vTexcoord;
if(mat_flip == 1) uv_coord.y = -uv_coord.y;
mat_baseColor = texture2D( gm_BaseTexture, uv_coord );
mat_baseColor *= v_vColour;
vec4 final_color = mat_baseColor;
@ -153,7 +158,7 @@ void main() {
#region ++++ normal ++++
vec3 _norm = v_vNormal;
if(mat_use_normal == 1) {
vec3 _sampled_normal = texture2D(mat_normal_map, v_vTexcoord).rgb;
vec3 _sampled_normal = texture2D(mat_normal_map, uv_coord).rgb;
_norm += (_sampled_normal - 0.5) * 2. * mat_normal_strength;
}