Filter löschen
Filter löschen

how can i map a 2d texture image in 3d surface ?

18 Ansichten (letzte 30 Tage)
youb mr
youb mr am 21 Okt. 2020
Kommentiert: youb mr am 22 Okt. 2020
hello every one
I have a texture image I want to map this texture to a 3d object ,where i want which each face of this 3d surface will be plated with this image this is my code
v = fv.vertices; % vertices [x y z] columns
f=fv.faces;
nx = 120; % the size of the grid
ny = 120; % the size of the grid
% create a grid in x and y
x = linspace(min(v(:,1)),max(v(:,1)),nx);
y = linspace(min(v(:,2)),max(v(:,2)),ny);
[x,y] = meshgrid(x,y);
Z = gridtrimesh(f,v,x,y);
surf(x,y,Z,'facecolor','texturemap', ...
'cdata',I,'edgecolor','none');
but I don't have the result which I wanted how I can solve the problem ?

Antworten (1)

drummer
drummer am 21 Okt. 2020
Your code is not very clear, but I assume your 2D texture is f, right?
You want a 3D plot of each surface?
Would this work?
v = rand(10,10); % mimicking your faces. Notice it is two dimensional
figure
surfc(v); % Notice this way, the dimensions of your 3D plot will be the dimension of your faces.
% Therefore, no grid was necessary.
You can code a workaround for each face.
If that helps, please accept the answer.
Cheers.
  1 Kommentar
youb mr
youb mr am 22 Okt. 2020
no my textrure is I where v and f ar the cordinate of 3d surface

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by