Skip to content

Commit

Permalink
0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Pitto committed Oct 4, 2018
1 parent 459114f commit 4195a8e
Show file tree
Hide file tree
Showing 10 changed files with 1,464 additions and 39 deletions.
Binary file modified data/icon-set.ase
Binary file not shown.
Binary file modified data/icon-set.bmp
Binary file not shown.
29 changes: 7 additions & 22 deletions data/instructions.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,34 @@
F1..........Show / Hide help

DRAW TOOLS______________________________________________________________

V...........Selection tool
click and drag to select multiple polygons
A...........Direct Sel. tool - click & drag to select multiple nodes
V...........Selection tool - click and drag to select multiple polygons
P...........Pen Tool
left mouse click to add points, right click to
automatically close path
SPACE.......Hand Tool - while pressed it's possible to drag the artwork
using the mouse
LEFT SHIFT..while pressed disable snapping to point or line

EDITING COMMANDS________________________________________________________

CANC........Delete selected polygon/s

VIEW COMMANDS

CANC........Delete selected polygon/s or nodes
VIEW COMMANDS___________________________________________________________
Q...........Show / Hide Points
W...........Show / Hide Wireframe
C...........Show / Hide Centroids
B...........Show / Hide background Bitmap
X...........Show / Hide alpha Bitmap

FILE COMMANDS___________________________________________________________

S...........Save as .lpe file <- WILL OVERWRITE EXISTING FILE
E...........Exports as SVG file <- WILL OVERWRITE EXISTING FILE
CTRL + L....load .lpe file

DEBUG COMMANDS__________________________________________________________

D...........Show / Hide Polygon point's pointers Address
CTRL + R....Fill artwork with random polygons


Special thanks to:
D.J. Peters for his ImageScale function
Mr Swiss for his code review of the scanline algorithm

Stonemonkey, Muttonhead for their tips

the fill polygon (using scanline algorithm) function is a translation
of a c snippet by Angad... original source:
the fill polygon (using scanline algorithm) function is a translation of a c snippet by Angad...
original source:
http://code-heaven.blogspot.it/2009/10/simple-c-program-for-scan-line-polygon.html

FB Low Poly Editor is created using FreeBasic language
www.freebasic.net
FB Low Poly Editor is created using FreeBasic language: www.freebasic.net
4 changes: 3 additions & 1 deletion definitions.bi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'define and consts______________________________________________________
#define APP_NAME "Low Poly Editor by Pitto"
#define APP_VERSION "Version 0.09"
#define APP_VERSION "Version 0.10"
#define SCR_W 1024
#define SCR_H 768
#define MIN_SNAP_DIST 15
Expand All @@ -19,6 +19,8 @@
#define BTN_W 90 'GUI standard button width
#define BTN_H 12 'GUI standard button heigth

#define KEYBOARD_PX_INCREMENTS 1


'colors
#define C_BLACK &h000000
Expand Down
12 changes: 9 additions & 3 deletions enums.bi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ enum proto_input_mode
input_add_point = 2
input_close_polygon = 3
input_selection
input_direct_selection
input_move_node_up
input_move_node_down
input_move_node_left
input_move_node_right
input_delete_node
input_hand
add_vertex
del_vertex
Expand Down Expand Up @@ -44,10 +50,10 @@ enum proto_console_message
end enum

enum proto_icon
icon_selection = 0
icon_selection_over
icon_direct_selection
icon_direct_selection = 0
icon_direct_selection_over
icon_selection
icon_selection_over
icon_pen
icon_pen_is_pressed
icon_pen_snap
Expand Down
159 changes: 156 additions & 3 deletions functions.bi
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ declare sub draw_mouse_pointer ( x as integer, y as integer, _
is_snap_point_available as boolean, _
input_mode as proto_input_mode, _
icon_set() as Ulong ptr)
declare sub mark_selected_nodes ( x1 as integer, y1 as integer, _
x2 as integer, y2 as integer, _
array() as polygon_proto)
declare sub unmark_all_nodes ( array() as polygon_proto)
declare sub move_selected_node(x_offset as integer, y_offset as integer, array() as polygon_proto)
declare function delete_selected_node (node as point_proto ptr) as point_proto ptr
declare function count_selected_nodes (head as point_proto ptr) as integer

'_______________________________________________________________________

Expand All @@ -100,6 +107,7 @@ function add_point(head as point_proto ptr ptr, x as single, y as single) as poi
dim as point_proto ptr p = callocate(sizeof(point_proto))
p->x = x
p->y = y
p->is_selected = false
p->next_p = *head
*head = p
return p
Expand Down Expand Up @@ -476,8 +484,17 @@ Sub draw_vertices(head as point_proto ptr, ByVal c As ULong, view_area as view_a

while head <> NULL
if (head->next_p <> NULL) then
line (head->x*view_area.zoom + view_area.x -2, _
head->y*view_area.zoom + view_area.y -2)-STEP(4,4),c, BF
'highlight the selected node
if head->is_selected then
circle (head->x*view_area.zoom + view_area.x , _
head->y*view_area.zoom + view_area.y ), 3, C_BLUE,,,,F

end if

circle (head->x*view_area.zoom + view_area.x , _
head->y*view_area.zoom + view_area.y), 2,C_WHITE,,,,F


end if
head = head->next_p
wend
Expand Down Expand Up @@ -644,7 +661,11 @@ sub keyboard_listener( input_mode as proto_input_mode ptr, _
reset_key_status(@key(i))
'delete all
case SC_DELETE
*input_mode = input_erase_polygon
if *input_mode = input_selection then
*input_mode = input_erase_polygon
elseif *input_mode = input_direct_selection then
*input_mode = input_delete_node
end if
view_area->refresh = true
reset_key_status(@key(i))
'show / hide vertices
Expand Down Expand Up @@ -674,6 +695,39 @@ sub keyboard_listener( input_mode as proto_input_mode ptr, _
*input_mode = input_create_random_polygons
end if
reset_key_status(@key(i))
'direct selection
case SC_A
*input_mode = input_direct_selection
reset_key_status(@key(i))

case SC_UP
'direct selection - node selected + UP key
if *input_mode = input_direct_selection then
*input_mode = input_move_node_up
end if
reset_key_status(@key(i))

case SC_DOWN
'direct selection - node selected + DOWN key
if *input_mode = input_direct_selection then
*input_mode = input_move_node_down
end if
reset_key_status(@key(i))

case SC_LEFT
'direct selection - node selected + LEFT key
if *input_mode = input_direct_selection then
*input_mode = input_move_node_left
end if
reset_key_status(@key(i))

case SC_RIGHT
'direct selection - node selected + RIGHT key
if *input_mode = input_direct_selection then
*input_mode = input_move_node_right
end if
reset_key_status(@key(i))

end select


Expand Down Expand Up @@ -719,6 +773,26 @@ Sub delete_all_points (head as point_proto ptr)
wend
end sub

sub mark_selected_nodes ( x1 as integer, y1 as integer, _
x2 as integer, y2 as integer, _
array() as polygon_proto)
dim i as integer
dim head as point_proto ptr

for i = 0 to Ubound(array)-1
head = array(i).first_point
while head->next_p <> NULL
if head->x > x1 and head->y > y1 and _
head->x < x2 and head->y < y2 then

head->is_selected = true
end if

head = head->next_p
wend
next i
end sub

sub mouse_listener(user_mouse as mouse_proto ptr, view_area as view_area_proto ptr)
static old_is_lbtn_pressed as boolean = false
static old_is_rbtn_pressed as boolean = false
Expand Down Expand Up @@ -947,6 +1021,7 @@ sub reset_key_status (key as key_proto ptr)
key->old_is_down = false
end sub


Sub draw_wireframe( head as point_proto ptr, ByVal c As ULong, _
view_area as view_area_proto, _
settings as settings_proto, _
Expand Down Expand Up @@ -1429,3 +1504,81 @@ sub draw_mouse_pointer ( x as integer, y as integer, _
put (x-12, y), icon_set(icon), trans

end sub

sub unmark_all_nodes (array() as polygon_proto)

dim i as integer
dim head as point_proto ptr

for i = 0 to Ubound(array)-1
head = array(i).first_point
while head->next_p <> NULL
head->is_selected = false
head = head->next_p
wend
next i

end sub

sub move_selected_node(x_offset as integer, y_offset as integer, array() as polygon_proto)

dim i as integer
dim head as point_proto ptr


for i = 0 to Ubound(array)-1
head = array(i).first_point
while head->next_p <> NULL
if head->is_selected then
head->x += x_offset
head->y += y_offset

end if
head = head->next_p
'compute again the centroid of the modified polygon
array(i).centroid = calculate_centroid(array(i).first_point)
wend
next i


end sub

function delete_selected_node (node as point_proto ptr) as point_proto ptr

if (node = NULL) then ' Found the tail
return NULL

elseif (node->is_selected = true) then

dim next_node as point_proto ptr
' Found one to delete
next_node = node->next_p

deallocate(node)

return next_node
else
' Just keep going
node->next_p = delete_selected_node(node->next_p)
return node
end if

end function

function count_selected_nodes (head as point_proto ptr) as integer

dim i as integer
i = 0

while head <> NULL
if (head->next_p <> NULL) then
if head->is_selected then
i+=1
end if
end if
head = head->next_p
wend

return i

end function
Loading

0 comments on commit 4195a8e

Please sign in to comment.