资源简介
用Matlab实现的Z-Buffer算法,其中读取了一个wrl文件和obj文件
代码片段和文件信息
function [vertexfacesnormallocationpicture] = read_obj(filenamepicturename)
% read_obj - load a .obj file.
%
% [vertexfacenormal] = read_obj(filename);
%
% faces : list of facesangle elements
% vertex : node vertexinatates
% normal : normal vector list
%
% Copyright (c) 2008 Gabriel Peyre
fid = fopen(filename);
if fid<0
error([‘Cannot open ‘ filename ‘.‘]);
end
frewind(fid);
a = fscanf(fid‘%c‘1);
if strcmp(a ‘P‘)
% This is the montreal neurological institute (MNI) specific ASCII facesangular mesh data structure.
% For FreeSurfer software a slightly different data input coding is
% needed. It will be provided upon request.
fscanf(fid‘%f‘5);
n_points=fscanf(fid‘%i‘1);
vertex=fscanf(fid‘%f‘[3n_points]);
normal=fscanf(fid‘%f‘[3n_points]);
n_faces=fscanf(fid‘%i‘1);
fscanf(fid‘%i‘5+n_faces);
faces=fscanf(fid‘%i‘[3n_faces])‘+1;
fclose(fid);
return;
end
frewind(fid);
vertex = [];
faces = [];
location = [];
normal = [];
while 1
s = fgetl(fid);
if ~ischar(s)
break;
end
if ~isempty(s) && strcmp(s(1) ‘f‘)
% face
af = sscanf(s(3:end)‘%d/%d/%d %d/%d/%d %d/%d/%d‘);
faces(:end+1) =af(1:3:end1);
% faces(:end+1) = sscanf(s(3:end) ‘%d %d %d‘);
end
if ~isempty(s) && strcmp(s(1) ‘v‘)
if strcmp(s(2) ‘ ‘)
% vertex
vertex(:end+1) = sscanf(s(3:end) ‘%f %f %f‘);
elseif strcmp(s(2) ‘t‘)
location(:end+1) = sscanf(s(4:end) ‘%f %f‘);
elseif strcmp(s(2) ‘n‘)
normal(:end+1) = sscanf(s(4:end) ‘%f %f %f‘);
end
end
end
fclose(fid);
picture = imread(picturename);
[highwidth~] = size(picture);
location(1:) = location(1:) * width;
location(2:) = high-1-location(2:) * high;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 103625 2016-07-26 21:34 test\Angry\000.jpg
文件 6607102 2016-07-25 15:17 test\Angry\000.wrl
文件 687801 2013-07-27 20:36 test\bu4d_test\0000.jpg
文件 211 2013-07-27 20:39 test\bu4d_test\0000.mtl
文件 8566714 2013-07-27 20:26 test\bu4d_test\0000.obj
文件 1840 2018-05-17 19:38 test\read_obj.m
文件 1628 2018-05-16 22:01 test\read_wrl.m
文件 56864 2018-05-17 20:24 test\result.png
文件 671 2018-05-17 20:24 test\test_obj.m
文件 653 2018-05-17 20:23 test\test_wrl.m
文件 2921 2018-05-17 20:14 test\ZBuffer.m
..AD... 0 2018-05-17 20:26 test\Angry
目录 0 2018-05-17 20:22 test\bu4d_test
目录 0 2018-05-17 20:24 test
----------- --------- ---------- ----- ----
16030030 14
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
川公网安备 51152502000135号
评论
共有 条评论