資源簡介
from:
http://people.sc.fsu.edu/~jburkardt/data/obj/obj.html
代碼片段和文件信息
function?obj_display?(?input_file_name?)
%*****************************************************************************80
%
%%?OBJ_DISPLAY?displays?the?faces?of?a?shape?defined?by?an?OBJ?file.
%
%??Usage:
%
%????obj_display?(?‘file.obj‘?)
%
%??Licensing:
%
%????This?code?is?distributed?under?the?GNU?LGPL?license.
%
%??Modified:
%
%????27?September?2008
%
%??Author:
%
%????John?Burkardt
%
??timestamp?(?);
??fprintf?(?1?‘\n‘?);
??fprintf?(?1?‘OBJ_DISPLAY\n‘?);
??fprintf?(?1?‘??MATLAB?version\n‘?);
??fprintf?(?1?‘\n‘?);
??fprintf?(?1?‘??Reads?an?object?in?an?ASCII?OBJ?file.\n‘?);
??fprintf?(?1?‘??Display?it?as?a?MATLAB?shape.\n‘?);
%
%??If?at?least?one?command?line?argument?it‘s?the?input?file?name.
%
??if?(?nargin?1?)
????fprintf?(?1?‘\n‘?);
????fprintf?(?1?‘OBJ_DISPLAY:\n‘?);
????input_file_name?=?input?(?‘Enter?the?name?of?the?input?file:‘?);
??end
%
%??Get?sizes.
%
??[?node_num?face_num?normal_num?order_max?]?=?obj_size?(?input_file_name?);
%
%??Print?the?sizes.
%
??obj_size_print?(?input_file_name?node_num?face_num?normal_num?order_max?);
%
%??Get?the?data.
%
??[?node_xyz?face_order?face_node?]?=?...
????obj_read?(?input_file_name?node_num?face_num?normal_num?order_max?);
%
%??FACE_NODE?may?contain?polygons?of?different?orders.
%??To?make?the?call?to?PATCH?we?will?assume?all?the?polygons?are?the?same?order.
%??To?do?so?we‘ll?simply?“stutter“?the?first?node?in?each?face?list.
%
??for?face?=?1?:?face_num
????face_node(face_order(face)+1:order_maxface)?=?face_node(1face);
??end
%
%??If?any?node?index?is?still?less?than?1?set?the?whole?face?to?1‘s.
%??We‘re?giving?up?on?this?presumably?meaningless?face?but?we?need?to
%??do?it?in?a?way?that?keeps?MATLAB?happy!
%
??for?face?=?1?:?face_num
????for?i?=?1?:?order_max
??????face_node(iface)?=?max?(?face_node(iface)?1?);
????end
??end
%
%??Display?the?shape.
%
??handle?=?patch?(?‘Vertices‘?node_xyz‘?‘Faces‘?face_node‘?);
??
??set?(?handle?‘FaceColor‘?[0.5?0.6?0.8]?‘EdgeColor‘?‘Black‘?);
??axis?equal;?
??grid?on;
??xlabel?(?‘--X?axis--‘?)
??ylabel?(?‘--Y?axis--‘?)
??zlabel?(?‘--Z?axis--‘?)
%
%??The?title?function?will?interpret?underscores?in?the?title.
%??We?need?to?unescape?such?escape?sequences!
%
??title_string?=?s_escape_tex?(?input_file_name?);
??title?(?title_string?)
%
%??Terminate.
%
??fprintf?(?1?‘\n‘?);
??fprintf?(?1?‘OBJ_DISPLAY:\n‘?);
??fprintf?(?1?‘??Normal?end?of?execution.\n‘?);
??fprintf?(?1?‘\n‘?);
??timestamp?(?);
??return
end
function?c?=?ch_cap?(?c?)
%*****************************************************************************80
%
%%?CH_CAP?capitalizes?a?single?character.
%
%??Licensing:
%
%????This?code?is?distributed?under?the?GNU?LGPL?license.
%
%??Modified:
%
%????22?November?2003
%
%??Author:
%
%????John?Burkardt
%
%??Parameters:
%
%????Input?character?C?the?character?to?capitalize.
%
%????Output?char
評論
共有 條評論