How can I export a figure to mashlab-like editable format?
8 ビュー (過去 30 日間)
古いコメントを表示
My very best idea is to fully export the figure plotted by pattern function, to load it into Unity. However, I only managed to get the values of X, Y and Z and export a colorless surf plot into STL format (with surf2stl).
Being unable to colorize it in apps like meshlab, I need to export the figure and the color. I have seen a very close post to this one, unanswered since 2012 ( mathworks post ).
Here it is what pattern plots:

Here it is what I'd like to export:

And this is what I got, and how:

% Code for pattern figure (first figure, the colorful one)
% Obtained by AntennaToolbox
load('antennaDipole.mat'); % Loads antennaObject
plotFrequency = 2700000000;
figure;
pattern(antennaObject, plotFrequency);
I debugged it stepping into every function until I reached surf, where I manually saved X,Y and Z values, as well as other inner parameters that allows me to plot with color as I'll write soon below.
% Code for the surf (second figure (the colored sharpy one))
load('valuesXYZ.mat') % Saved while debugging previous code
surf(x,y,z);
surf2stl('DipoleMeander.stl',x,y,z); % Save grey figure
And after debugging a bit more and understanding the inside I got to plot the first picture, with the proper colors; although here's where I'm stuck since I can't export the colors with surf2stl (as it can be seen in the third picture, the grey one).
To get also the color mapping:
% Similar code as the one before
load('valuesXYZdipole.mat')
load('allargs.mat')
cell=allargs(8); % Color data, as a matrix
surf(x,y,z,cell{:})
I want the color-mapped 3D object so that I can load it into meshlab (or any other object editor), force invert faces, then export into OBJ format and finally into unity as a prefab. Any idea of how to export the figure with the color or the color only as a material/filter/something? Or to get what I want in a different way.
1 件のコメント
DGM
2025 年 10 月 9 日 12:46
編集済み: DGM
2025 年 10 月 9 日 13:00
STL canonically does not support color information, but there are at least two poorly documented and broadly unsupported proprietary conventions for abusing reserved fields in order to store per-face color data. As of early 2018, the only available tool would have been FEX #20922, though it only supports one format, and would have required you to put the color data into a nonstandard uint5-scale. As of today, the R2018b built-in tools could be used if you knew how to do the data preparation yourself, but again, it's restricted to the one format since it can't write anything to the header field. FEX #182013 has broader and intended support for these proprietary features.
This is all moot, though. To my knowledge, Meshlab does not support any of these color packing schemes in STL. I don't know about configuring other formats like OBJ or what else is supported by Meshlab or Unity.
If all you need to do is flip the faces, either changes need to be made in the triangulation process, or you can just take your face list and flip it.
Other similar examples of STL export from antenna tools:
In these examples, the mesh is exported right-side-out. At the very least, they expose the mesh as F,V data which can trivially be flipped with fliplr(F).
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!