Skip to content

Commit

Permalink
Added vertex-buttons
Browse files Browse the repository at this point in the history
Added buttons which sit on top of vertices. Those do not have any funcition atm but this will be added in the next step.
  • Loading branch information
141512114 committed Feb 4, 2021
1 parent bb32587 commit 250ab61
Show file tree
Hide file tree
Showing 112 changed files with 1,465 additions and 58 deletions.
63 changes: 62 additions & 1 deletion ModelCreator/ModelCreator.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added ModelCreator/datafiles/Collisions.dll
Binary file not shown.
1 change: 1 addition & 0 deletions ModelCreator/objects/o_element/CleanUp_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if (vlist != -1) then ds_list_destroy(vlist);
2 changes: 2 additions & 0 deletions ModelCreator/objects/o_element/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ z = 0;
model = -1;
texture = -1;

vlist = -1;

// Transform options
xsize = 1;
ysize = 1;
Expand Down
1 change: 1 addition & 0 deletions ModelCreator/objects/o_element/Destroy_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if (vlist != -1) then ds_list_destroy(vlist);
2 changes: 2 additions & 0 deletions ModelCreator/objects/o_element/o_element.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 49 additions & 9 deletions ModelCreator/objects/o_softwareManager/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ for (var i = 0; i < room_width; i += size) {
for (var j = 0; j < room_height; j += size) {
var color = c_white;

vertex_add_point(vbuffer, i, j, zz, 0, 0, 1, 0, 0, color, 1);
vertex_add_point(vbuffer, i+size, j, zz, 0, 0, 1, 1, 0, color, 1);
vertex_add_point(vbuffer, i+size, j+size, zz, 0, 0, 1, 1, 1, color, 1);
vertex_add_point(vbuffer, -1, i, j, zz, 0, 0, 1, 0, 0, color, 1);
vertex_add_point(vbuffer, -1, i+size, j, zz, 0, 0, 1, 1, 0, color, 1);
vertex_add_point(vbuffer, -1, i+size, j+size, zz, 0, 0, 1, 1, 1, color, 1);

vertex_add_point(vbuffer, i+size, j+size, zz, 0, 0, 1, 1, 1, color, 1);
vertex_add_point(vbuffer, i, j+size, zz, 0, 0, 1, 0, 1, color, 1);
vertex_add_point(vbuffer, i, j, zz, 0, 0, 1, 0, 0, color, 1);
vertex_add_point(vbuffer, -1, i+size, j+size, zz, 0, 0, 1, 1, 1, color, 1);
vertex_add_point(vbuffer, -1, i, j+size, zz, 0, 0, 1, 0, 1, color, 1);
vertex_add_point(vbuffer, -1, i, j, zz, 0, 0, 1, 0, 0, color, 1);
}
}

Expand All @@ -36,6 +36,46 @@ instance_create_depth(xppos, yppos, 0, o_camera);
instance_create_depth(xppos, yppos, 0, o_userControl);

var cube_size = 96;
var el_obj = instance_create_depth(xppos - cube_size/2, yppos - cube_size/2, 0, o_element);
el_obj.model = vertex_create_cube(0, 0, 0, cube_size, c_gray, 1);
el_obj.z = 25;
var cube_x = xppos - cube_size/2, cube_y = yppos - cube_size/2, cube_z = 25;
var el_obj = instance_create_depth(cube_x, cube_y, 0, o_element);
el_obj.vlist = ds_list_create();
el_obj.model = vertex_create_cube(el_obj.vlist, 0, 0, 0, cube_size, c_gray, 1);
el_obj.z = cube_z;

if (el_obj.vlist != -1) {
var vlen = ds_list_size(el_obj.vlist), vcube_size = 10, v_pos_list = ds_list_create();
for (var i = 0; i < vlen; i++) {
var xx = el_obj.x + ds_list_find_value(el_obj.vlist, i)[0] - vcube_size/2;
var yy = el_obj.y + ds_list_find_value(el_obj.vlist, i)[1] - vcube_size/2;
var zz = el_obj.z + ds_list_find_value(el_obj.vlist, i)[2] - vcube_size/2;

var v_pos_len = ds_list_size(v_pos_list)-1;

// Check if our list has entries
var same_vertex_pos = 0; if (v_pos_len > -1) {
var j = 0; while (j <= v_pos_len) {
// Check if the row exists (has a valid value)
if (ds_list_find_value(v_pos_list, j) != undefined && ds_list_find_value(v_pos_list, j) != -1) {
var v_value = ds_list_find_value(v_pos_list, j);

// Check if it's exactly the same position
if (xx == v_value[0] && yy == v_value[1] && zz == v_value[2]) then same_vertex_pos++;

j++;
}
}
}

// Check if there are no vertecies with the same position
if (same_vertex_pos <= 0) {
var vpoint_obj = instance_create_depth(xx, yy, 0, o_vertex_point);
vpoint_obj.z = zz;
vpoint_obj.model = vertex_create_cube(-1, 0, 0, 0, vcube_size, c_orange, 1);

// Add the new vertex position to the list
ds_list_add(v_pos_list, [xx, yy, zz]);
}
}
// Destroy the temporary list
ds_list_destroy(v_pos_list);
}
3 changes: 0 additions & 3 deletions ModelCreator/objects/o_userControl/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
event_inherited();

// Z axis
z = 0;

// Rotation
look_dir = 0;
look_pitch = 0;
Expand Down
23 changes: 18 additions & 5 deletions ModelCreator/objects/o_userControl/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ window_mouse_set(window_get_width() / 2, window_get_height() / 2);
if (keyboard_check_direct(vk_escape)) then game_end(); // Emergency exit

// Movement
var dx = 0, dy = 0, len = 0;

var w_s_move = sign(keyboard_check(ord("W")) - keyboard_check(ord("S")));
if (w_s_move != 0) {
x += w_s_move * dcos(look_dir) * move_speed;
y += -(w_s_move * dsin(look_dir)) * move_speed;
dx += w_s_move * dcos(look_dir) * move_speed;
dy += -(w_s_move * dsin(look_dir)) * move_speed;
z += -(w_s_move * dsin(look_pitch)) * move_speed;
}

var a_d_move = sign(keyboard_check(ord("D")) - keyboard_check(ord("A")));
if (a_d_move != 0) {
x -= a_d_move * dsin(look_dir) * move_speed;
y -= a_d_move * dcos(look_dir) * move_speed;
}
dx -= a_d_move * dsin(look_dir) * move_speed;
dy -= a_d_move * dcos(look_dir) * move_speed;
}

if (a_d_move != 0 || w_s_move != 0) then len = move_speed;

// Fix diagonal movement (speed fix)
var dir = point_direction(0, 0, dx, dy);
var len_x = 0, len_y = 0;
len_x = lengthdir_x(len, dir);
len_y = lengthdir_y(len, dir);

x += len_x;
y += len_y;
34 changes: 34 additions & 0 deletions ModelCreator/objects/o_vertex_point/o_vertex_point.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions ModelCreator/scripts/c_hit_fraction/c_hit_fraction.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// @author https://web.archive.org/web/20191214124933/https://gmc.yoyogames.com/index.php?showtopic=632606
function c_hit_fraction() {
/*
Returns a number between 0 and 1, which is the distance to the hit.
*/
return external_call(global._c_hit_fraction);


}
12 changes: 12 additions & 0 deletions ModelCreator/scripts/c_hit_fraction/c_hit_fraction.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions ModelCreator/scripts/c_hit_nx/c_hit_nx.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// @author https://web.archive.org/web/20191214124933/https://gmc.yoyogames.com/index.php?showtopic=632606
function c_hit_nx() {
/*
Returns the x component of the normal of the last hit.
*/
return external_call(global._c_hit_nx);


}
12 changes: 12 additions & 0 deletions ModelCreator/scripts/c_hit_nx/c_hit_nx.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions ModelCreator/scripts/c_hit_ny/c_hit_ny.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// @author https://web.archive.org/web/20191214124933/https://gmc.yoyogames.com/index.php?showtopic=632606
function c_hit_ny() {
/*
Returns the y component of the normal of the last hit.
*/
return external_call(global._c_hit_ny);


}
12 changes: 12 additions & 0 deletions ModelCreator/scripts/c_hit_ny/c_hit_ny.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions ModelCreator/scripts/c_hit_nz/c_hit_nz.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// @author https://web.archive.org/web/20191214124933/https://gmc.yoyogames.com/index.php?showtopic=632606
function c_hit_nz() {
/*
Returns the z component of the normal of the last hit.
*/
return external_call(global._c_hit_nz);


}
12 changes: 12 additions & 0 deletions ModelCreator/scripts/c_hit_nz/c_hit_nz.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions ModelCreator/scripts/c_hit_object/c_hit_object.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// @param n
/// @author https://web.archive.org/web/20191214124933/https://gmc.yoyogames.com/index.php?showtopic=632606
function c_hit_object(argument0) {
/*
Returns the id's of the collision objects that were hit.
For raycasts and sweeps, only one object can be hit so use 0 as the argument.
Overlap tests can hit multiple objects to use argument0 to access each one.
c_overlap_world() and c_overlap_world_position() return the number of objects that were hit.
*/
return external_call(global._c_hit_object, argument0);


}
12 changes: 12 additions & 0 deletions ModelCreator/scripts/c_hit_object/c_hit_object.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 250ab61

Please sign in to comment.