-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
75 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,5 @@ function init(obj, hidxs) | |
|
||
mesh.p = reshape(u,2,[]); | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,5 @@ function init(obj, hidxs) | |
|
||
obj.mesh.p = reshape(u,2,[]); | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
function [p,t,uv] = readMesh(filename) | ||
% read in vertices and faces from a .off or .obj file | ||
% Input: | ||
% filename file holding mesh | ||
% Output: | ||
% p (vertex list) | ||
% t (face list) | ||
% uv (texture coordinates list) | ||
% | ||
% Copyright 2011, Alec Jacobson ([email protected]) | ||
% | ||
% See also: readOBJ, readOBJfast, readOFF | ||
% | ||
uv = []; | ||
% read in vertices and faces from a .off or .obj file | ||
% Input: | ||
% filename file holding mesh | ||
% Output: | ||
% p (vertex list) | ||
% t (face list) | ||
% uv (texture coordinates list) | ||
% | ||
% Copyright 2011, Alec Jacobson ([email protected]) | ||
% | ||
% See also: readOBJ, readOBJfast, readOFF | ||
% | ||
uv = []; | ||
|
||
if ~isempty(regexp(filename,'\.off$')) | ||
[V,F] = readOFF(filename); | ||
elseif ~isempty(regexp(filename,'\.obj$')) | ||
if nargout > 2, | ||
[V,F,UV] = readOBJ(filename); | ||
uv = UV'; | ||
else | ||
try | ||
[V,F] = readOBJfast(filename); | ||
catch exception | ||
fprintf('Fast reader failed, retrying with more robust, slower reader\n'); | ||
[V,F] = readOBJ(filename); | ||
if ~isempty(regexp(filename,'\.off$')) | ||
[V,F] = readOFF(filename); | ||
elseif ~isempty(regexp(filename,'\.obj$')) | ||
if nargout > 2, | ||
[V,F,UV] = readOBJ(filename); | ||
uv = UV'; | ||
else | ||
try | ||
[V,F] = readOBJfast(filename); | ||
catch exception | ||
fprintf('Fast reader failed, retrying with more robust, slower reader\n'); | ||
[V,F] = readOBJ(filename); | ||
end | ||
end | ||
else | ||
error('Input file must be .off or .obj file.'); | ||
end | ||
else | ||
error('Input file must be .off or .obj file.'); | ||
end | ||
|
||
% adapt to our convention | ||
p = V'; | ||
t = F'; | ||
% adapt to our convention | ||
p = V'; | ||
t = F'; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,42 +14,44 @@ | |
% WARNING: This is at least 40 times slower than readOFF but probably much much | ||
% slower... | ||
% | ||
% Copyright 2011, Alec Jacobson ([email protected]) | ||
% | ||
% See also: load_mesh, readOBJfast, readOFF | ||
|
||
V = []; | ||
UV = []; | ||
F = []; | ||
fp = fopen( filename, 'r' ); | ||
type = fscanf( fp, '%s', 1 ); | ||
while strcmp( type, '' ) == 0 | ||
if strcmp( type, 'v' ) == 1 | ||
v = fscanf( fp, '%g %g %g\n' ); | ||
V = [V; v']; | ||
elseif strcmp( type, 'vt') | ||
v = fscanf( fp, '%g %g %g\n' ); | ||
UV = [UV; v']; | ||
elseif strcmp( type, 'f' ) == 1 | ||
line = fgets(fp); | ||
[t, count] = sscanf(line, '%d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d'); | ||
V = []; | ||
UV = []; | ||
F = []; | ||
fp = fopen( filename, 'r' ); | ||
type = fscanf( fp, '%s', 1 ); | ||
while strcmp( type, '' ) == 0 | ||
if strcmp( type, 'v' ) == 1 | ||
v = fscanf( fp, '%g %g %g\n' ); | ||
V = [V; v']; | ||
elseif strcmp( type, 'vt') | ||
v = fscanf( fp, '%g %g %g\n' ); | ||
UV = [UV; v']; | ||
elseif strcmp( type, 'f' ) == 1 | ||
line = fgets(fp); | ||
[t, count] = sscanf(line, '%d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d'); | ||
|
||
if (count>2) | ||
t = t(1:3:end); | ||
else | ||
[t, count] = sscanf(line, '%d/%d %d/%d %d/%d %d/%d %d/%d'); | ||
if (count>2) | ||
t = t(1:2:end); | ||
else | ||
[t, count] = sscanf( line, '%d %d %d %d %d %d %d %d %d %d %d\n' ); | ||
end | ||
end | ||
F = [F; t']; | ||
elseif strcmp( type, '#' ) == 1 | ||
fscanf( fp, '%s\n', 1 ); | ||
end | ||
type = fscanf( fp, '%s', 1 ); | ||
end | ||
fclose( fp ); | ||
if (count>2) | ||
t = t(1:3:end); | ||
else | ||
[t, count] = sscanf(line, '%d/%d %d/%d %d/%d %d/%d %d/%d'); | ||
if (count>2) | ||
t = t(1:2:end); | ||
else | ||
[t, count] = sscanf( line, '%d %d %d %d %d %d %d %d %d %d %d\n' ); | ||
end | ||
end | ||
F = [F; t']; | ||
elseif strcmp( type, '#' ) == 1 | ||
fscanf( fp, '%s\n', 1 ); | ||
end | ||
type = fscanf( fp, '%s', 1 ); | ||
end | ||
fclose( fp ); | ||
|
||
%% transform into array if all faces have the same number of vertices | ||
if (size(UV,1)>0) UV = UV; end | ||
%% transform into array if all faces have the same number of vertices | ||
if (size(UV,1)>0) UV = UV; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
% C #V by 3 list of colors | ||
% N #V by 3 list of normals | ||
% | ||
% Copyright 2011, Alec Jacobson ([email protected]) | ||
% | ||
% See also: load_mesh, readOBJfast, readOBJ | ||
|
||
V = []; | ||
|