Skip to content

Instantly share code, notes, and snippets.

@daeyun
Created February 21, 2015 04:52
Show Gist options
  • Save daeyun/853139e333b650ff658d to your computer and use it in GitHub Desktop.
Save daeyun/853139e333b650ff658d to your computer and use it in GitHub Desktop.
function renderMesh(Mesh, vertexColors, az, el, upvec)
if ~exist('vertexColors', 'var'), vertexColors=zeros(size(Mesh.v,1), 1); end
if ~exist('az', 'var'), az=-45; end
if ~exist('el', 'var'), el=-120; end
if ~exist('upvec', 'var'), upvec=[0 1 0]; end
y=Mesh.v(:,2);
Mesh.v(:,2)=Mesh.v(:,3);
Mesh.v(:,3)=y;
patch('vertices', Mesh.v, 'faces',Mesh.f, ...
'FaceVertexCData', vertexColors, ...
'FaceColor', 'interp', 'CDataMapping', 'scaled', 'edgecolor', 'interp');
%, 'EdgeColor','flat');
axis off;
axis equal;
axis vis3d;
view(az, el);
camtarget(mean(Mesh.v));
camproj('perspective');
lighting gouraud;
cameramenu;
shading interp;
camlight('headlight')
set(gca,'CameraUpVector', upvec);
cameratoolbar('Show');
cameratoolbar('SetMode', 'orbit');
cameratoolbar('SetCoordSys', 'z');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment