资源简介
用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
相关资源
- sift matlab代码
- 用四阶统计量方法对图像特征进行提
- Matlab 2015b Win32 Crack
- matlab下的概率密度函数
- OFDM-MIMOMATLAB
- MATLAB下PSAT工具箱使用说明中文版
- cplex 12.4 MATLAB工具箱
- matlab connector
- 高斯模糊图像的盲复原
- 精通MATLAB数字图像处理2015的源代码
- 精通Matlab图形绘制
- 扩频通信系统的MATLAB仿真
- 一个通信抗干扰仿真MATLAB代码
- bayes分类器完整版代码
- 数字与图像处理matlab课程设计
- Matlab科学计算与可视化仿真宝典-源码
- Introduction to MATLAB
- MATLAB精彩编程100例
- MATLAB SIFT 代码
- matlab 2014b_x64 破解 mcc真正可用
- 5G Development with MATLAB
- 04-图像复原MATLAB
- 点云的三维重建代码,内容丰富matl
- matlab自动代码生成
- 《MATLAB高效编程技巧与应用的25个案例
- MATLAB模拟的电磁学数值技术
- 视频镜头分割及关键帧提取MATLAB
- 小波变换法图像融合MATLAB代码
- petri net matlab simulation
- SVM-KM Matlab源程序
评论
共有 条评论