资源简介
MATLAB读取obj文件中的数据,读取的数据是点和面
代码片段和文件信息
function [node_xyz face_node ]= obj__read( 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
%
% Get sizes.
%
[ node_num face_num normal_num order_max ] = obj_size ( input_file_name );
%
% 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.
% The title function will interpret underscores in the title.
% We need to unescape such escape sequences!
return
end
function c = ch_cap ( c )
%*****************************************************************************80
%
%% CH_CAP capitalizes a single character.
%
% Parameters:
%
% Input character C the character to capitalize.
% Output character C the capitalized character.
%
if ( ‘a‘ <= c && c <= ‘z‘ )
c = c + ‘A‘ - ‘a‘;
end
return
end
function truefalse = ch_eqi ( c1 c2 )
%*****************************************************************************80
%
%% CH_EQI is a case insensitive comparison of two characters for equality.
%
% Example:
%
% CH_EQI ( ‘A‘ ‘a‘ ) is TRUE.
%
%
% Parameters:
%
% Input character C1 C2 the characters to compare.
%
% Output logical TRUEFALSE is TRUE (1) if the characters are equal.
%
FALSE = 0;
TRUE = 1;
if ( ch_cap ( c1 ) == ch_cap ( c2 ) )
truefalse = TRUE;
else
truefalse = FALSE;
end
return
end
function value = ch_index ( s c )
%*****************************************************************************80
%
%% CH_INDEX is the first occurrence of a character in a string.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 01 May 2004
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input string S the string to be searched.
%
% Input character C the character to be searched for.
%
% Output integer VALUE the location of the first occurrence of C
% in the string or 0 if C doe
- 上一篇:Hibernate的视图功能
- 下一篇:matlab小波信号去噪可用于预测数据预处理
评论
共有 条评论