当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 6

梁俊伍/使用kinodynamic RRTStar算法规划轨迹
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
readObj.m 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
function obj = readObj(fname)
%
% obj = readObj(fname)
%
% This function parses wavefront object data
% It reads the mesh vertices, texture coordinates, normal coordinates
% and face definitions(grouped by number of vertices) in a .obj file
%
%
% INPUT: fname - wavefront object file full path
%
% OUTPUT: obj.v - mesh vertices
% : obj.vt - texture coordinates
% : obj.vn - normal coordinates
% : obj.f - face definition assuming faces are made of of 3 vertices
%
% Bernard Abayowa, Tec^Edge
% 11/8/07
% set up field types
v = []; vt = []; vn = []; f.v = []; f.vt = []; f.vn = [];
fid = fopen(fname);
% parse .obj file
while 1
tline = fgetl(fid);
if ~ischar(tline), break, end % exit at end of file
ln = sscanf(tline,'%s',1); % line type
%disp(ln)
switch ln
case 'v' % mesh vertexs
v = [v; sscanf(tline(2:end),'%f')'];
case 'vt' % texture coordinate
vt = [vt; sscanf(tline(3:end),'%f')'];
case 'vn' % normal coordinate
vn = [vn; sscanf(tline(3:end),'%f')'];
case 'f' % face definition
fv = []; fvt = []; fvn = [];
str = textscan(tline(2:end),'%s'); str = str{1};
nf = length(findstr(str{1},'/')); % number of fields with this face vertices
[tok str] = strtok(str,'//'); % vertex only
for k = 1:length(tok) fv = [fv str2num(tok{k})]; end
if (nf > 0)
[tok str] = strtok(str,'//'); % add texture coordinates
for k = 1:length(tok) fvt = [fvt str2num(tok{k})]; end
end
if (nf > 1)
[tok str] = strtok(str,'//'); % add normal coordinates
for k = 1:length(tok) fvn = [fvn str2num(tok{k})]; end
end
f.v = [f.v; fv]; f.vt = [f.vt; fvt]; f.vn = [f.vn; fvn];
end
end
fclose(fid);
% set up matlab object
obj.v = v; obj.vt = vt; obj.vn = vn; obj.f = f;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/liang-junwu/kinodynamic-RRTStar-for-landing-on-small-body.git
git@gitee.com:liang-junwu/kinodynamic-RRTStar-for-landing-on-small-body.git
liang-junwu
kinodynamic-RRTStar-for-landing-on-small-body
使用kinodynamic RRTStar算法规划轨迹
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385