Forge test
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
|
||||
function base_ext_init() {
|
||||
sim_init();
|
||||
|
||||
object_remove(scene_lights[0].base);
|
||||
|
||||
// project_paint_objects[0].base.visible = false;
|
||||
// tab_scene_new_object("box.arm");
|
||||
}
|
||||
|
||||
function base_ext_render() {
|
||||
|
||||
@@ -70,6 +70,10 @@ function sim_add(o: object_t, shape: physics_shape_t, mass: f32) {
|
||||
physics_body_init(body, o);
|
||||
}
|
||||
|
||||
function sim_remove(uid: i32) {
|
||||
physics_body_remove(uid);
|
||||
}
|
||||
|
||||
function sim_duplicate() {
|
||||
// Mesh
|
||||
let so: mesh_object_t = context_raw.selected_object.ext;
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
|
||||
function tab_object_draw(htab: ui_handle_t) {
|
||||
let ui: ui_t = ui_base_ui;
|
||||
if (ui_tab(htab, tr("Object"))) {
|
||||
|
||||
if (context_raw.selected_object != null) {
|
||||
let h: ui_handle_t = ui_handle(__ID__);
|
||||
h.selected = context_raw.selected_object.visible;
|
||||
context_raw.selected_object.visible = ui_check(h, "Visible");
|
||||
|
||||
let t: transform_t = context_raw.selected_object.transform;
|
||||
let rot: vec4_t = quat_get_euler(t.rot);
|
||||
rot = vec4_mult(rot, 180 / 3.141592);
|
||||
let f: f32 = 0.0;
|
||||
let changed: bool = false;
|
||||
|
||||
ui_text("Transform", ui_align_t.LEFT, ui.ops.theme.SEPARATOR_COL);
|
||||
|
||||
ui_row4();
|
||||
ui_text("Loc");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.loc.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.loc.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.loc.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.loc.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.loc.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.loc.z = f;
|
||||
}
|
||||
|
||||
ui_row4();
|
||||
ui_text("Rotation");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(rot.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
rot.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(rot.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
rot.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(rot.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
rot.z = f;
|
||||
}
|
||||
|
||||
ui_row4();
|
||||
ui_text("Scale");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.scale.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.scale.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.scale.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.scale.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.scale.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.scale.z = f;
|
||||
}
|
||||
|
||||
ui_row4();
|
||||
ui_text("Dimensions");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.dim.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.dim.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.dim.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.dim.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.dim.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.dim.z = f;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
rot = vec4_mult(rot, 3.141592 / 180);
|
||||
context_raw.selected_object.transform.rot = quat_from_euler(rot.x, rot.y, rot.z);
|
||||
transform_build_matrix(context_raw.selected_object.transform);
|
||||
transform_compute_dim(context_raw.selected_object.transform);
|
||||
///if arm_physics
|
||||
let pb: physics_body_t = map_get(physics_body_object_map, context_raw.selected_object.uid);
|
||||
if (pb != null) {
|
||||
physics_body_sync_transform(pb);
|
||||
}
|
||||
///end
|
||||
}
|
||||
|
||||
ui_text("Physics", ui_align_t.LEFT, ui.ops.theme.SEPARATOR_COL);
|
||||
|
||||
let pb: physics_body_t = map_get(physics_body_object_map, context_raw.selected_object.uid);
|
||||
|
||||
let hshape: ui_handle_t = ui_handle(__ID__);
|
||||
let shape_combo: string[] = [
|
||||
tr("None"),
|
||||
tr("Box"),
|
||||
tr("Sphere"),
|
||||
tr("Convex Hull"),
|
||||
tr("Mesh"),
|
||||
];
|
||||
hshape.position = pb != null ? pb.shape + 1 : 0;
|
||||
ui_combo(hshape, shape_combo, tr("Shape"), true);
|
||||
|
||||
let hdynamic: ui_handle_t = ui_handle(__ID__);
|
||||
hdynamic.selected = pb != null ? pb.mass > 0 : false;
|
||||
ui_check(hdynamic, "Dynamic");
|
||||
|
||||
if (hshape.changed || hdynamic.changed) {
|
||||
sim_remove(context_raw.selected_object.uid);
|
||||
if (hshape.position > 0) {
|
||||
sim_add(context_raw.selected_object, hshape.position - 1, hdynamic.selected ? 1.0 : 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
-167
@@ -1,5 +1,6 @@
|
||||
|
||||
let tab_scene_line_counter: i32 = 0;
|
||||
let tab_scene_new_meshes: string[] = null;
|
||||
|
||||
function tab_scene_select_object(mo: mesh_object_t) {
|
||||
if (mo == null) {
|
||||
@@ -33,6 +34,7 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object:
|
||||
if (char_at(current_object.name, 0) == ".") {
|
||||
return; // Hidden
|
||||
}
|
||||
|
||||
let b: bool = false;
|
||||
|
||||
// Highlight every other line
|
||||
@@ -79,6 +81,16 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object:
|
||||
tab_scene_select_object(current_object.ext);
|
||||
}
|
||||
|
||||
if (ui.is_hovered && ui.input_released_r) {
|
||||
tab_scene_select_object(current_object.ext);
|
||||
|
||||
ui_menu_draw(function (ui: ui_t) {
|
||||
if (ui_menu_button(ui, tr("Duplicate"))) {
|
||||
sim_duplicate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (b) {
|
||||
let current_y: i32 = ui._y;
|
||||
for (let i: i32 = 0; i < current_object.children.length; ++i) {
|
||||
@@ -95,15 +107,51 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object:
|
||||
}
|
||||
}
|
||||
|
||||
function tab_scene_new_object(mesh_name: string) {
|
||||
let blob: buffer_t = iron_load_blob(data_path() + "meshes/" + mesh_name);
|
||||
let raw: scene_t = armpack_decode(blob);
|
||||
let md: mesh_data_t = mesh_data_create(raw.mesh_datas[0]);
|
||||
md._.handle = md.name;
|
||||
let mo: mesh_object_t = scene_add_mesh_object(md, scene_meshes[0].materials);
|
||||
mo.base.name = md.name;
|
||||
let o: obj_t = {};
|
||||
o._ = { _gc: raw };
|
||||
mo.base.raw = o;
|
||||
map_set(data_cached_meshes, md._.handle, md);
|
||||
array_push(project_paint_objects, mo);
|
||||
tab_scene_import_mesh_done();
|
||||
}
|
||||
|
||||
function tab_scene_new_menu(ui: ui_t) {
|
||||
for (let i: i32 = 0; i < tab_scene_new_meshes.length; ++i) {
|
||||
let mesh_name: string = tab_scene_new_meshes[i];
|
||||
if (ui_menu_button(ui, mesh_name)) {
|
||||
tab_scene_new_object(mesh_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tab_scene_draw(htab: ui_handle_t) {
|
||||
let ui: ui_t = ui_base_ui;
|
||||
if (ui_tab(htab, tr("Scene"))) {
|
||||
|
||||
ui_begin_sticky();
|
||||
let row: f32[] = [1 / 4];
|
||||
|
||||
let row: f32[] = [1 / 4, 1 / 4];
|
||||
ui_row(row);
|
||||
|
||||
if (ui_button("New")) {
|
||||
if (tab_scene_new_meshes == null) {
|
||||
tab_scene_new_meshes = file_read_directory(path_data() + path_sep + "meshes");
|
||||
}
|
||||
|
||||
ui_menu_draw(tab_scene_new_menu);
|
||||
}
|
||||
|
||||
if (ui_button("Import")) {
|
||||
project_import_mesh(false, tab_scene_import_mesh_done);
|
||||
}
|
||||
|
||||
ui_end_sticky();
|
||||
|
||||
{
|
||||
@@ -111,8 +159,10 @@ function tab_scene_draw(htab: ui_handle_t) {
|
||||
|
||||
tab_scene_line_counter = 0;
|
||||
|
||||
for (let i: i32 = 0; i < _scene_root.children.length; ++i) {
|
||||
let c: object_t = _scene_root.children[i];
|
||||
let scene: object_t = _scene_root.children[0];
|
||||
|
||||
for (let i: i32 = 0; i < scene.children.length; ++i) {
|
||||
let c: object_t = scene.children[i];
|
||||
tab_scene_draw_list(ui, ui_handle(__ID__), c);
|
||||
}
|
||||
|
||||
@@ -130,169 +180,5 @@ function tab_scene_draw(htab: ui_handle_t) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let properties_handle: ui_handle_t = ui_handle(__ID__);
|
||||
if (properties_handle.init) {
|
||||
properties_handle.selected = true;
|
||||
}
|
||||
|
||||
if (ui_panel(properties_handle, "Properties", true, false)) {
|
||||
if (context_raw.selected_object != null) {
|
||||
let h: ui_handle_t = ui_handle(__ID__);
|
||||
h.selected = context_raw.selected_object.visible;
|
||||
context_raw.selected_object.visible = ui_check(h, "Visible");
|
||||
|
||||
let t: transform_t = context_raw.selected_object.transform;
|
||||
let rot: vec4_t = quat_get_euler(t.rot);
|
||||
rot = vec4_mult(rot, 180 / 3.141592);
|
||||
let f: f32 = 0.0;
|
||||
let changed: bool = false;
|
||||
|
||||
ui_row4();
|
||||
ui_text("Loc");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.loc.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.loc.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.loc.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.loc.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.loc.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.loc.z = f;
|
||||
}
|
||||
|
||||
ui_row4();
|
||||
ui_text("Rotation");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(rot.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
rot.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(rot.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
rot.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(rot.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
rot.z = f;
|
||||
}
|
||||
|
||||
ui_row4();
|
||||
ui_text("Scale");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.scale.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.scale.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.scale.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.scale.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.scale.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.scale.z = f;
|
||||
}
|
||||
|
||||
ui_row4();
|
||||
ui_text("Dimensions");
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.dim.x);
|
||||
f = parse_float(ui_text_input(h, "X"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.dim.x = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.dim.y);
|
||||
f = parse_float(ui_text_input(h, "Y"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.dim.y = f;
|
||||
}
|
||||
|
||||
h = ui_handle(__ID__);
|
||||
h.text = f32_to_string(t.dim.z);
|
||||
f = parse_float(ui_text_input(h, "Z"));
|
||||
if (h.changed) {
|
||||
changed = true;
|
||||
t.dim.z = f;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
rot = vec4_mult(rot, 3.141592 / 180);
|
||||
context_raw.selected_object.transform.rot = quat_from_euler(rot.x, rot.y, rot.z);
|
||||
transform_build_matrix(context_raw.selected_object.transform);
|
||||
transform_compute_dim(context_raw.selected_object.transform);
|
||||
///if arm_physics
|
||||
let pb: physics_body_t = map_get(physics_body_object_map, context_raw.selected_object.uid);
|
||||
if (pb != null) {
|
||||
physics_body_sync_transform(pb);
|
||||
}
|
||||
///end
|
||||
}
|
||||
|
||||
if (ui_button("Sphere Dynamic")) {
|
||||
sim_add(context_raw.selected_object, physics_shape_t.SPHERE, 1.0);
|
||||
}
|
||||
|
||||
if (ui_button("Box Dynamic")) {
|
||||
sim_add(context_raw.selected_object, physics_shape_t.BOX, 1.0);
|
||||
}
|
||||
|
||||
if (ui_button("Box Static")) {
|
||||
sim_add(context_raw.selected_object, physics_shape_t.BOX, 0.0);
|
||||
}
|
||||
|
||||
if (ui_button("Hull Dynamic")) {
|
||||
sim_add(context_raw.selected_object, physics_shape_t.HULL, 1.0);
|
||||
}
|
||||
|
||||
if (ui_button("Mesh Static")) {
|
||||
sim_add(context_raw.selected_object, physics_shape_t.MESH, 0.0);
|
||||
}
|
||||
|
||||
if (ui_button("Duplicate")) {
|
||||
sim_duplicate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ function ui_base_ext_init_hwnd_tabs(): tab_draw_array_t[] {
|
||||
_draw_callback_create(tab_plugins_draw)
|
||||
];
|
||||
let a1: tab_draw_array_t = [
|
||||
_draw_callback_create(tab_object_draw),
|
||||
_draw_callback_create(tab_materials_draw),
|
||||
_draw_callback_create(tab_particles_draw)
|
||||
];
|
||||
|
||||
@@ -14,4 +14,12 @@ function ui_header_draw_tool_properties(ui: ui_t) {
|
||||
let h_record: ui_handle_t = ui_handle(__ID__);
|
||||
let record: bool = ui_check(h_record, tr("Record"));
|
||||
}
|
||||
|
||||
else if (context_raw.tool == workspace_tool_t.FILL) {
|
||||
let brush_scale_handle: ui_handle_t = ui_handle(__ID__);
|
||||
if (brush_scale_handle.init) {
|
||||
brush_scale_handle.value = context_raw.brush_scale;
|
||||
}
|
||||
context_raw.brush_scale = ui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ function context_create(): context_t {
|
||||
c.brush_opacity_handle.value = 1.0;
|
||||
///if is_forge
|
||||
let atlas_w: i32 = 8192; // config_get_texture_res();
|
||||
let item_w: i32 = 4096;
|
||||
let item_w: i32 = 2048;
|
||||
let atlas_stride: i32 = atlas_w / item_w;
|
||||
c.brush_scale = atlas_stride;
|
||||
///else
|
||||
|
||||
@@ -219,7 +219,7 @@ function _import_mesh_add_mesh(mesh: raw_mesh_t) {
|
||||
// Scale tex coords into global atlas
|
||||
let atlas_w: i32 = config_get_texture_res();
|
||||
let item_i: i32 = project_paint_objects.length;
|
||||
let item_w: i32 = 4096;
|
||||
let item_w: i32 = 2048;
|
||||
let atlas_stride: i32 = atlas_w / item_w;
|
||||
let atlas_step: i32 = 32767 / atlas_stride;
|
||||
let item_x: i32 = (item_i % atlas_stride) * atlas_step;
|
||||
|
||||
@@ -160,6 +160,9 @@ function render_path_raytrace_raytrace_init(shader_name: string, build: bool = t
|
||||
///if is_forge
|
||||
for (let i: i32 = 0; i < project_paint_objects.length; ++i) {
|
||||
let po: mesh_object_t = project_paint_objects[i];
|
||||
if (!po.base.visible) {
|
||||
continue;
|
||||
}
|
||||
iron_raytrace_as_add(po.data._.vertex_buffer.buffer_, po.data._.index_buffers[0].buffer_, po.base.transform.world_unpack);
|
||||
}
|
||||
///else
|
||||
|
||||
Reference in New Issue
Block a user