Image texture on face vertice 3D Model
5 views (last 30 days)
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?
0 Comments
Answers (1)
Walter Roberson
on 14 Jan 2021
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.
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots 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!