info3ds_u: add new mode to view material colors

git-svn-id: svn://kolibrios.org@6509 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-09-02 09:26:04 +00:00
parent 35a72cec53
commit e643356bbc
3 changed files with 254 additions and 107 deletions

View File

@ -31,6 +31,12 @@ ID_ICON_POINT_SEL equ 9
FILE_ERROR_CHUNK_SIZE equ -3 ;®è¨¡ª  ¢ à §¬¥à¥ ¡«®ª 
size_one_list equ 42+sizeof.obj_3d
list_offs_chunk_del equ 8 ;¬®¦¥â «¨ ¡«®ª 㤠«ïâáï
list_offs_chunk_lev equ 9 ;ã஢¥­ì ¡«®ª  (¯à®¯¨á ­ ¢ ¤ ­­ë¥ 㧫 )
list_offs_p_data equ 10 ;㪠§ â¥«ì ­  ¯®¤¯¨áì ¡«®ª 
list_offs_obj3d equ 14 ;㪠§ â¥«ì ­  áâàãªâãàã ¤ ­­ëå ¤«ï 3d ®¡ê¥ªâ 
list_offs_text equ 14+sizeof.obj_3d ;ᤢ¨£ ­ ç «  ⥪áâ  ¢ «¨áâ¥
include 'info_o3d.inc'
align 4
@ -57,12 +63,6 @@ file_3ds: ;
.size: dd 0 ;+4 à §¬¥à ¡«®ª  (¤«ï 1-£® ¯ à ¬¥âà  = à §¬¥à ä ©«  3ds)
rb 8*MAX_FILE_LEVEL
size_one_list equ 42+sizeof.obj_3d
list_offs_chunk_del equ 8 ;¬®¦¥â «¨ ¡«®ª 㤠«ïâáï
list_offs_chunk_lev equ 9 ;ã஢¥­ì ¡«®ª  (¯à®¯¨á ­ ¢ ¤ ­­ë¥ 㧫 )
list_offs_p_data equ 10 ;㪠§ â¥«ì ­  ¯®¤¯¨áì ¡«®ª 
list_offs_obj3d equ 14 ;㪠§ â¥«ì ­  áâàãªâãàã ¤ ­­ëå ¤«ï 3d ®¡ê¥ªâ 
list_offs_text equ 14+sizeof.obj_3d ;ᤢ¨£ ­ ç «  ⥪áâ  ¢ «¨áâ¥
buffer rb size_one_list ;¡ãä¥à ¤«ï ¤®¡ ¢«¥­¨ï áâàãªâãà ¢ ᯨ᮪ tree1
txt_3ds_symb db 0,0
@ -113,11 +113,11 @@ start:
stdcall [ksubmenu_add], [main_menu_view], eax
stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Veiw_Faces_Fill, 7
stdcall [ksubmenu_add], [main_menu_view], eax
stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Veiw_Light, 8
stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Veiw_Light, 9
stdcall [ksubmenu_add], [main_menu_view], eax
stdcall [kmenuitem_new], KMENUITEM_SEPARATOR, 0, 0
stdcall [ksubmenu_add], [main_menu_view], eax
stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Veiw_Reset, 9
stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Veiw_Reset, 10
stdcall [ksubmenu_add], [main_menu_view], eax
stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_main_menu_View, [main_menu_view]
stdcall [ksubmenu_add], [main_menu], eax
@ -395,7 +395,7 @@ timer_funct:
stdcall draw_material,edi
jmp .end_f
.ini_mblo:
stdcall mat_init,edi ;¯®¯ë⪠ ­ áâநâì ¤ ­­ë¥ ¬ â¥à¨ « 
stdcall mat_init,edi,eax ;¯®¯ë⪠ ­ áâநâì ¤ ­­ë¥ ¬ â¥à¨ « 
cmp dword[edi+offs_mat_name],0
je .end_f
stdcall draw_material,edi
@ -438,25 +438,28 @@ pushad
mov esi,[sc.work_button]
mcall SF_DEFINE_BUTTON,(5 shl 16)+20,(24 shl 16)+20,0x40000003
mcall ,(30 shl 16)+20,,0x40000004 ;open
mcall ,(3d_wnd_l shl 16)+20,,0x40000005 ;¢¥àè¨­ë ¢ª«./¢ëª«.
mcall ,((3d_wnd_l+25) shl 16)+20,,0x40000006 ;£à ­¨ ¢ª«./¢ëª«.
mcall ,((3d_wnd_l+50) shl 16)+20,,0x40000007 ;§ «¨¢ª  £à ­¥© ¢ª«./¢ëª«.
mcall ,((3d_wnd_l+75) shl 16)+20,,0x40000008 ;ᢥ⠢ª«./¢ëª«.
mcall ,((3d_wnd_l+100) shl 16)+20,,0x40000009 ;á¡à®á
mcall ,(3d_wnd_l shl 16)+20,,0x40000005 ;¢¥àè¨­ë ¢ª«.
mcall ,((3d_wnd_l+25) shl 16)+20,,0x40000006 ;ª àª á­ë¥ £à ­¨ ¢ª«.
mcall ,((3d_wnd_l+50) shl 16)+20,,0x40000007 ;§ «¨¢ª  £à ­¥© ¢ª«.
mcall ,((3d_wnd_l+75) shl 16)+20,,0x40000008 ;£à ­¨ ¯® ¬ â¥à¨ « ¬ ¢ª«.
mcall ,((3d_wnd_l+100) shl 16)+20,,0x40000009 ;ᢥ⠢ª«./¢ëª«.
mcall ,((3d_wnd_l+125) shl 16)+20,,0x4000000a ;á¡à®á
mcall SF_PUT_IMAGE,[image_data_toolbar],(21 shl 16)+21,(5 shl 16)+24 ;new
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,(30 shl 16)+24 ;open
add ebx,IMAGE_TOOLBAR_ICON_SIZE*6
mcall ,,,((3d_wnd_l) shl 16)+24 ;¢¥àè¨­ë ¢ª«./¢ëª«.
mcall ,,,((3d_wnd_l) shl 16)+24 ;¢¥àè¨­ë ¢ª«.
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,((3d_wnd_l+25) shl 16)+24 ;£à ­¨ ¢ª«./¢ëª«.
mcall ,,,((3d_wnd_l+25) shl 16)+24 ;ª àª á­ë¥ £à ­¨ ¢ª«.
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,((3d_wnd_l+50) shl 16)+24 ;§ «¨¢ª  £à ­¥© ¢ª«./¢ëª«.
mcall ,,,((3d_wnd_l+50) shl 16)+24 ;§ «¨¢ª  £à ­¥© ¢ª«.
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,((3d_wnd_l+75) shl 16)+24 ;ᢥ⠢ª«./¢ëª«.
mcall ,,,((3d_wnd_l+100) shl 16)+24 ;ᢥ⠢ª«./¢ëª«.
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,((3d_wnd_l+100) shl 16)+24 ;á¡à®á
mcall ,,,((3d_wnd_l+125) shl 16)+24 ;á¡à®á
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,((3d_wnd_l+75) shl 16)+24 ;£à ­¨ ¯® ¬ â¥à¨ « ¬ ¢ª«.
mov dword[w_scr_t1.all_redraw],1
stdcall [tl_draw], tree1
@ -561,10 +564,15 @@ button:
@@:
cmp ah,8
jne @f
call mnu_light_on_off
call mnu_faces_mat
jmp still
@@:
cmp ah,9
jne @f
call mnu_light_on_off
jmp still
@@:
cmp ah,10
jne @f
call mnu_reset_settings
jmp still
@ -1397,9 +1405,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 [user] ¢¥àá¨ï 18.02.16',0 ;¯®¤¯¨áì ®ª­ 
capt db 'info 3ds [user] ¢¥àá¨ï 02.09.16',0 ;¯®¤¯¨áì ®ª­ 
else
capt db 'info 3ds [user] version 18.02.16',0 ;window caption
capt db 'info 3ds [user] version 02.09.16',0 ;window caption
end if
align 16
@ -1417,10 +1425,8 @@ i_end:
color_vert rd 1
color_face rd 1
color_select rd 1
rb 2048
align 16
thread_coords:
rb 2048
rb 4096
stacktop:
sys_path rb 2048
file_name rb 4096

View File

@ -25,6 +25,7 @@ struct obj_3d
z_min dd ?
z_centr dd ?
z_scale dd ?
mat1_data dd ? ;¤ ­­ë¥ 1-£® ¬ â¥à¨ «  ¢ ®¡ê¥ªâ¥
ends
offs_obj_poi_data equ 0 ;㪠§ â¥«ì ­  ª®®à¤¨­ âë ¢¥à設
@ -47,6 +48,7 @@ offs_obj_z_max equ 64
offs_obj_z_min equ 68
offs_obj_z_centr equ 72
offs_obj_z_scale equ 76
offs_obj_mat1_data equ 80
struct material
name dd ?
@ -64,6 +66,7 @@ bit_vertexes equ 0
bit_faces equ 1
bit_faces_fill equ 2
bit_light equ 3
bit_faces_mat equ 4
ini_name db 'info3ds.ini',0
ini_sec_w3d db 'Window 3d',0
@ -118,6 +121,7 @@ proc obj_clear_param uses edi, o_data:dword
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
mov dword[edi+offs_obj_mat1_data],0
cmp dword[edi+offs_obj_normals_tri_data],0
je @f
stdcall mem.Free,[edi+offs_obj_normals_tri_data]
@ -526,6 +530,13 @@ proc obj_init, o_data:dword
mov [edi+offs_obj_tri_count],edx
add esi,8 ;2+4+2 (chunk+size+count)
mov [edi+offs_obj_tri_data],esi
;¯®¨áª ¬ â¥à¨ «®¢ £à ­¥©
shl edx,3
add esi,edx
cmp word[esi],CHUNK_FACEMAT
jne .end_points
mov [edi+offs_obj_mat1_data],esi
.end_points:
stdcall obj_set_sizes, edi
@ -539,8 +550,11 @@ end if
endp
;­ áâனª  ¬ â¥à¨ « 
;input:
; m_data - 㪠§ â¥«ì ­  § ¯®«­ï¥¬ãî áâàãªâãàã á ¬ â¥à¨ «®¬
; f_data - 㪠§ â¥«ì­  ­  ¡«®ª CHUNK_MATERIAL ¨§ ä ©«  3ds
align 4
proc mat_init, m_data:dword
proc mat_init, m_data:dword, f_data:dword
pushad
mov edi,[m_data]
@ -550,12 +564,8 @@ proc mat_init, m_data:dword
mov dword[edi+offs_mat_col_diffuse],0
mov dword[edi+offs_mat_col_specular],0
stdcall [tl_node_get_data],tree1
xor edx,edx
cmp eax,0
je .no_material
mov ebx,[eax] ;¯®«ãç ¥¬ §­ ç¥­¨¥ ᤢ¨£  ¢ë¡à ­­®£® ¡«®ª 
add ebx,[open_file_data]
mov ebx,[f_data]
xor ecx,ecx
cmp word[ebx],CHUNK_MATERIAL
jne .no_material
@ -714,6 +724,22 @@ end if
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]
if version_edit eq 0
;à¨á®¢ ­¨¥ £à ­¥© á ¨á¯®«ì§®¢ ­¨¥¬ 梥⮢ ¬ â¥à¨ «®¢
bt dword[draw_mode],bit_faces_mat
jnc @f
mov eax,[edi+offs_obj_mat1_data]
.b_found:
cmp eax,0
je .end_triangles
mov ebx,eax
stdcall get_mat_color, eax
stdcall draw_3d_faces_color, edi,ebx,eax
stdcall found_mat_faces, ebx
jmp .b_found
@@:
end if
;à¨á®¢ ­¨¥ â®ç¥ª
bt dword[draw_mode],bit_vertexes
jnc .end_points
@ -863,7 +889,7 @@ SetLight:
align 4
mnu_vertexes_on:
or dword[draw_mode], 1 shl bit_vertexes
and dword[draw_mode], not (1 shl bit_faces) ;¢ëª«îç ¥¬ ०¨¬ à¨á®¢ ­¨ï £à ­¥© (çâ®-¡ë ­¥ ¬¥è «¨)
and dword[draw_mode], not ((1 shl bit_faces)+(1 shl bit_faces_mat)) ;¢ëª«îç ¥¬ ०¨¬ë à¨á®¢ ­¨ï, ª®â®àë¥ ¬®£ãâ ¬¥è âì
call update_obj
ret
@ -871,7 +897,7 @@ mnu_vertexes_on:
align 4
mnu_edges_on:
or dword[draw_mode], 1 shl bit_faces
and dword[draw_mode], not ((1 shl bit_vertexes)+(1 shl bit_faces_fill))
and dword[draw_mode], not ((1 shl bit_vertexes)+(1 shl bit_faces_fill)+(1 shl bit_faces_mat))
call update_obj
ret
@ -879,7 +905,7 @@ mnu_edges_on:
align 4
mnu_faces_on:
or dword[draw_mode], (1 shl bit_faces)+(1 shl bit_faces_fill)
and dword[draw_mode], not (1 shl bit_vertexes)
and dword[draw_mode], not ((1 shl bit_vertexes)+(1 shl bit_faces_mat))
call update_obj
ret
@ -908,6 +934,13 @@ update_obj:
else
;¢ª«îç ¥¬ ०¨¬ à¨á®¢ ­¨ï ᯫ®è­ëå £à ­¥©
align 4
mnu_faces_mat:
or dword[draw_mode], (1 shl bit_faces_mat)
call update_obj
ret
align 4
update_obj:
push eax ebx
@ -918,12 +951,120 @@ push eax ebx
add ebx,dword[open_file_data] ;¯®«ãç ¥¬ §­ ç¥­¨¥ ᤢ¨£  ¢ ¯ ¬ïâ¨
cmp word[ebx],CHUNK_OBJBLOCK
jne @f
add eax,14 ;14=list_offs_obj3d
add eax,list_offs_obj3d
stdcall draw_3d,eax
@@:
pop ebx eax
ret
;input:
; p_mat - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¯à¥¤ë¤ã饣® ¬ â¥à¨ « 
align 4
proc found_mat_faces uses ebx, p_mat:dword
mov eax,[p_mat]
add eax,[eax+2]
cmp word[eax],CHUNK_FACEMAT
je @f
xor eax,eax
@@:
ret
endp
align 4
proc get_mat_color uses ebx ecx edx edi esi, p_mat:dword
stdcall [tl_node_poi_get_info], tree1,0
mov ecx,eax
.cycle_0:
cmp ecx,0
je .cycle_0_end
stdcall [tl_node_poi_get_data], tree1,ecx
mov ebx,[eax] ;¯®«ãç ¥¬ §­ ç¥­¨¥ ᤢ¨£  ¢ë¡à ­­®£® ¡«®ª 
add ebx,[open_file_data]
cmp word[ebx],CHUNK_MATERIAL
jne .end_add_p3
add eax,list_offs_obj3d
mov esi,[eax+offs_mat_name]
cmp esi,0
jne @f
;init material
stdcall mat_init,eax,ebx
mov esi,[eax+offs_mat_name]
@@:
mov edi,[p_mat]
mov eax,5
add edi,eax
align 4
@@:
cmp al,0
je .found
lodsb
inc edi
cmp byte[edi],al
je @b
.end_add_p3:
stdcall [tl_node_poi_get_next_info], tree1,ecx
mov ecx,eax ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
jmp .cycle_0
.cycle_0_end:
.no_found:
xor eax,eax
jmp .end_f
.found:
stdcall [tl_node_poi_get_data], tree1,ecx
add eax,list_offs_obj3d
mov eax,[eax+offs_mat_col_diffuse]
.end_f:
ret
endp
align 4
proc draw_3d_faces_color o_data:dword, p_mat:dword, color:dword
pushad
stdcall [glPolygonMode], GL_FRONT_AND_BACK,GL_FILL
stdcall [glColor3ub],[color+2],[color+1],[color]
stdcall [glBegin],GL_TRIANGLES
mov edi,[o_data]
mov esi,[p_mat]
add esi,6
@@:
lodsb
cmp al,0
jne @b
movzx ecx,word[esi] ;ecx - ç¨á«® £à ­¥© á ¤ ­­ë¬ ¬ â¥à¨ «®¬
mov edx,[edi+offs_obj_poi_data]
align 4
@@:
add esi,2
;word[esi] - ­®¬¥à âà¥ã£®«ì­¨ª 
movzx ebx,word[esi]
shl ebx,3
add ebx,[edi+offs_obj_tri_data]
movzx eax,word[ebx] ;1-ï ¢¥à設 
imul eax,12 ;float(x,y,z)
add eax,edx
stdcall [glVertex3f], [eax],[eax+4],[eax+8]
movzx eax,word[ebx+2] ;2-ï ¢¥à設 
imul eax,12 ;float(x,y,z)
add eax,edx
stdcall [glVertex3f], [eax],[eax+4],[eax+8]
movzx eax,word[ebx+4] ;3-ï ¢¥à設 
imul eax,12 ;float(x,y,z)
add eax,edx
stdcall [glVertex3f], [eax],[eax+4],[eax+8]
dec ecx
jnz @b
stdcall [glEnd]
.end_f:
popad
ret
endp
end if
align 4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB