Image texture on face vertice 3D Model
Show older comments
I'd like to texture a 3D model described by faces and vertices with an image.
Therefore I tried with the MATLAB method surface like this:
% definition of faces and vertices above
n = length(vertices)/3;
X = reshape(vertices(:,1),3,n);
Y = reshape(vertices(:,2),3,n);
Z = reshape(vertices(:,3),3,n);
img = imread('image.png'); % mandrill image
surface(X,Y,Z,...
'Cdata', img,...
'FaceColor','texturemap',...
'EdgeColor','none',...
'FaceLighting','gouraud')
But this doesn't really work as my 3D Model has lots of 'empty' faces:

Same happens using the method warp like this:
warp (X,Y,Z,img)
Is this a MATLAB bug or am I doing something wrong?
Answers (1)
Walter Roberson
on 14 Jan 2021
0 votes
If you have empty faces, then nothing can be drawn there.
Perhaps you should use boundary() https://www.mathworks.com/help/matlab/ref/boundary.html with a shrink factor, in order to get the outside layer connections (like a tight-fitting bounding box) and texture on top of that.
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!