- Download the Wavefront OBJ Toolbox from MATLAB File exchange using the following link- https://in.mathworks.com/matlabcentral/fileexchange/27982-wavefront-obj-toolbox .
- Extract the “write_wobj.m” file in your current path.
- Save the “gcf” of your figure as a “.png” file to be used later for applying texture from image in blender.
- Create the “.obj” for the sphere plot as per the example given in the toolbox.
- Import the “.obj” file in blender.
- Select the object and create a new material for the object.
- Define a new material for the object and under “base color” select “image texture”.
How to unwrap Spherical surface function
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I would like to unwrap a plotted sphere into a 2D image so it can be used as texture or import the 3D figure with colors to use in blender (colormap is important) I know matlab functions can be expoerted into stl or x3d files but when I open it in blender it is just a sphere without colors. Any help will be appreciated
0 comentarios
Respuestas (1)
VINAYAK LUHA
el 27 de Sept. de 2023
Hi Apops,
I understand that you have plotted a sphere in MATLAB, and you want to export it along with its colormap and use it in Blender. Here is a workaround involving exporting the sphere in “.obj” format, which unlike “.stl” format, also supports color information:
You can now see a preview of the object with the colormap applied on it in the preview window.
Here is the code for generating “.obj” file and the “image texture” file your reference:
[x, y, z] = sphere(100);
c = hypot(x, y);
surf(x, y, z, c, 'FaceColor', 'interp', 'EdgeColor', 'none');
colormap jet;
colorbar;
OBJ.vertices = [x(:), y(:), z(:)];
OBJ.material = struct('type', 'newmtl', 'data', 'sphere_material');
OBJ.objects(1).type = 'g';
OBJ.objects(1).data = 'sphere_object';
OBJ.objects(2).type = 'usemtl';
OBJ.objects(2).data = 'sphere_material';
OBJ.objects(3).type = 'f';
OBJ.objects(3).data.vertices = surf2patch(x, y, z).faces;
filename = 'sphere.obj';
write_wobj(OBJ, filename);
filename = 'sphere_texture.png';
saveas(gcf, filename);
Explore the documentation of the following functions for more details:
Hope this helps.
Regards,
Vinayak Luha
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!