code reorganization

git-svn-id: svn://kolibrios.org@6046 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-01-09 19:39:34 +00:00
parent 8181cb284f
commit ea730a853f
3 changed files with 692 additions and 747 deletions

View File

@ -13,9 +13,7 @@ include 'lang.inc'
include 'info_fun_float.inc'
include 'info_menu.inc'
offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc'
debug equ 0
version_edit equ 1
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
@ -29,6 +27,16 @@ struct FileInfoBlock
FileName dd ?
ends
ID_ICON_CHUNK_MAIN equ 0 ;¨ª®­ª  £« ¢­®£® ¡«®ª 
ID_ICON_CHUNK_NOT_FOUND equ 1 ;¨ª®­ª  ­¥ ¨§¢¥áâ­®£® ¡«®ª 
ID_ICON_DATA equ 2 ;¨ª®­ª  ¤«ï ¤ ­­ëå ¡«®ª , ­¥ ®¯à¥¤¥«¥­­®© áâàãªâãàë
ID_ICON_POINT equ 8
ID_ICON_POINT_SEL equ 9
FILE_ERROR_CHUNK_SIZE equ -3 ;®è¨¡ª  ¢ à §¬¥à¥ ¡«®ª 
include 'info_o3d.inc'
align 4
fl255 dd 255.0
image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì, ­ã¦¥­ ¤«ï ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
@ -93,14 +101,6 @@ include 'data.inc'
level_stack dd 0
offs_last_timer dd 0 ;¯®á«¥¤­¨© ᤢ¨£ ¯®ª § ­ë© ¢ ä㭪樨 â ©¬¥à 
ID_ICON_CHUNK_MAIN equ 0 ;¨ª®­ª  £« ¢­®£® ¡«®ª 
ID_ICON_CHUNK_NOT_FOUND equ 1 ;¨ª®­ª  ­¥ ¨§¢¥áâ­®£® ¡«®ª 
ID_ICON_DATA equ 2 ;¨ª®­ª  ¤«ï ¤ ­­ëå ¡«®ª , ­¥ ®¯à¥¤¥«¥­­®© áâàãªâãàë
ID_ICON_POINT equ 8
ID_ICON_POINT_SEL equ 9
FILE_ERROR_CHUNK_SIZE equ -3 ;®è¨¡ª  ¢ à §¬¥à¥ ¡«®ª 
align 4
file_3ds: ;¯¥à¥¬¥­­ë¥ ¨á¯®«ì§ã¥¬ë¥ ¯à¨ ®âªàë⨨ ä ©« 
.offs: dd 0 ;+0 㪠§ â¥«ì ­  ­ ç «® ¡«®ª 
@ -591,7 +591,7 @@ but_open_file:
mov byte[can_save],0
call init_tree
stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
call prop_wnd_clear_param ;ç¨á⨬ ¯ à ¬¥âàë ®ª­  á ª®®à¤¨­ â ¬¨
stdcall obj_clear_param, o3d ;ç¨á⨬ ¯ à ¬¥âàë ®ª­  á ª®®à¤¨­ â ¬¨
cmp byte[prop_wnd_run],0
je @f
;ç¨á⨬ ®ª­® á ª®®à¤¨­ â ¬¨
@ -713,7 +713,7 @@ block_analiz_data:
shl eax,3
add esi,2
sub ecx,2
stdcall add_3ds_object, ID_ICON_DATA,ebx,eax,0 ;¤ ­­ë¥ ¢¥à設
stdcall add_3ds_object, ID_ICON_DATA,ebx,eax,0 ;¤ ­­ë¥ £à ­¥©
sub ecx,eax
cmp ecx,1
@ -886,46 +886,10 @@ proc add_3ds_object, icon:dword,level:dword,size_bl:dword,info_bl:dword
.no_capt:
stdcall [tl_node_add], tree1, ebx, buffer
stdcall [tl_cur_next], tree1
if debug
stdcall print_err,sz_add_3ds_object,buffer+list_offs_text
end if
popad
ret
endp
if debug
sz_add_3ds_object db 13,10,'3ds_object',0
align 4
proc print_err, fun:dword, mes:dword ;¢ë¢®¤¨¬ á®®¡é¥­¨¥ ®¡ 訡ª¥ ­  ¤®áªã ®â« ¤ª¨
pushad
mov eax,63
mov ebx,1
mov esi,[fun]
@@:
mov cl,byte[esi]
int 0x40
inc esi
cmp byte[esi],0
jne @b
mov cl,':'
int 0x40
mov cl,' '
int 0x40
mov esi,[mes]
@@:
mov cl,byte[esi]
int 0x40
inc esi
cmp byte[esi],0
jne @b
popad
ret
endp
end if
;input:
; eax - value
; buf - string buffer
@ -1079,77 +1043,6 @@ but_delete_chunk:
popad
ret
;input:
; buf - 㪠§ â¥«ì ­  áâபã, ç¨á«® ¤®«¦­® ¡ëâì ¢ 10 ¨«¨ 16 à¨ç­®¬ ¢¨¤¥
;output:
; eax - ç¨á«®
align 4
proc conv_str_to_int uses ebx ecx esi, buf:dword
xor eax,eax
xor ebx,ebx
mov esi,[buf]
;®¯à¥¤¥«¥­¨¥ ®âà¨æ â¥«ì­ëå ç¨á¥«
xor ecx,ecx
inc ecx
cmp byte[esi],'-'
jne @f
dec ecx
inc esi
@@:
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
@@:
cmp ecx,0 ;¥á«¨ ç¨á«® ®âà¨æ â¥«ì­®¥
jne @f
sub ecx,eax
mov eax,ecx
@@:
ret
endp
;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
align 4
OpenDialog_data:
@ -1491,7 +1384,7 @@ dd 0,0
aini_get_color db 'ini_get_color',0
align 4
mouse_dd dd 0x0
mouse_dd dd 0
last_time dd 0
align 4
@ -1542,9 +1435,9 @@ white_light dd 0.8, 0.8, 0.8, 1.0 ;
lmodel_ambient dd 0.3, 0.3, 0.3, 1.0 ; <20> à ¬¥âàë ä®­®¢®£® ®á¢¥é¥­¨ï
if lang eq ru
capt db 'info 3ds ¢¥àá¨ï 01.01.16',0 ;¯®¤¯¨áì ®ª­ 
capt db 'info 3ds ¢¥àá¨ï 09.01.16',0 ;¯®¤¯¨áì ®ª­ 
else
capt db 'info 3ds version 01.01.16',0 ;window caption
capt db 'info 3ds version 09.01.16',0 ;window caption
end if
align 16
@ -1563,6 +1456,8 @@ i_end:
color_vert rd 1
color_face rd 1
color_select rd 1
obj_poi_sel_c rd 1
o3d obj_3d
rb 2048
align 16
thread_coords:

View File

@ -0,0 +1,652 @@
;
; áâàãªâãàë ¨ ä㭪樨 ¤«ï à¨á®¢ ­¨ï 3d ®¡ê¥ªâ®¢
;
offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc'
struct obj_3d
poi_data dd ? ;㪠§ â¥«ì ­  ª®®à¤¨­ âë ¢¥à設
poi_count dd ? ;ª®««¨ç¥á⢮ ¢¥à設
tri_data dd ? ;㪠§ â¥«ì ­  ¤ ­­ë¥ âà¥ã£®«ì­¨ª®¢
tri_count dd ? ;ª®««¨ç¥á⢮ âà¥ã£®«ì­¨ª®¢
normals_poi_data dd ? ;¤ ­­ë¥ ­®à¬ «¥© ª â®çª ¬
normals_poi_count dd ? ;ª®««¨ç¥á⢮ ­®à¬ «¥© ª â®çª ¬
normals_tri_data dd ? ;¤ ­­ë¥ ­®à¬ «¥© ª £à ­ï¬
normals_tri_count dd ? ;ª®««¨ç¥á⢮ ­®à¬ «¥© ª £à ­ï¬
x_max dd ?
x_min dd ?
x_centr dd ?
x_scale dd ?
y_max dd ?
y_min dd ?
y_centr dd ?
y_scale dd ?
z_max dd ?
z_min dd ?
z_centr dd ?
z_scale dd ?
ends
offs_obj_poi_data equ 0 ;㪠§ â¥«ì ­  ª®®à¤¨­ âë ¢¥à設
offs_obj_poi_count equ 4 ;ª®««¨ç¥á⢮ ¢¥à設
offs_obj_tri_data equ 8 ;㪠§ â¥«ì ­  ¤ ­­ë¥ âà¥ã£®«ì­¨ª®¢
offs_obj_tri_count equ 12 ;ª®««¨ç¥á⢮ âà¥ã£®«ì­¨ª®¢
offs_obj_normals_poi_data equ 16
offs_obj_normals_poi_count equ 20
offs_obj_normals_tri_data equ 24
offs_obj_normals_tri_count equ 28
offs_obj_x_max equ 32
offs_obj_x_min equ 36
offs_obj_x_centr equ 40
offs_obj_x_scale equ 44
offs_obj_y_max equ 48
offs_obj_y_min equ 52
offs_obj_y_centr equ 56
offs_obj_y_scale equ 60
offs_obj_z_max equ 64
offs_obj_z_min equ 68
offs_obj_z_centr equ 72
offs_obj_z_scale equ 76
bit_vertexes equ 0
bit_faces equ 1
bit_faces_fill equ 2
bit_light equ 3
ini_name db 'info3ds.ini',0
ini_sec_w3d db 'Window 3d',0
key_dv db 'draw_vertices',0
key_df db 'draw_faces',0
key_dff db 'draw_faces_fill',0
key_dl db 'draw_light',0
key_ox db 'col_ox',0
key_oy db 'col_oy',0
key_oz db 'col_oz',0
key_bk db 'col_bkgnd',0
key_vert db 'col_vertices',0
key_face db 'col_faces',0
key_select db 'col_select',0
rad_c dd 150 ;¤«ï ¢ëç¨á«¥­¨ï à ¤¨ãá 
;ãáâ ­®¢ª  ¢á¥å ®á­®¢­ëå ¯¥à¥¬¥­­ëå ¯® 㬮«ç ­¨î
align 4
proc obj_clear_param uses edi, o_data:dword
mov edi,[o_data]
;®¡­ã«¥­¨¥ 㪠§ â¥«¥© ­  ¤ ­­ë¥ ®¡ê¥ªâ®¢
mov dword[edi+offs_obj_poi_data],0
mov dword[edi+offs_obj_poi_count],0
mov dword[edi+offs_obj_tri_data],0
mov dword[edi+offs_obj_tri_count],0
mov dword[edi+offs_obj_normals_tri_count],0
mov dword[edi+offs_obj_normals_poi_count],0
stdcall mem.Free,[edi+offs_obj_normals_tri_data]
stdcall mem.Free,[edi+offs_obj_normals_poi_data]
mov dword[edi+offs_obj_normals_tri_data],0
mov dword[edi+offs_obj_normals_poi_data],0
;ãáâ ­®¢ª  ¯ à ¬¥â஢ ®â®¡à ¦¥­¨ï
call mnu_reset_settings
ret
endp
;¯®¨áª ¤ ­­ëå
;input:
;eax - ⥪ã騩 㧥«
;output:
;eax - áâàãªâãà  â¥ªã饣® 㧫  (¨«¨ 0 ¯à¨ ­¥ã¤ ç¥)
align 4
proc found_block_data uses ebx ecx edx, tlist:dword
mov edx,[tlist]
mov ecx,eax
stdcall [tl_node_poi_get_info], edx,0
@@:
mov ebx,eax
stdcall [tl_node_poi_get_data], edx,ebx
cmp eax,ecx
je @f ;¥á«¨ ¯®¯ «¨ ­  ¢ë¡à ­­ë© 㧥«
stdcall [tl_node_poi_get_next_info], edx,ebx
cmp eax,0
jne @b
jmp .end
@@:
mov eax,ebx
.end:
ret
endp
;ãáâ ­®¢ª  à §¬¥à®¢ ®¡ê¥ªâ 
align 4
proc obj_set_sizes uses eax ebx esi edi, o_data:dword
mov edi,[o_data]
cmp dword[edi+offs_obj_poi_count],0
je .end
finit
mov eax,[edi+offs_obj_poi_data]
mov ebx,dword[eax]
mov [edi+offs_obj_x_min],ebx
mov [edi+offs_obj_x_max],ebx
mov ebx,dword[eax+4]
mov [edi+offs_obj_y_min],ebx
mov [edi+offs_obj_y_max],ebx
mov ebx,dword[eax+8]
mov [edi+offs_obj_z_min],ebx
mov [edi+offs_obj_z_max],ebx
mov ebx,[edi+offs_obj_poi_data]
mov esi,[edi+offs_obj_poi_count]
align 4
.cycle_0: ;à ¡®â  á ª®®à¤¨­ â®© x
fld dword[ebx]
fld dword[edi+offs_obj_x_min]
fcomp
fstsw ax
sahf
jb @f
mov eax,[ebx]
mov [edi+offs_obj_x_min],eax
ffree st0
fincstp
jmp .next_x
@@:
fld dword[edi+offs_obj_x_max]
fcompp
fstsw ax
sahf
ja .next_x
mov eax,[ebx]
mov [edi+offs_obj_x_max],eax
.next_x:
add ebx,12
dec esi
jnz .cycle_0
fld1
fld dword[edi+offs_obj_x_max]
fsub dword[edi+offs_obj_x_min]
fst dword[edi+offs_obj_x_centr]
fdivp ;1/size.x
fstp dword[edi+offs_obj_x_scale]
fld dword[edi+offs_obj_x_centr]
fld1
fld1
faddp
fdivp ;centr.x = size.x/2
fadd dword[edi+offs_obj_x_min]
fchs
fstp dword[edi+offs_obj_x_centr]
mov ebx,[edi+offs_obj_poi_data]
mov esi,[edi+offs_obj_poi_count]
align 4
.cycle_1: ;à ¡®â  á ª®®à¤¨­ â®© y
fld dword[ebx+4]
fld dword[edi+offs_obj_y_min]
fcomp
fstsw ax
sahf
jb @f
mov eax,[ebx+4]
mov [edi+offs_obj_y_min],eax
ffree st0
fincstp
jmp .next_y
@@:
fld dword[edi+offs_obj_y_max]
fcompp
fstsw ax
sahf
ja .next_y
mov eax,[ebx+4]
mov [edi+offs_obj_y_max],eax
.next_y:
add ebx,12
dec esi
jnz .cycle_1
fld1
fld dword[edi+offs_obj_y_max]
fsub dword[edi+offs_obj_y_min]
fst dword[edi+offs_obj_y_centr]
fdivp ;1/size.y
fstp dword[edi+offs_obj_y_scale]
fld dword[edi+offs_obj_y_centr]
fld1
fld1
faddp
fdivp ;centr.y = size.y/2
fadd dword[edi+offs_obj_y_min]
fchs
fstp dword[edi+offs_obj_y_centr]
mov ebx,[edi+offs_obj_poi_data]
mov esi,[edi+offs_obj_poi_count]
align 4
.cycle_2: ;à ¡®â  á ª®®à¤¨­ â®© z
fld dword[ebx+8]
fld dword[edi+offs_obj_z_min]
fcomp
fstsw ax
sahf
jb @f
mov eax,[ebx+8]
mov [edi+offs_obj_z_min],eax
ffree st0
fincstp
jmp .next_z
@@:
fld dword[edi+offs_obj_z_max]
fcompp
fstsw ax
sahf
ja .next_z
mov eax,[ebx+8]
mov [edi+offs_obj_z_max],eax
.next_z:
add ebx,12
dec esi
jnz .cycle_2
fld1
fld dword[edi+offs_obj_z_max]
fsub dword[edi+offs_obj_z_min]
fst dword[edi+offs_obj_z_centr]
fdivp ;1/size.z
fstp dword[edi+offs_obj_z_scale]
fld dword[edi+offs_obj_z_centr]
fld1
fld1
faddp
fdivp ;centr.z = size.z/2
fadd dword[edi+offs_obj_z_min]
fchs
fstp dword[edi+offs_obj_z_centr]
;­ å®¤¨¬ à ¤¨ãá ¤«ï áä¥àë
fld dword[edi+offs_obj_x_max]
fsub dword[edi+offs_obj_x_min]
fld dword[edi+offs_obj_y_max]
fsub dword[edi+offs_obj_y_min]
faddp
fild dword[rad_c]
fdivp ;radius=(size.x+size.y)/rad_c
fstp dword[sph_radius]
;¤¥« ¥¬ ®¤¨­ ª®¢ë© ¬ áèâ ¡ ¯® ®áï¬ x ¨ y, çâ®-¡ë ­¥ ­ àãè «¨áì ¯à®¯®à樨 ¨§®¡à ¦¥­¨ï
fld dword[edi+offs_obj_y_scale]
fdiv dword[ratio] ;¯à¨¢¥¤¥­¨¥ ¬ áèâ ¡  ¯® ®á¨ y ãç¨â뢠ï çâ® ¯® ¢ëá®â¥ íªà ­ ¬¥­ìè¥
fcomp dword[edi+offs_obj_x_scale]
fstsw ax
sahf
jb @f
;ᦠ⨥ ¬ áèâ ¡  ¯® y
fld dword[edi+offs_obj_x_scale]
fmul dword[ratio]
fstp dword[edi+offs_obj_y_scale] ;¬ áèâ ¡ ¯® ®á¨ y = ¬ áèâ ¡ ¯® ®á¨ x
jmp .end
@@:
;ᦠ⨥ ¬ áèâ ¡  ¯® x >...<
fld dword[edi+offs_obj_x_scale]
fdiv dword[ratio]
fstp dword[edi+offs_obj_x_scale]
.end:
ret
endp
;ãáâ ­®¢ª  ­®à¬ «¥© ¤«ï £à ­¥©
align 4
proc obj_set_normals, o_data:dword
locals
tbl1 rd 9 ;ebp-72
tbl2 rd 9 ;ebp-36
endl
pushad
mov ecx,[o_data]
cmp dword[ecx+offs_obj_poi_count],0
je .end
mov eax,[ecx+offs_obj_tri_count]
mov [ecx+offs_obj_normals_tri_count],eax ;­  ª ¦¤ë© âà¥ã£®«ì­¨ª 1 ­®à¬ «ì
cmp eax,0
je .end
finit
imul eax,12
stdcall mem.Alloc, eax
mov [ecx+offs_obj_normals_tri_data],eax
mov edx,[ecx+offs_obj_tri_data]
mov ebx,[ecx+offs_obj_tri_count]
mov ecx,[ecx+offs_obj_poi_data]
align 4
@@:
mov edi,ebp
sub edi,36 ;tbl2
movzx esi,word[edx] ;1-ï ¢¥à設 
imul esi,12
add esi,ecx
movsd
movsd
movsd
movzx esi,word[edx+2] ;2-ï ¢¥à設 
imul esi,12
add esi,ecx
movsd
movsd
movsd
movzx esi,word[edx+4] ;3-ï ¢¥à設 
imul esi,12
add esi,ecx
movsd
movsd
movsd
mov esi,ebp
sub esi,72 ;tbl1
sub edi,36 ;tbl2
;v1 <-> v2
fld dword[edi+12]
fsub dword[edi]
fstp dword[esi] ;(x1-x2)
fld dword[edi+16]
fsub dword[edi+4]
fstp dword[esi+4] ;(y1-y2)
fld dword[edi+20]
fsub dword[edi+8]
fstp dword[esi+8] ;(z1-z2)
;v2 <-> v3
fld dword[edi+24]
fsub dword[edi+12]
fstp dword[esi+12] ;(x2-x3)
fld dword[edi+28]
fsub dword[edi+16]
fstp dword[esi+16] ;(y2-y3)
fld dword[edi+32]
fsub dword[edi+20]
fstp dword[esi+20] ;(z2-z3)
;v3 <-> v1
fld dword[edi]
fsub dword[edi+24]
fstp dword[esi+24] ;(x3-x1)
fld dword[edi+4]
fsub dword[edi+28]
fstp dword[esi+28] ;(y3-y1)
fld dword[edi+8]
fsub dword[edi+32]
fstp dword[esi+32] ;(z3-z1)
;a1,a2,a3
fld dword[esi+4]
fmul dword[esi+8]
fstp dword[edi] ;a1=(y1-y2)*(z1-z2)
fld dword[esi+16]
fmul dword[esi+20]
fstp dword[edi+4] ;a2=(y2-y3)*(z2-z3)
fld dword[esi+28]
fmul dword[esi+32]
fstp dword[edi+8] ;a3=(y3-y1)*(z3-z1)
;b1,b2,b3
fld dword[esi]
fmul dword[esi+8]
fstp dword[edi+12] ;b1=(x1-x2)*(z1-z2)
fld dword[esi+12]
fmul dword[esi+20]
fstp dword[edi+16] ;b2=(x2-x3)*(z2-z3)
fld dword[esi+24]
fmul dword[esi+32]
fstp dword[edi+20] ;b3=(x3-x1)*(z3-z1)
;c1,á2,á3
fld dword[esi]
fmul dword[esi+4]
fstp dword[edi+24] ;c1=(x1-x2)*(y1-y2)
fld dword[esi+12]
fmul dword[esi+16]
fstp dword[edi+28] ;c2=(x2-x3)*(y2-y3)
fld dword[esi+24]
fmul dword[esi+28]
fstp dword[edi+32] ;c3=(x3-x1)*(y3-y1)
fld dword[edi]
fadd dword[edi+4]
fadd dword[edi+8]
fstp dword[eax] ;set normal.a
fld dword[edi+12]
fadd dword[edi+16]
fadd dword[edi+20]
fstp dword[eax+4] ;set normal.b
fld dword[edi+24]
fadd dword[edi+28]
fadd dword[edi+32]
fstp dword[eax+8] ;set normal.c
add edx,8 ;à §¬¥à âà¥ã£®«ì­¨ª  = (3 ¢¥à設ë (¯® 2¡) + ᢮©á⢠ (2¡))
add eax,12
dec ebx
jnz @b
.end:
popad
ret
endp
;à¨á®¢ ­¨¥ â®ç¥ª ¢ 3d
align 4
proc draw_3d uses eax ebx ecx edi, o_data:dword
mov edi,[o_data]
cmp dword[edi+offs_obj_poi_count],2
jl .end_f
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;®ç¨á⨬ ¡ãä¥à æ¢¥â  ¨ £«ã¡¨­ë
stdcall [glPushMatrix]
bt dword[draw_mode],bit_light
jnc @f
call SetLight
jmp .end_l
@@:
stdcall [glDisable],GL_LIGHTING
.end_l:
stdcall [glTranslatef], 0.0,0.0,0.5 ;correct for z
stdcall [glScalef], [edi+offs_obj_x_scale],[edi+offs_obj_y_scale],[edi+offs_obj_z_scale]
stdcall [glScalef], 1.0,1.0,0.7 ;correct for z
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
stdcall [glRotatef], [angle_y],0.0,1.0,0.0
stdcall [glRotatef], [angle_x],1.0,0.0,0.0
stdcall [glTranslatef], [edi+offs_obj_x_centr],[edi+offs_obj_y_centr],[edi+offs_obj_z_centr]
;à¨á®¢ ­¨¥ â®ç¥ª
bt dword[draw_mode],bit_vertexes
jnc .end_points
stdcall [glColor3ub],[color_vert+2],[color_vert+1],[color_vert]
stdcall [glBegin],GL_POINTS
mov eax,[edi+offs_obj_poi_data]
mov ebx,[edi+offs_obj_poi_count]
@@:
stdcall [glVertex3f], [eax],[eax+4],[eax+8]
add eax,12
dec ebx
jnz @b
stdcall [glEnd]
.end_points:
if version_edit eq 1
;à¨á®¢ ­¨¥  ªâ¨¢­®© â®çª¨
stdcall [tl_node_get_data],tree3
cmp eax,0
je @f
;¢ë¤¥«¥­¨¥  ªâ¨¢­®© â®çª¨
mov eax,[eax]
stdcall [glBegin],GL_LINES
stdcall [glColor3ub], [color_ox+2],[color_ox+1],[color_ox]
stdcall [glVertex3f], [edi+offs_obj_x_min],[eax+4],[eax+8]
stdcall [glVertex3f], [edi+offs_obj_x_max],[eax+4],[eax+8]
stdcall [glColor3ub], [color_oy+2],[color_oy+1],[color_oy]
stdcall [glVertex3f], [eax],[edi+offs_obj_y_min],[eax+8]
stdcall [glVertex3f], [eax],[edi+offs_obj_y_max],[eax+8]
stdcall [glColor3ub], [color_oz+2],[color_oz+1],[color_oz]
stdcall [glVertex3f], [eax],[eax+4],[edi+offs_obj_z_min]
stdcall [glVertex3f], [eax],[eax+4],[edi+offs_obj_z_max]
stdcall [glEnd]
stdcall [glColor3ub],[color_select+2],[color_select+1],[color_select]
stdcall [glPushMatrix]
stdcall [glTranslatef], [eax],[eax+4],[eax+8]
stdcall [gluSphere], [qObj], [sph_radius], 8,8
stdcall [glPopMatrix]
@@:
;à¨á®¢ ­¨¥ ¢ë¤¥«¥­­ëå â®ç¥ª
cmp dword[obj_poi_sel_c],0
je .end_select
mov ecx,dword[obj_poi_sel_c]
stdcall [glColor3ub],[color_select+2],[color_select+1],[color_select]
stdcall dword[tl_node_poi_get_info], tree3,0
@@:
cmp eax,0
je .end_select
mov ebx,eax
cmp word[ebx],ID_ICON_POINT_SEL
jne .next_sel
stdcall [tl_node_poi_get_data], tree3,ebx
mov eax,[eax]
stdcall [glPushMatrix]
stdcall [glTranslatef], [eax],[eax+4],[eax+8]
stdcall [gluSphere], [qObj], [sph_radius], 4,4
stdcall [glPopMatrix]
dec ecx
jz .end_select
.next_sel:
stdcall dword[tl_node_poi_get_next_info], tree3,ebx
jmp @b
.end_select:
end if
;à¨á®¢ ­¨¥ £à ­¥©
bt dword[draw_mode],bit_faces
jnc .end_triangles
cmp dword[edi+offs_obj_tri_count],0
je .end_triangles
cmp dword[edi+offs_obj_poi_count],0
je .end_triangles
bt dword[draw_mode],bit_faces_fill
jc @f
push GL_LINE
jmp .end_0
@@:
push GL_FILL
.end_0:
stdcall [glPolygonMode], GL_FRONT_AND_BACK ;mode - 㦥 ¢ á⥪¥
stdcall [glColor3ub],[color_face+2],[color_face+1],[color_face]
stdcall [glBegin],GL_TRIANGLES
mov eax,[edi+offs_obj_tri_data]
mov ecx,[edi+offs_obj_tri_count]
mov edx,[edi+offs_obj_normals_tri_data]
@@:
;
bt dword[draw_mode],bit_light
jnc .norm
;[obj_normals_tri_count]
stdcall [glNormal3fv], edx
add edx,12
.norm:
;
movzx ebx,word[eax] ;1-ï ¢¥à設 
imul ebx,12
add ebx,[edi+offs_obj_poi_data]
stdcall [glVertex3f], [ebx],[ebx+4],[ebx+8]
movzx ebx,word[eax+2] ;2-ï ¢¥à設 
imul ebx,12
add ebx,[edi+offs_obj_poi_data]
stdcall [glVertex3f], [ebx],[ebx+4],[ebx+8]
movzx ebx,word[eax+4] ;3-ï ¢¥à設 
imul ebx,12
add ebx,[edi+offs_obj_poi_data]
stdcall [glVertex3f], [ebx],[ebx+4],[ebx+8]
add eax,8 ;à §¬¥à âà¥ã£®«ì­¨ª  = (3 ¢¥à設ë (¯® 2¡) + ᢮©á⢠ (2¡))
dec ecx
jnz @b
stdcall [glEnd]
.end_triangles:
stdcall [glPopMatrix]
if version_edit eq 1
cmp dword[obj_poi_sel_c],0
je @f
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_select_vert,5,3,[color_select]
@@:
end if
stdcall [kosglSwapBuffers]
.end_f:
ret
endp
align 4
SetLight:
stdcall [glLightfv], GL_LIGHT0, GL_POSITION, light_position
stdcall [glLightfv], GL_LIGHT0, GL_SPOT_DIRECTION, light_dir
stdcall [glLightfv], GL_LIGHT0, GL_DIFFUSE, white_light
stdcall [glLightfv], GL_LIGHT0, GL_SPECULAR, white_light
stdcall [glEnable], GL_COLOR_MATERIAL
stdcall [glColorMaterial], GL_FRONT, GL_AMBIENT_AND_DIFFUSE
stdcall [glMaterialfv], GL_FRONT, GL_SPECULAR, mat_specular
stdcall [glMaterialf], GL_FRONT, GL_SHININESS, mat_shininess
stdcall [glLightModelfv], GL_LIGHT_MODEL_AMBIENT, lmodel_ambient
stdcall [glEnable],GL_LIGHTING
stdcall [glEnable],GL_LIGHT0
ret
;¨§¬¥­ï¥¬ ०¨¬ à¨á®¢ ­¨ï ¢¥à設
align 4
mnu_vertexes_on_off:
xor dword[draw_mode], 1 shl bit_vertexes
stdcall draw_3d, o3d
ret
;¨§¬¥­ï¥¬ ०¨¬ à¨á®¢ ­¨ï £à ­¥©
align 4
mnu_faces_on_off:
xor dword[draw_mode], 1 shl bit_faces
stdcall draw_3d, o3d
ret
;¨§¬¥­ï¥¬ ª àª á­ë¥ ¨«¨ ᯫ®è­ë¥ £à ­¨
align 4
mnu_faces_fill_on_off:
xor dword[draw_mode], 1 shl bit_faces_fill
or dword[draw_mode], 1 shl bit_faces ;¢ª«îç ¥¬ ०¨¬ à¨á®¢ ­¨ï £à ­¥© (¥á«¨ ¢¤à㣠¡ë« ®âª«î祭)
stdcall draw_3d, o3d
ret
;¢ª«îç ¥¬ ¨«¨ ®âª«îç ¥¬ ®á¢¥é¥­¨¥
align 4
mnu_light_on_off:
xor dword[draw_mode], 1 shl bit_light
stdcall draw_3d, o3d
ret
align 4
mnu_reset_settings:
mov dword[angle_x],0.0
mov dword[angle_y],0.0
mov dword[angle_z],0.0
m2m dword[draw_mode],dword[def_dr_mode]
stdcall draw_3d, o3d
ret
align 4
draw_mode dd 0 ;०¨¬ à¨á®¢ ­¨ï ®¡ê¥ªâ 
def_dr_mode dd 0 ;०¨¬ à¨á®¢ ­¨ï ¯® 㬮«ç ­¨î
delt_size dd 3.0 ;¨§¬¥­¥­¨¥ 㣫®¢ ¯à¨ ¯®¢®à®â å á ª«¨¢¨ âãàë
mouse_drag dd 0 ;०¨¬ ¯®¢®à®â  áæ¥­ë ®â ¯¥à¥¬¥é¥­¨¨ ªãàá®à  ¬ëè¨
mouse_x dd 0
mouse_y dd 0
sph_radius dd 0 ;à ¤¨ãá áä¥àë ¤«ï ¢ë¤¥«¥­¨ï  ªâ¨¢­®© â®çª¨

View File

@ -12,25 +12,6 @@ prop_wnd_height equ 460 ;
SIZE_ONE_FLOAT equ 14
MAX_OBJECT_SIZE equ (4+SIZE_ONE_FLOAT*3+1)
bit_vertexes equ 0
bit_faces equ 1
bit_faces_fill equ 2
bit_light equ 3
ini_name db 'info3ds.ini',0
ini_sec_w3d db 'Window 3d',0
key_dv db 'draw_vertices',0
key_df db 'draw_faces',0
key_dff db 'draw_faces_fill',0
key_dl db 'draw_light',0
key_ox db 'col_ox',0
key_oy db 'col_oy',0
key_oz db 'col_oz',0
key_bk db 'col_bkgnd',0
key_vert db 'col_vertices',0
key_face db 'col_faces',0
key_select db 'col_select',0
prop_wnd_run db 0 ;¯¥à¥¬¥­­ ï á«¥¤ïé ï §  ⥬ çâ®-¡ë ­¥ § ¯ã᪠âì ¡®«ìè¥ 1-£® ®ª­  ᮠ᢮©á⢠¬¨ ®¤­®¢à¥¬¥­­®
txt_q db '?',0
@ -39,8 +20,6 @@ txt_space:
.end:
db 0
rad_c dd 150 ;¤«ï ¢ëç¨á«¥­¨ï à ¤¨ãá 
obj_point: ;¤®¡ ¢«ï¥¬ë© ®¡ê¥ªâ
dd 0 ;㪠§ â¥«ì
.text:
@ -61,7 +40,8 @@ pushad
mcall 40,0x27 ;¬ áª  ®¦¨¤ ¥¬ëå ᮡë⨩
inc byte[prop_wnd_run]
mov dword[w_scr_t3.type],1
call prop_wnd_clear_param
mov edi,o3d
stdcall obj_clear_param, edi
stdcall [tl_node_get_data],tree1
xor edx,edx
@ -148,9 +128,9 @@ pushad
cmp word[eax],CHUNK_FACELIST
jne .cycle_2
movzx ecx,word[eax+6]
mov [obj_tri_count],ecx
mov [edi+offs_obj_tri_count],ecx
add eax,8 ;2+4+2 (chunk+size+count)
mov [obj_tri_data],eax
mov [edi+offs_obj_tri_data],eax
jmp .set_points
.end_vlist:
cmp word[ebx],CHUNK_TRACKPIVOT
@ -168,8 +148,8 @@ pushad
;jmp .set_points
@@:
.set_points:
mov [obj_poi_data],ebx
mov [obj_poi_count],edx
mov [edi+offs_obj_poi_data],ebx
mov [edi+offs_obj_poi_count],edx
.no_points:
;­ áâனª  ᯨ᪠ ®¡ê¥ªâ®¢
@ -212,8 +192,8 @@ pushad
jg .new_point
stdcall dword[tl_cur_beg], tree3
.no_object:
call obj_set_sizes
call obj_set_normals
stdcall obj_set_sizes, o3d
stdcall obj_set_normals, o3d
edit_boxes_set_sys_color edit1,editboxes_end,sc ;ãáâ ­®¢ª  á¨á⥬­ëå 梥⮢
stdcall [edit_box_set_text], edit1, txt_q
stdcall [edit_box_set_text], edit2, txt_q
@ -317,529 +297,11 @@ pushad
stdcall [edit_box_draw], edit3
stdcall [kmainmenu_draw], [main_menu]
call draw_3d
stdcall draw_3d, o3d
mcall 12,2
popad
ret
;ãáâ ­®¢ª  ¢á¥å ®á­®¢­ëå ¯¥à¥¬¥­­ëå ¯® 㬮«ç ­¨î
align 4
prop_wnd_clear_param:
;ãáâ ­®¢ª  ¯ à ¬¥â஢ ®â®¡à ¦¥­¨ï
call mnu_reset_settings
;®¡­ã«¥­¨¥ 㪠§ â¥«¥© ­  ¤ ­­ë¥ ®¡ê¥ªâ®¢
mov dword[obj_poi_data],0
mov dword[obj_poi_count],0
mov dword[obj_poi_sel_c],0
mov dword[obj_tri_data],0
mov dword[obj_tri_count],0
mov dword[obj_normals_tri_count],0
mov dword[obj_normals_poi_count],0
stdcall mem.Free,[obj_normals_tri_data]
stdcall mem.Free,[obj_normals_poi_data]
mov dword[obj_normals_tri_data],0
mov dword[obj_normals_poi_data],0
ret
;¯®¨áª ¤ ­­ëå
;input:
;eax - ⥪ã騩 㧥«
;output:
;eax - áâàãªâãà  â¥ªã饣® 㧫  (¨«¨ 0 ¯à¨ ­¥ã¤ ç¥)
align 4
proc found_block_data uses ebx ecx edx, tlist:dword
mov edx,[tlist]
mov ecx,eax
stdcall [tl_node_poi_get_info], edx,0
@@:
mov ebx,eax
stdcall [tl_node_poi_get_data], edx,ebx
cmp eax,ecx
je @f ;¥á«¨ ¯®¯ «¨ ­  ¢ë¡à ­­ë© 㧥«
stdcall [tl_node_poi_get_next_info], edx,ebx
cmp eax,0
jne @b
jmp .end
@@:
mov eax,ebx
.end:
ret
endp
;ãáâ ­®¢ª  à §¬¥à®¢ ®¡ê¥ªâ 
align 4
proc obj_set_sizes uses eax ebx esi
cmp dword[obj_poi_count],0
je .end
finit
mov eax,[obj_poi_data]
mov ebx,dword[eax]
mov [obj_x_min],ebx
mov [obj_x_max],ebx
mov ebx,dword[eax+4]
mov [obj_y_min],ebx
mov [obj_y_max],ebx
mov ebx,dword[eax+8]
mov [obj_z_min],ebx
mov [obj_z_max],ebx
mov ebx,[obj_poi_data]
mov esi,[obj_poi_count]
align 4
.cycle_0: ;à ¡®â  á ª®®à¤¨­ â®© x
fld dword[ebx]
fld dword[obj_x_min]
fcomp
fstsw ax
sahf
jb @f
mov eax,[ebx]
mov [obj_x_min],eax
ffree st0
fincstp
jmp .next_x
@@:
fld dword[obj_x_max]
fcompp
fstsw ax
sahf
ja .next_x
mov eax,[ebx]
mov [obj_x_max],eax
.next_x:
add ebx,12
dec esi
jnz .cycle_0
fld1
fld dword[obj_x_max]
fsub dword[obj_x_min]
fst dword[obj_x_centr]
fdivp ;1/size.x
fstp dword[obj_x_scale]
fld dword[obj_x_centr]
fld1
fld1
faddp
fdivp ;centr.x = size.x/2
fadd dword[obj_x_min]
fchs
fstp dword[obj_x_centr]
mov ebx,[obj_poi_data]
mov esi,[obj_poi_count]
align 4
.cycle_1: ;à ¡®â  á ª®®à¤¨­ â®© y
fld dword[ebx+4]
fld dword[obj_y_min]
fcomp
fstsw ax
sahf
jb @f
mov eax,[ebx+4]
mov [obj_y_min],eax
ffree st0
fincstp
jmp .next_y
@@:
fld dword[obj_y_max]
fcompp
fstsw ax
sahf
ja .next_y
mov eax,[ebx+4]
mov [obj_y_max],eax
.next_y:
add ebx,12
dec esi
jnz .cycle_1
fld1
fld dword[obj_y_max]
fsub dword[obj_y_min]
fst dword[obj_y_centr]
fdivp ;1/size.y
fstp dword[obj_y_scale]
fld dword[obj_y_centr]
fld1
fld1
faddp
fdivp ;centr.y = size.y/2
fadd dword[obj_y_min]
fchs
fstp dword[obj_y_centr]
mov ebx,[obj_poi_data]
mov esi,[obj_poi_count]
align 4
.cycle_2: ;à ¡®â  á ª®®à¤¨­ â®© z
fld dword[ebx+8]
fld dword[obj_z_min]
fcomp
fstsw ax
sahf
jb @f
mov eax,[ebx+8]
mov [obj_z_min],eax
ffree st0
fincstp
jmp .next_z
@@:
fld dword[obj_z_max]
fcompp
fstsw ax
sahf
ja .next_z
mov eax,[ebx+8]
mov [obj_z_max],eax
.next_z:
add ebx,12
dec esi
jnz .cycle_2
fld1
fld dword[obj_z_max]
fsub dword[obj_z_min]
fst dword[obj_z_centr]
fdivp ;1/size.z
fstp dword[obj_z_scale]
fld dword[obj_z_centr]
fld1
fld1
faddp
fdivp ;centr.z = size.z/2
fadd dword[obj_z_min]
fchs
fstp dword[obj_z_centr]
;­ å®¤¨¬ à ¤¨ãá ¤«ï áä¥àë
fld dword[obj_x_max]
fsub dword[obj_x_min]
fld dword[obj_y_max]
fsub dword[obj_y_min]
faddp
fild dword[rad_c]
fdivp ;radius=(size.x+size.y)/rad_c
fstp dword[sph_radius]
;¤¥« ¥¬ ®¤¨­ ª®¢ë© ¬ áèâ ¡ ¯® ®áï¬ x ¨ y, çâ®-¡ë ­¥ ­ àãè «¨áì ¯à®¯®à樨 ¨§®¡à ¦¥­¨ï
fld dword[obj_y_scale]
fdiv dword[ratio] ;¯à¨¢¥¤¥­¨¥ ¬ áèâ ¡  ¯® ®á¨ y ãç¨â뢠ï çâ® ¯® ¢ëá®â¥ íªà ­ ¬¥­ìè¥
fcomp dword[obj_x_scale]
fstsw ax
sahf
jb @f
;ᦠ⨥ ¬ áèâ ¡  ¯® y
fld dword[obj_x_scale]
fmul dword[ratio]
fstp dword[obj_y_scale] ;¬ áèâ ¡ ¯® ®á¨ y = ¬ áèâ ¡ ¯® ®á¨ x
jmp .end
@@:
;ᦠ⨥ ¬ áèâ ¡  ¯® x >...<
fld dword[obj_x_scale]
fdiv dword[ratio]
fstp dword[obj_x_scale]
.end:
ret
endp
;ãáâ ­®¢ª  ­®à¬ «¥© ¤«ï £à ­¥©
align 4
proc obj_set_normals
locals
tbl1 rd 9 ;ebp-72
tbl2 rd 9 ;ebp-36
endl
pushad
cmp dword[obj_poi_count],0
je .end
finit
mov ecx,[obj_tri_count]
mov [obj_normals_tri_count],ecx ;­  ª ¦¤ë© âà¥ã£®«ì­¨ª 1 ­ à¬ «ì
cmp ecx,0
je .end
imul ecx,12
stdcall mem.Alloc, ecx
mov [obj_normals_tri_data],eax
mov edx,[obj_tri_data]
mov ebx,[obj_tri_count]
align 4
@@:
mov edi,ebp
sub edi,36 ;tbl2
movzx esi,word[edx] ;1-ï ¢¥à設 
imul esi,12
add esi,[obj_poi_data]
mov ecx,3
rep movsd
movzx esi,word[edx+2] ;2-ï ¢¥à設 
imul esi,12
add esi,[obj_poi_data]
mov ecx,3
rep movsd
movzx esi,word[edx+4] ;3-ï ¢¥à設 
imul esi,12
add esi,[obj_poi_data]
mov ecx,3
rep movsd
mov esi,ebp
sub esi,72 ;tbl1
sub edi,36 ;tbl2
;v1 <-> v2
fld dword[edi+12]
fsub dword[edi]
fstp dword[esi] ;(x1-x2)
fld dword[edi+16]
fsub dword[edi+4]
fstp dword[esi+4] ;(y1-y2)
fld dword[edi+20]
fsub dword[edi+8]
fstp dword[esi+8] ;(z1-z2)
;v2 <-> v3
fld dword[edi+24]
fsub dword[edi+12]
fstp dword[esi+12] ;(x2-x3)
fld dword[edi+28]
fsub dword[edi+16]
fstp dword[esi+16] ;(y2-y3)
fld dword[edi+32]
fsub dword[edi+20]
fstp dword[esi+20] ;(z2-z3)
;v3 <-> v1
fld dword[edi]
fsub dword[edi+24]
fstp dword[esi+24] ;(x3-x1)
fld dword[edi+4]
fsub dword[edi+28]
fstp dword[esi+28] ;(y3-y1)
fld dword[edi+8]
fsub dword[edi+32]
fstp dword[esi+32] ;(z3-z1)
;a1,a2,a3
fld dword[esi+4]
fmul dword[esi+8]
fstp dword[edi] ;a1=(y1-y2)*(z1-z2)
fld dword[esi+16]
fmul dword[esi+20]
fstp dword[edi+4] ;a2=(y2-y3)*(z2-z3)
fld dword[esi+28]
fmul dword[esi+32]
fstp dword[edi+8] ;a3=(y3-y1)*(z3-z1)
;b1,b2,b3
fld dword[esi]
fmul dword[esi+8]
fstp dword[edi] ;b1=(x1-x2)*(z1-z2)
fld dword[esi+12]
fmul dword[esi+20]
fstp dword[edi+4] ;b2=(x2-x3)*(z2-z3)
fld dword[esi+24]
fmul dword[esi+32]
fstp dword[edi+8] ;b3=(x3-x1)*(z3-z1)
;c1,á2,á3
fld dword[esi]
fmul dword[esi+4]
fstp dword[edi] ;c1=(x1-x2)*(y1-y2)
fld dword[esi+12]
fmul dword[esi+16]
fstp dword[edi+4] ;c2=(x2-x3)*(y2-y3)
fld dword[esi+24]
fmul dword[esi+28]
fstp dword[edi+8] ;c3=(x3-x1)*(y3-y1)
fld dword[edi]
fadd dword[edi+4]
fadd dword[edi+8]
fstp dword[eax] ;set normal.a
fld dword[edi+12]
fadd dword[edi+16]
fadd dword[edi+20]
fstp dword[eax+4] ;set normal.b
fld dword[edi+24]
fadd dword[edi+28]
fadd dword[edi+32]
fstp dword[eax+8] ;set normal.c
add edx,8 ;à §¬¥à âà¥ã£®«ì­¨ª  = (3 ¢¥à設ë (¯® 2¡) + ᢮©á⢠ (2¡))
add eax,12
dec ebx
jnz @b
.end:
popad
ret
endp
;à¨á®¢ ­¨¥ â®ç¥ª ¢ 3d
align 4
draw_3d:
cmp dword[obj_poi_count],2
jl .end_f
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;®ç¨á⨬ ¡ãä¥à æ¢¥â  ¨ £«ã¡¨­ë
stdcall [glPushMatrix]
bt dword[draw_mode],bit_light
jnc @f
call SetLight
jmp .end_l
@@:
stdcall [glDisable],GL_LIGHTING
.end_l:
stdcall [glTranslatef], 0.0,0.0,0.5 ;correct for z
stdcall [glScalef], [obj_x_scale],[obj_y_scale],[obj_z_scale]
stdcall [glScalef], 1.0,1.0,0.7 ;correct for z
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
stdcall [glRotatef], [angle_y],0.0,1.0,0.0
stdcall [glRotatef], [angle_x],1.0,0.0,0.0
stdcall [glTranslatef], [obj_x_centr],[obj_y_centr],[obj_z_centr]
;à¨á®¢ ­¨¥ â®ç¥ª
bt dword[draw_mode],bit_vertexes
jnc .end_points
stdcall [glColor3ub],[color_vert+2],[color_vert+1],[color_vert]
stdcall [glBegin],GL_POINTS
mov eax,[obj_poi_data]
mov ebx,[obj_poi_count]
@@:
stdcall [glVertex3f], [eax],[eax+4],[eax+8]
add eax,12
dec ebx
jnz @b
stdcall [glEnd]
.end_points:
;à¨á®¢ ­¨¥  ªâ¨¢­®© â®çª¨
stdcall [tl_node_get_data],tree3
cmp eax,0
je @f
;¢ë¤¥«¥­¨¥  ªâ¨¢­®© â®çª¨
mov eax,[eax]
stdcall [glBegin],GL_LINES
stdcall [glColor3ub],[color_ox+2],[color_ox+1],[color_ox]
stdcall [glVertex3f], [obj_x_min],[eax+4],[eax+8]
stdcall [glVertex3f], [obj_x_max],[eax+4],[eax+8]
stdcall [glColor3ub],[color_oy+2],[color_oy+1],[color_oy]
stdcall [glVertex3f], [eax],[obj_y_min],[eax+8]
stdcall [glVertex3f], [eax],[obj_y_max],[eax+8]
stdcall [glColor3ub],[color_oz+2],[color_oz+1],[color_oz]
stdcall [glVertex3f], [eax],[eax+4],[obj_z_min]
stdcall [glVertex3f], [eax],[eax+4],[obj_z_max]
stdcall [glEnd]
stdcall [glColor3ub],[color_select+2],[color_select+1],[color_select]
stdcall [glPushMatrix]
stdcall [glTranslatef], [eax],[eax+4],[eax+8]
stdcall [gluSphere], [qObj], [sph_radius], 8,8
stdcall [glPopMatrix]
@@:
;à¨á®¢ ­¨¥ ¢ë¤¥«¥­­ëå â®ç¥ª
cmp dword[obj_poi_sel_c],0
je .end_select
mov ecx,dword[obj_poi_sel_c]
stdcall [glColor3ub],[color_select+2],[color_select+1],[color_select]
stdcall dword[tl_node_poi_get_info], tree3,0
@@:
cmp eax,0
je .end_select
mov ebx,eax
cmp word[ebx],ID_ICON_POINT_SEL
jne .next_sel
stdcall [tl_node_poi_get_data], tree3,ebx
mov eax,[eax]
stdcall [glPushMatrix]
stdcall [glTranslatef], [eax],[eax+4],[eax+8]
stdcall [gluSphere], [qObj], [sph_radius], 4,4
stdcall [glPopMatrix]
dec ecx
jz .end_select
.next_sel:
stdcall dword[tl_node_poi_get_next_info], tree3,ebx
jmp @b
.end_select:
;à¨á®¢ ­¨¥ £à ­¥©
bt dword[draw_mode],bit_faces
jnc .end_triangles
cmp dword[obj_tri_count],0
je .end_triangles
cmp dword[obj_poi_count],0
je .end_triangles
bt dword[draw_mode],bit_faces_fill
jc @f
push GL_LINE
jmp .end_0
@@:
push GL_FILL
.end_0:
stdcall [glPolygonMode], GL_FRONT_AND_BACK ;mode - 㦥 ¢ á⥪¥
stdcall [glColor3ub],[color_face+2],[color_face+1],[color_face]
stdcall [glBegin],GL_TRIANGLES
mov eax,[obj_tri_data]
mov ecx,[obj_tri_count]
mov edx,[obj_normals_tri_data]
@@:
;
bt dword[draw_mode],bit_light
jnc .norm
;[obj_normals_tri_count]
stdcall [glNormal3fv], edx
add edx,12
.norm:
;
movzx ebx,word[eax] ;1-ï ¢¥à設 
imul ebx,12
add ebx,[obj_poi_data]
stdcall [glVertex3f], [ebx],[ebx+4],[ebx+8]
movzx ebx,word[eax+2] ;2-ï ¢¥à設 
imul ebx,12
add ebx,[obj_poi_data]
stdcall [glVertex3f], [ebx],[ebx+4],[ebx+8]
movzx ebx,word[eax+4] ;3-ï ¢¥à設 
imul ebx,12
add ebx,[obj_poi_data]
stdcall [glVertex3f], [ebx],[ebx+4],[ebx+8]
add eax,8 ;à §¬¥à âà¥ã£®«ì­¨ª  = (3 ¢¥à設ë (¯® 2¡) + ᢮©á⢠ (2¡))
dec ecx
jnz @b
stdcall [glEnd]
.end_triangles:
stdcall [glPopMatrix]
cmp dword[obj_poi_sel_c],0
je @f
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_select_vert,5,3,[color_select]
@@:
stdcall [kosglSwapBuffers]
.end_f:
ret
align 4
SetLight:
stdcall [glLightfv], GL_LIGHT0, GL_POSITION, light_position
stdcall [glLightfv], GL_LIGHT0, GL_SPOT_DIRECTION, light_dir
stdcall [glLightfv], GL_LIGHT0, GL_DIFFUSE, white_light
stdcall [glLightfv], GL_LIGHT0, GL_SPECULAR, white_light
stdcall [glEnable], GL_COLOR_MATERIAL
stdcall [glColorMaterial], GL_FRONT, GL_AMBIENT_AND_DIFFUSE
stdcall [glMaterialfv], GL_FRONT, GL_SPECULAR, mat_specular
stdcall [glMaterialf], GL_FRONT, GL_SHININESS, mat_shininess
stdcall [glLightModelfv], GL_LIGHT_MODEL_AMBIENT, lmodel_ambient
stdcall [glEnable],GL_LIGHTING
stdcall [glEnable],GL_LIGHT0
ret
align 4
proc prop_key uses eax ebx
mcall 2
@ -870,7 +332,7 @@ proc prop_key uses eax ebx
fld dword[angle_x]
fadd dword[delt_size]
fstp dword[angle_x]
call draw_3d
stdcall draw_3d, o3d
jmp .end
@@:
cmp ah,177 ;Down
@ -878,7 +340,7 @@ proc prop_key uses eax ebx
fld dword[angle_x]
fsub dword[delt_size]
fstp dword[angle_x]
call draw_3d
stdcall draw_3d, o3d
jmp .end
@@:
cmp ah,176 ;Left
@ -886,7 +348,7 @@ proc prop_key uses eax ebx
fld dword[angle_y]
fadd dword[delt_size]
fstp dword[angle_y]
call draw_3d
stdcall draw_3d, o3d
jmp .end
@@:
cmp ah,179 ;Right
@ -894,7 +356,7 @@ proc prop_key uses eax ebx
fld dword[angle_y]
fsub dword[delt_size]
fstp dword[angle_y]
call draw_3d
stdcall draw_3d, o3d
;jmp .end
@@:
.end:
@ -947,7 +409,7 @@ prop_mouse:
fadd dword[angle_y]
fstp dword[angle_y]
call draw_3d
stdcall draw_3d, o3d
jmp .end_d
.end_m:
bt eax,16
@ -993,7 +455,7 @@ prop_button:
cmp ah,3
jne @f
call get_point_coords
call draw_3d
stdcall draw_3d, o3d
jmp prop_still.end
@@:
cmp ah,4
@ -1058,7 +520,7 @@ prop_button:
stdcall dword[tl_draw], tree3
mov byte[can_save],1 ;¤«ï ¯®ª §  ª­®¯ª¨ '‘®åà ­¨âì'
mov dword[offs_last_timer],0 ;¤«ï ®¡­®¢«¥­¨ï ¡«®ª  ¢ â ©¬¥à¥
call draw_3d
stdcall draw_3d, o3d
.no_select_1:
pop esi edi ecx ebx eax
jmp prop_still.end
@ -1120,10 +582,11 @@ prop_button:
mov dword[tree3.data_img],0 ;ç¨á⨬ 㪠§ â¥«¨ ­  ¨ª®­ª¨ çâ®-¡ë ¨å ­¥ 㤠«¨« ¤¥áâàãªâ®à
mov dword[tree3.data_img_sys],0 ;â. ª. ®­¨ ¥é¥ ¨á¯®«ì§ãîâìáï ¢ ¤à㣨å í«¥¬¥­â å
stdcall dword[tl_data_clear], tree3
stdcall mem.Free,[obj_normals_tri_data]
stdcall mem.Free,[obj_normals_poi_data]
mov dword[obj_normals_tri_data],0
mov dword[obj_normals_poi_data],0
mov edi,o3d
stdcall mem.Free,[edi+offs_obj_normals_tri_data]
stdcall mem.Free,[edi+offs_obj_normals_poi_data]
mov dword[edi+offs_obj_normals_tri_data],0
mov dword[edi+offs_obj_normals_poi_data],0
mov byte[prop_wnd_run],0 ;®¡­ã«ï¥¬ áç¥â稪 ®ª®­
mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
@ -1163,44 +626,11 @@ proc prop_timer_funct uses eax
cmp [cursor_last_draw],eax
je @f
mov [cursor_last_draw],eax
call draw_3d
stdcall draw_3d, o3d
@@:
ret
endp
;¨§¬¥­ï¥¬ ०¨¬ à¨á®¢ ­¨ï ¢¥à設
align 4
mnu_vertexes_on_off:
xor dword[draw_mode], 1 shl bit_vertexes
ret
;¨§¬¥­ï¥¬ ०¨¬ à¨á®¢ ­¨ï £à ­¥©
align 4
mnu_faces_on_off:
xor dword[draw_mode], 1 shl bit_faces
ret
;¨§¬¥­ï¥¬ ª àª á­ë¥ ¨«¨ ᯫ®è­ë¥ £à ­¨
align 4
mnu_faces_fill_on_off:
xor dword[draw_mode], 1 shl bit_faces_fill
or dword[draw_mode], 1 shl bit_faces ;¢ª«îç ¥¬ ०¨¬ à¨á®¢ ­¨ï £à ­¥© (¥á«¨ ¢¤à㣠¡ë« ®âª«î祭)
ret
;¢ª«îç ¥¬ ¨«¨ ®âª«îç ¥¬ ®á¢¥é¥­¨¥
align 4
mnu_light_on_off:
xor dword[draw_mode], 1 shl bit_light
ret
align 4
mnu_reset_settings:
mov dword[angle_x],0.0
mov dword[angle_y],0.0
mov dword[angle_z],0.0
m2m dword[draw_mode],dword[def_dr_mode]
ret
align 4
proc mnu_vertexes_select uses eax ebx
stdcall [tl_node_get_data],tree3
@ -1427,42 +857,10 @@ popad
endp
align 4
def_dr_mode dd 0 ;०¨¬ à¨á®¢ ­¨ï ¯® 㬮«ç ­¨î
delt_size dd 3.0 ;¨§¬¥­¥­¨¥ 㣫®¢ ¯à¨ ¯®¢®à®â å á ª«¨¢¨ âãàë
mouse_drag dd 0 ;०¨¬ ¯®¢®à®â  áæ¥­ë ®â ¯¥à¥¬¥é¥­¨¨ ªãàá®à  ¬ëè¨
mouse_x dd 0
mouse_y dd 0
angle_dxm dd 1.7775 ;~ 3d_wnd_w/180 - ¯à¨¡ ¢«¥­¨¥ 㣫®¢ ¯®¢®à®â  áæ¥­ë ¯à¨ ¢à é¥­¨¨ ¬ë襩
angle_dym dd 1.3335 ;~ 3d_wnd_h/180
ratio dd 1.3333 ;~ 3d_wnd_w/3d_wnd_h
;angle_dzm dd ?
draw_mode dd 0 ;०¨¬ à¨á®¢ ­¨ï ®¡ê¥ªâ 
obj_poi_data dd 0 ;㪠§ â¥«ì ­  ª®®à¤¨­ âë ¢¥à設
obj_poi_count dd 0 ;ª®««¨ç¥á⢮ ¢¥à設
obj_poi_sel_c dd 0 ;ª®««¨ç¥á⢮ ¢ë¤¥«¥­­ëå ¢¥à設
obj_tri_data dd 0 ;㪠§ â¥«ì ­  ¤ ­­ë¥ âà¥ã£®«ì­¨ª®¢
obj_tri_count dd 0 ;ª®««¨ç¥á⢮ âà¥ã£®«ì­¨ª®¢
cursor_last_draw dd 0 ;¯®«®¦¥­¨¥ ªãàá®à  ¯à¨ ¯®á«¥¤­¥© ¯à®à¨á®¢ª¥ 3d ®ª­ 
sph_radius dd 0 ;à ¤¨ãá áä¥àë ¤«ï ¢ë¤¥«¥­¨ï  ªâ¨¢­®© â®çª¨
obj_normals_poi_data dd 0
obj_normals_poi_count dd 0
obj_normals_tri_data dd 0
obj_normals_tri_count dd 0
obj_x_max dd 0
obj_x_min dd 0
obj_x_centr dd 0
obj_x_scale dd 1.0
obj_y_max dd 0
obj_y_min dd 0
obj_y_centr dd 0
obj_y_scale dd 1.0
obj_z_max dd 0
obj_z_min dd 0
obj_z_centr dd 0
obj_z_scale dd 1.0
capt_p dd 0
;¤¥à¥¢® á ®¡ê¥ªâ ¬¨ ¢ ¯®«ì§®¢ â¥«ì᪮¬ ä ©«¥