update utilite 'vox_tgl'

git-svn-id: svn://kolibrios.org@5393 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2015-02-11 14:28:00 +00:00
parent 454f3da10c
commit 5b6cfd44a0
4 changed files with 111 additions and 106 deletions

Binary file not shown.

View File

@ -2,6 +2,13 @@
; Ôóíêöèè íóæíûå äëÿ îòîáðàæåíèÿ âîêñåëüíîãî îáúåêòà ÷åðåç áèáëèîòåêó tinygl
;
normal_gran_z1 equ -1.0
normal_gran_z0 equ 1.0
normal_gran_y1 equ -1.0
normal_gran_y0 equ 1.0
normal_gran_x1 equ -1.0
normal_gran_x0 equ 1.0
;ìàðîñ êîðåêòèðîâêè âåêòîðà íîðìàëè äëÿ çàêðóãëåíèÿ êðàéíèõ âîêñåëåé
macro normal_gran param, gran
{
@ -573,9 +580,8 @@ align 4
;coord x
fild dword[eax+vox_ogl_x0]
fscale
fchs
fst dword[eax+vox_ogl_x0]
fsub st0,st2 ;äîáàâëÿåì êî âòîðîé òî÷êå ðàçìåð ìàñøòàáèðîâàííîé êóáè÷åñêîé ãðàíè
fadd st0,st2 ;äîáàâëÿåì êî âòîðîé òî÷êå ðàçìåð ìàñøòàáèðîâàííîé êóáè÷åñêîé ãðàíè
fstp dword[eax+vox_ogl_x1]
;coord y
fild dword[eax+vox_ogl_y0]
@ -610,10 +616,10 @@ align 4
@@:
;coord x
fld dword[eax+vox_ogl_x0]
fadd st0,st1 ;+0.5
fsub st0,st1 ;-0.5
fstp dword[eax+vox_ogl_x0]
fld dword[eax+vox_ogl_x1]
fadd st0,st1 ;+0.5
fsub st0,st1 ;-0.5
fstp dword[eax+vox_ogl_x1]
;coord y
fld dword[eax+vox_ogl_y0]
@ -1304,12 +1310,6 @@ proc vox_corect_coords_pl, v_obj:dword, v_size:dword
ret
endp
normal_gran_z1 equ -1.0
normal_gran_z0 equ 1.0
normal_gran_y1 equ 1.0
normal_gran_y0 equ -1.0
normal_gran_x1 equ -1.0
normal_gran_x0 equ 1.0
align 4
p1 dd ?
p2 dd ?

View File

@ -18,7 +18,7 @@ include 'vox_3d.inc'
include '../trunk/str.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db 'Voxel viewer 29.01.15',0 ;¯®¤¯¨áì ®ª­ 
caption db 'Voxel viewer 11.02.15',0 ;¯®¤¯¨áì ®ª­ 
struct FileInfoBlock
Function dd ?
@ -34,7 +34,7 @@ run_file_70 FileInfoBlock
image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì. ¤«ï ­ã¦¥­ ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*9
IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*10
image_data_toolbar dd 0
offs_zbuf_pbuf equ 24
@ -95,7 +95,10 @@ start:
stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à 
load_image_file 'toolbar_t.png', image_data_toolbar,IMAGE_TOOLBAR_SIZE
load_image_file 'toolbar_t.png', image_data_toolbar,IMAGE_TOOLBAR_SIZE*2 ;*2 for gray icons
mov eax,[image_data_toolbar]
add eax,IMAGE_TOOLBAR_SIZE
stdcall img_to_gray, [image_data_toolbar],eax,(IMAGE_TOOLBAR_SIZE)/3
mcall 26,9
mov [last_time],eax
@ -198,6 +201,18 @@ pushad
mov edx,12
int 0x40
call draw_toolbar_i
stdcall [buf2d_draw], buf_0
stdcall [kosglSwapBuffers]
mcall 12,2
popad
ret
align 4
draw_toolbar_i:
; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
mov edx,(7 shl 16)+7 ;icon new
mcall 7,[image_data_toolbar],(16 shl 16)+16
@ -215,27 +230,49 @@ pushad
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;zoom -
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
cmp word[opt_light],0
jne @f
add ebx,IMAGE_TOOLBAR_SIZE ;make gray icon
@@:
add edx,(25 shl 16) ;light on/off
int 0x40
cmp word[opt_light],0
jne @f
sub ebx,IMAGE_TOOLBAR_SIZE
@@:
add ebx,IMAGE_TOOLBAR_ICON_SIZE
cmp word[opt_cube_box],0
jne @f
add ebx,IMAGE_TOOLBAR_SIZE ;make gray icon
@@:
add edx,(25 shl 16) ;box on/off
int 0x40
cmp word[opt_cube_box],0
jne @f
sub ebx,IMAGE_TOOLBAR_SIZE
@@:
add ebx,IMAGE_TOOLBAR_ICON_SIZE
cmp word[opt_auto_rotate],0
jne @f
add ebx,IMAGE_TOOLBAR_SIZE ;make gray icon
@@:
add edx,(25 shl 16) ;auto rotate on/off
int 0x40
cmp word[opt_auto_rotate],0
jne @f
sub ebx,IMAGE_TOOLBAR_SIZE
@@:
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;info voxels
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;refresh
int 0x40
stdcall [buf2d_draw], buf_0
stdcall [kosglSwapBuffers]
mcall 12,2
popad
ret
@ -245,33 +282,33 @@ key:
cmp ah,178 ;Up
jne @f
fld dword[angle_z]
fld dword[angle_x]
fadd dword[delt_size]
fstp dword[angle_z]
fstp dword[angle_x]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
cmp ah,177 ;Down
jne @f
fld dword[angle_z]
fld dword[angle_x]
fsub dword[delt_size]
fstp dword[angle_z]
fstp dword[angle_x]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
cmp ah,176 ;Left
jne @f
fld dword[angle_x]
fld dword[angle_y]
fadd dword[delt_size]
fstp dword[angle_x]
fstp dword[angle_y]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
cmp ah,179 ;Right
jne @f
fld dword[angle_x]
fld dword[angle_y]
fsub dword[delt_size]
fstp dword[angle_x]
fstp dword[angle_y]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
@ -320,7 +357,7 @@ button:
@@:
cmp ah,12
jne @f
call but_7
call but_draw_cadr
@@:
cmp ah,1
jne still
@ -334,9 +371,9 @@ button:
align 4
but_new_file:
mov dword[angle_x], 0.0
mov [angle_y], 0.0
mov [angle_z], 180.0
mov dword[angle_x], 30.0
mov dword[angle_y], 180.0
mov dword[angle_z], 180.0
ret
align 4
@ -474,7 +511,7 @@ draw_cadr_8:
ret
align 4
rot_angles dd 0,45,90,135,180,225,270,315
rot_angles dd 180,225,270,315,0,45,90,135
align 4
draw_cadr:
@ -554,7 +591,7 @@ proc but_zoom_m uses eax
endp
align 4
proc but_3 uses eax
proc but_3 uses eax ebx ecx edx
xor word[opt_light],1
cmp word[opt_light],0
je @f
@ -565,22 +602,25 @@ proc but_3 uses eax
stdcall [glDisable], GL_LIGHTING
stdcall [glDisable], GL_LIGHT0
.end_light:
call draw_toolbar_i
call draw_3d
stdcall [kosglSwapBuffers]
ret
endp
align 4
proc but_4 uses eax
proc but_4 uses eax ebx ecx edx
xor word[opt_cube_box],1
call draw_toolbar_i
call draw_3d
stdcall [kosglSwapBuffers]
ret
endp
align 4
proc but_5 uses eax
proc but_5 uses eax ebx ecx edx
xor word[opt_auto_rotate],1
call draw_toolbar_i
ret
endp
@ -647,8 +687,19 @@ txt_stat_m2:
.v: rb 20
align 4
proc but_7 uses eax
proc but_draw_cadr uses eax ebx ecx edx
mov ebx,[angle_x]
mov ecx,[angle_y]
mov edx,[angle_z]
call draw_cadr_8
mov [angle_x],ebx
mov [angle_y],ecx
mov [angle_z],edx
cmp word[opt_auto_rotate],0
jne @f
call draw_3d
;stdcall [kosglSwapBuffers]
@@:
ret
endp
@ -666,8 +717,8 @@ draw_3d:
;­® ¢á¥ ¦¥ ¯à¨ ¯®¢®à®â å ¡ã¤ãâ ®âᥪ âáï ªà ï, ª®â®àë¥ ¢ë«¥§ãâ §  ¯à¥¤¥«ë ¯«®áª®á⥩ ®âá¥ç¥­¨ï
;¢ ¢¥àᨨ opengl ¯®¤ Win ª®®à¤¨­ âë ¨¤ãâ ®â -1.0 ¤® 1.0 ¯®â®¬ã â ¬ í⮣® ¤¥« âì ­¥ ­ã¦­®
stdcall [glScalef], [scale], [scale], [scale] ;㢥«¨ç¨¢ ¥¬ ¢®ªá¥«ì­ë© ®¡ê¥ªâ, çâ®-¡ë ­¥ ¡ë« ®ç¥­ì ¬ «¥­ìª¨¬
stdcall [glRotatef], [angle_y],0.0,1.0,0.0
stdcall [glRotatef], [angle_x],1.0,0.0,0.0
stdcall [glRotatef], [angle_y],0.0,1.0,0.0
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
stdcall draw_voxels_3d,[open_file_ogl]
@ -695,79 +746,33 @@ proc SetLight
ret
endp
;input:
; buf - 㪠§ â¥«ì ­  áâபã, ç¨á«® ¤®«¦­® ¡ëâì ¢ 10 ¨«¨ 16 à¨ç­®¬ ¢¨¤¥
;output:
; eax - ç¨á«®
align 4
proc conv_str_to_int, buf:dword
xor eax,eax
push ebx ecx esi
xor ebx,ebx
mov esi,[buf]
;®¯à¥¤¥«¥­¨¥ ®âà¨æ â¥«ì­ëå ç¨á¥«
xor ecx,ecx
inc ecx
cmp byte[esi],'-'
jne @f
dec ecx
inc esi
proc img_to_gray, buf_rgb:dword, buf_g24:dword, pixels:dword
pushad
mov esi,[buf_rgb]
mov edi,[buf_g24]
mov ecx,[pixels]
mov ebx,3
align 4
@@:
cmp word[esi],'0x'
je .load_digit_16
.load_digit_10: ;áç¨â뢠­¨¥ 10-â¨ç­ëå æ¨äà
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'9'
jg @f
sub bl,'0'
imul eax,10
add eax,ebx
inc esi
jmp .load_digit_10
jmp @f
.load_digit_16: ;áç¨â뢠­¨¥ 16-à¨ç­ëå æ¨äà
add esi,2
.cycle_16:
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'f'
jg @f
cmp bl,'9'
jle .us1
cmp bl,'A'
jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'9' ¨ <'A'
.us1: ;á®áâ ¢­®¥ ãá«®¢¨¥
cmp bl,'F'
jle .us2
cmp bl,'a'
jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'F' ¨ <'a'
sub bl,32 ;¯¥à¥¢®¤¨¬ ᨬ¢®«ë ¢ ¢¥àå­¨© ॣ¨áâà, ¤«ï ã¯à®é¥­¨ï ¨å ¯®á«¥¤ã饩 ®¡à ¡®âª¨
.us2: ;á®áâ ¢­®¥ ãá«®¢¨¥
sub bl,'0'
cmp bl,9
jle .cor1
sub bl,7 ;convert 'A' to '10'
.cor1:
shl eax,4
add eax,ebx
inc esi
jmp .cycle_16
@@:
or ecx,ecx ;¥á«¨ ç¨á«® ®âà¨æ â¥«ì­®¥
jnz @f
neg eax
inc eax
@@:
pop esi ecx ebx
movzx eax,byte[esi]
movzx edx,byte[esi+1]
add eax,edx
movzx edx,byte[esi+2]
add eax,edx
xor edx,edx
div ebx ;shr eax,2
mov ah,al
mov word[edi],ax
mov byte[edi+2],al
add esi,3
add edi,3
loop @b
popad
ret
endp
;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
align 4
OpenDialog_data:
@ -1004,7 +1009,7 @@ delt_size dd 3.0
opt_light dw 0 ;®¯æ¨ï ¤«ï ¢ª«î祭¨ï/¢ëª«î祭¨ï ᢥâ 
opt_cube_box dw 1 ;®¯æ¨ï ¤«ï à¨á®¢ ­¨ï à ¬ª¨ ¢®ªà㣠®¡ê¥ªâ 
opt_auto_rotate dw 1 ;®¯æ¨ï ¤«ï  ¢â®¬ â¨ç¥áª®£® ¯®¢®à®â  ®¡ê¥ªâ 
opt_auto_rotate dw 0 ;®¯æ¨ï ¤«ï  ¢â®¬ â¨ç¥áª®£® ¯®¢®à®â  ®¡ê¥ªâ 
light_position dd 0.0, 0.0, 2.0, 1.0 ; <20> á¯®«®¦¥­¨¥ ¨áâ®ç­¨ª  [0][1][2]
;[3] = (0.0 - ¡¥áª®­¥ç­® 㤠«¥­­ë© ¨áâ®ç­¨ª, 1.0 - ¨áâ®ç­¨ª á¢¥â  ­  ®¯à¥¤¥«¥­­®¬ à ááâ®ï­¨¨)