Professional Documents
Culture Documents
MATLAB
3D Obj
2013/01/02
1 / 23
3D ObjMATLAB
Introduction to Obj le
OBJ
Wavefront 3D
2 / 23
3D ObjMATLAB
Introduction to Obj le
3D
.3ds : 3D Studio
.dxf : AutoCAD
.o :
.ply
.lwob; .lwlo : Lightwave 3D
.vrml :
3 / 23
3D ObjMATLAB
Introduction to Obj le
3D
3D
Autodesk 3DS MAX
Autodesk Maya
Autodesk Softimage XI
Lightwave 3D
4 / 23
3D ObjMATLAB
Introduction to Obj le
3D object converter
http://web.t-online.hu/karpo/
: obj viewer
http://www.pyramidproject.net/objviewer.php
5 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Data structure
6 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Display 3D object in MATLAB
MATLAB
3D
trimesh:
trisurf:
light:
7 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Display 3D object in MATLAB
OBJ
MATLAB
MATLAB
simple_obj
WOBJ_toolbox
Obj_IO_library
8 / 23
3D ObjMATLAB
Object Read/write in MATLAB
simple_obj
simple_obj
: Alec Jacobson
9 / 23
3D ObjMATLAB
Object Read/write in MATLAB
simple_obj
simple_obj
clear
close a l l
% obj 3D
[V, F ] = read_vertices_and_faces_from_obj_file ( ' cessna .
obj ' ) ;
% obj 3D
t r i s u r f (F ,V(: ,1 ) ,V( : ,2 ) ,V( : ,3 ) , ' FaceColor '
,[0.26 ,0.33 ,1.0 ] ) ;
l i g h t ( ' Position ' ,[ -1.0 , -1.0 ,100.0] , ' Style ' , ' i n f i n i t e ' ) ;
l i g h t i n g phong ;
10 / 23
3D ObjMATLAB
Object Read/write in MATLAB
simple_obj
simple_obj
11 / 23
3D ObjMATLAB
Object Read/write in MATLAB
WOBJ_toolbox
WOBJ_toolbox
http://www.mathworks.com/matlabcentral/leexchange/27982wavefront-obj-toolbox
.vertices
.objects.data.vertices
12 / 23
3D ObjMATLAB
Object Read/write in MATLAB
WOBJ_toolbox
WOBJ_toolbox
read_wobj
3D=read_wobj('');
:
A=read_wobj('example2.obj');
A.vertices length(A.vertices)
A.objects.data.vertices
length(A.objects.data.vertices)
13 / 23
3D ObjMATLAB
Object Read/write in MATLAB
WOBJ_toolbox
write_wobj
write_wobj(3D,"");
14 / 23
3D ObjMATLAB
Object Read/write in MATLAB
WOBJ_toolbox
WOBJ_toolbox
clear
close a l l
% obj 3D
A = read_wobj ( ' example2 . obj ' ) ;
% obj 3D
f p r i n t f ( '#(node )=%d\n ' , l e n g t h (A. v e r t i c e s ) ) ;
f p r i n t f ( '#(face )=%d\n ' , l e n g t h (A. objects . data . v e r t i c e s ) )
;
t r i s u r f (A. objects . data . v e r t i c e s , . . .
A. v e r t i c e s (: ,1) ,A. v e r t i c e s ( : , 2) ,A. v e r t i c e s (: ,3) , . . .
' FaceColor ' ,[0.26 ,0.33 ,1.0 ] ) ;
l i g h t ( ' Position ' ,[ -1.0 , -1.0 ,100.0] , ' Style ' , ' i n f i n i t e ' ) ;
l i g h t i n g phong ;
% obj 3D
write_wobj (A, ' t e s t . obj ' ) ;
15 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
Obj_IO library
obj_io
John
Burkardt, 2008
http://people.sc.fsu.edu/jburkardt/m_src/obj_io/obj_io.html
16 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
Obj_IO library:
.OBJ
[, , ]= obj_size('');
17 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
Obj_IO libary:
.OBJ ()
[, , , ]=
obj_read(,, , )
18 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
Obj_IO libary:
obj_display('')
3D?
trisurf(face_node',node_xyz(1,:),node_xyz(2,:),node_xyz(3,:),'facecolor',
0 0]);
19 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
Obj_IO library
clear
close a l l
%
[ filename , pathname ] = u i g e t f i l e ({ ' *. obj ' , '3D Obj F i l e s
' ;...
' *.* ' , ' All F i l e s ' } , ' choose a model ' ) ;
[ node_num , face_num , normal_num , order_max ] =
obj_size ( filename ) ;
f p r i n t f ( '#(node )=%d\n ' ,node_num) ;
f p r i n t f ( '#(face )=%d\n ' ,face_num) ;
%
[ node_xyz , face_order , face_node , normal_vector ,
vertex_normal ] = . . .
obj_read ( filename , node_num , face_num , normal_num ,
order_max ) ;
%
obj_display ( filename ) ;
20 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
OBJ_IO library
obj_display
21 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
Obj_IO libary:
obj_write(, , , ,
, , , )
22 / 23
3D ObjMATLAB
Object Read/write in MATLAB
Obj_IO library
23 / 23